-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Resources for working with miniscript, and script descriptors -- -- Resources for working with miniscript, and script descriptors @package bitcoin-scripting @version 0.2.0 module Language.Bitcoin.Miniscript.Witness -- | Compute a scriptinput which satisfies this miniscript satisfy :: ChainState -> SatisfactionContext -> Miniscript -> Either SatisfactionError Script data SatisfactionContext satisfactionContext :: [(ByteString, ByteString)] -> [(PubKeyI, Signature)] -> SatisfactionContext -- | Use with the monoid instance to add a signature to the -- SatisfactionContext signature :: PubKeyI -> Signature -> SatisfactionContext -- | Use with the monoid instance to add preimage to the -- SatisfactionContext preimage :: ByteString -> ByteString -> SatisfactionContext lookupSignature :: PubKeyI -> SatisfactionContext -> Maybe Signature lookupPreimage :: ByteString -> SatisfactionContext -> Maybe ByteString data ChainState ChainState :: Maybe Int -> Maybe Int -> ChainState [blockHeight] :: ChainState -> Maybe Int [utxoAge] :: ChainState -> Maybe Int emptyChainState :: ChainState data Signature Signature :: !Sig -> !SigHash -> Signature [sig] :: Signature -> !Sig [sigHash] :: Signature -> !SigHash data SatisfactionError MissingSignature :: [KeyDescriptor] -> SatisfactionError MissingPreimage :: ByteString -> SatisfactionError FreeVariable :: Text -> SatisfactionError TypeError :: Text -> Miniscript -> SatisfactionError Impossible :: SatisfactionError AbstractKey :: KeyDescriptor -> SatisfactionError instance GHC.Show.Show Language.Bitcoin.Miniscript.Witness.Signature instance GHC.Classes.Eq Language.Bitcoin.Miniscript.Witness.Signature instance GHC.Show.Show Language.Bitcoin.Miniscript.Witness.OrdPubKeyI instance GHC.Classes.Eq Language.Bitcoin.Miniscript.Witness.OrdPubKeyI instance GHC.Show.Show Language.Bitcoin.Miniscript.Witness.SatisfactionContext instance GHC.Classes.Eq Language.Bitcoin.Miniscript.Witness.SatisfactionContext instance GHC.Show.Show Language.Bitcoin.Miniscript.Witness.ChainState instance GHC.Classes.Eq Language.Bitcoin.Miniscript.Witness.ChainState instance GHC.Show.Show Language.Bitcoin.Miniscript.Witness.SatisfactionError instance GHC.Classes.Eq Language.Bitcoin.Miniscript.Witness.SatisfactionError instance GHC.Show.Show Language.Bitcoin.Miniscript.Witness.SatScript instance GHC.Classes.Eq Language.Bitcoin.Miniscript.Witness.SatScript instance GHC.Show.Show Language.Bitcoin.Miniscript.Witness.SatResult instance GHC.Classes.Eq Language.Bitcoin.Miniscript.Witness.SatResult instance GHC.Base.Semigroup Language.Bitcoin.Miniscript.Witness.SatScript instance GHC.Base.Monoid Language.Bitcoin.Miniscript.Witness.SatScript instance GHC.Exception.Type.Exception Language.Bitcoin.Miniscript.Witness.SatisfactionError instance GHC.Base.Semigroup Language.Bitcoin.Miniscript.Witness.SatisfactionContext instance GHC.Base.Monoid Language.Bitcoin.Miniscript.Witness.SatisfactionContext instance GHC.Classes.Ord Language.Bitcoin.Miniscript.Witness.OrdPubKeyI module Language.Bitcoin.Script.Utils pushNumber :: Int -> ScriptOp -- | Encode a numeric stack value toCScriptNum :: Int -> ByteString -- | Decode a numeric stack value fromCScriptNum :: ByteString -> Int -- | Haskell embedding of miniscript. See -- http://bitcoin.sipa.be/miniscript/ for details. Much of the -- documentation below is taken from this site. module Language.Bitcoin.Miniscript data Value a Variable :: Text -> Value a Lit :: a -> Value a var :: Text -> Value a literal :: a -> Value a -- | The Miniscript AST with the addition of key descriptors and let -- bindings data Miniscript Var :: Text -> Miniscript Let :: Text -> Miniscript -> Miniscript -> Miniscript Boolean :: Bool -> Miniscript Number :: Int -> Miniscript Bytes :: ByteString -> Miniscript KeyDesc :: KeyDescriptor -> Miniscript Key :: Value KeyDescriptor -> Miniscript KeyH :: Value KeyDescriptor -> Miniscript Older :: Value Int -> Miniscript After :: Value Int -> Miniscript Sha256 :: Value ByteString -> Miniscript Ripemd160 :: Value ByteString -> Miniscript Hash256 :: Value ByteString -> Miniscript Hash160 :: Value ByteString -> Miniscript AndOr :: Miniscript -> Miniscript -> Miniscript -> Miniscript AndV :: Miniscript -> Miniscript -> Miniscript AndB :: Miniscript -> Miniscript -> Miniscript OrB :: Miniscript -> Miniscript -> Miniscript OrC :: Miniscript -> Miniscript -> Miniscript OrD :: Miniscript -> Miniscript -> Miniscript OrI :: Miniscript -> Miniscript -> Miniscript Thresh :: Value Int -> Miniscript -> [Miniscript] -> Miniscript Multi :: Value Int -> [Value KeyDescriptor] -> Miniscript AnnA :: Miniscript -> Miniscript AnnS :: Miniscript -> Miniscript AnnC :: Miniscript -> Miniscript AnnD :: Miniscript -> Miniscript AnnV :: Miniscript -> Miniscript AnnJ :: Miniscript -> Miniscript AnnN :: Miniscript -> Miniscript let_ :: [(Text, Miniscript)] -> Miniscript -> Miniscript -- | Check a key key :: KeyDescriptor -> Miniscript -- | Check a key hash keyH :: KeyDescriptor -> Miniscript older :: Int -> Miniscript after :: Int -> Miniscript sha256 :: ByteString -> Miniscript ripemd160 :: ByteString -> Miniscript hash256 :: ByteString -> Miniscript hash160 :: ByteString -> Miniscript thresh :: Int -> Miniscript -> [Miniscript] -> Miniscript multi :: Int -> [KeyDescriptor] -> Miniscript class MiniscriptAnnotation a (.:) :: MiniscriptAnnotation a => a -> Miniscript -> Miniscript data Annotation A :: Annotation S :: Annotation C :: Annotation D :: Annotation V :: Annotation J :: Annotation N :: Annotation T :: Annotation L :: Annotation U :: Annotation data BaseType -- | Base expression TypeB :: BaseType -- | Verify expression TypeV :: BaseType -- | Key expression TypeK :: BaseType -- | Wrapped expression TypeW :: BaseType -- | Number expression TypeNumber :: BaseType -- | Bytes expression TypeBytes :: BaseType -- | Key descriptor type TypeKeyDesc :: BaseType -- | Type modifications that imply additional properties of the expression data ModField ModField :: Bool -> Bool -> Bool -> Bool -> Bool -> ModField -- | Consumes exactly 0 stack elements [modZ] :: ModField -> Bool -- | One-arg: this expression always consumes exactly 1 stack element. [modO] :: ModField -> Bool -- | Nonzero: this expression always consumes at least 1 stack element, no -- satisfaction for this expression requires the top input stack element -- to be zero. [modN] :: ModField -> Bool -- | Dissatisfiable: a dissatisfaction for this expression can -- unconditionally be constructed. [modD] :: ModField -> Bool -- | Unit: when satisfied put exactly 1 on the stack [modU] :: ModField -> Bool data MiniscriptType MiniscriptType :: BaseType -> ModField -> MiniscriptType [baseType] :: MiniscriptType -> BaseType [modifiers] :: MiniscriptType -> ModField boolType :: Bool -> MiniscriptType numberType :: MiniscriptType bytesType :: MiniscriptType keyDescriptorType :: MiniscriptType -- | Check that a miniscript expression is well-typed. typeCheckMiniscript :: Map Text MiniscriptType -> Miniscript -> Either MiniscriptTypeError MiniscriptType data MiniscriptTypeError MiniscriptTypeError :: Miniscript -> MiniscriptTypeError UntypedVariable :: Text -> MiniscriptTypeError -- | fields: name expectedBaseType typeAnnotation WrongVariableType :: Text -> BaseType -> MiniscriptType -> MiniscriptTypeError -- | Type check and compile a miniscript compile :: Miniscript -> Either CompilerError Script -- | Compile a miniscript without type checking compileOnly :: Miniscript -> Either CompilerError Script data CompilerError FreeVariable :: Text -> CompilerError CompilerError :: Miniscript -> CompilerError TypeError :: MiniscriptTypeError -> CompilerError NotImplemented :: Miniscript -> CompilerError AbstractKey :: KeyDescriptor -> CompilerError miniscriptToText :: Network -> Miniscript -> Text miniscriptParser :: Network -> Parser Miniscript parseMiniscript :: Network -> Text -> Either String Miniscript -- | A library for working with bitcoin script descriptors. Documentation -- taken from -- https://github.com/bitcoin/bitcoin/blob/master/doc/descriptors.md. module Language.Bitcoin.Script.Descriptors -- | High level description for a bitcoin output data OutputDescriptor -- | The output is secured by the given script. ScriptPubKey :: ScriptDescriptor -> OutputDescriptor -- | P2SH embed the argument. P2SH :: ScriptDescriptor -> OutputDescriptor -- | P2WPKH output for the given compressed pubkey. P2WPKH :: KeyDescriptor -> OutputDescriptor -- | P2WSH embed the argument. P2WSH :: ScriptDescriptor -> OutputDescriptor -- | P2SH-P2WPKH the given compressed pubkey. WrappedWPkh :: KeyDescriptor -> OutputDescriptor -- | P2SH-P2WSH the given script WrappedWSh :: ScriptDescriptor -> OutputDescriptor -- | An alias for the collection of pk(KEY) and pkh(KEY). If the key is -- compressed, it also includes wpkh(KEY) and sh(wpkh(KEY)). Combo :: KeyDescriptor -> OutputDescriptor -- | The script which ADDR expands to. Addr :: Address -> OutputDescriptor -- | High level description of a bitcoin script data ScriptDescriptor -- | Require a signature for this key Pk :: KeyDescriptor -> ScriptDescriptor -- | Require a key matching this hash and a signature for that key Pkh :: KeyDescriptor -> ScriptDescriptor -- | k-of-n multisig script. Multi :: Int -> [KeyDescriptor] -> ScriptDescriptor -- | k-of-n multisig script with keys sorted lexicographically in the -- resulting script. SortedMulti :: Int -> [KeyDescriptor] -> ScriptDescriptor -- | the script whose hex encoding is HEX. Raw :: ByteString -> ScriptDescriptor data KeyDescriptor KeyDescriptor :: Maybe Origin -> Key -> KeyDescriptor [origin] :: KeyDescriptor -> Maybe Origin [keyDef] :: KeyDescriptor -> Key data Origin Origin :: Fingerprint -> DerivPath -> Origin [fingerprint] :: Origin -> Fingerprint [derivation] :: Origin -> DerivPath data Key -- | DER-hex encoded secp256k1 public key Pubkey :: PubKeyI -> Key -- | (de)serialized as WIF SecretKey :: SecKeyI -> Key XPub :: XPubKey -> DerivPath -> KeyCollection -> Key -- | Represent whether the key corresponds to a collection (and how) or a -- single key. data KeyCollection Single :: KeyCollection -- | immediate hardened children HardKeys :: KeyCollection -- | immediate non-hardened children SoftKeys :: KeyCollection -- | Test whether the key descriptor corresponds to a single key isDefinite :: KeyDescriptor -> Bool -- | For key families, get the key at the given index. Otherwise, return -- the input key. keyAtIndex :: Word32 -> Key -> Key -- | Produce a pubkey if possible keyDescPubKey :: KeyDescriptor -> Maybe PubKeyI -- | Simple explicit public key with no origin information pubKey :: PubKeyI -> KeyDescriptor -- | Simple explicit secret key with no origin information secKey :: SecKeyI -> KeyDescriptor -- | Produce a key literal if possible keyBytes :: KeyDescriptor -> Maybe ByteString descriptorToText :: Network -> OutputDescriptor -> Text keyDescriptorToText :: Network -> KeyDescriptor -> Text parseDescriptor :: Network -> Text -> Either String OutputDescriptor outputDescriptorParser :: Network -> Parser OutputDescriptor parseKeyDescriptor :: Network -> Text -> Either String KeyDescriptor keyDescriptorParser :: Network -> Parser KeyDescriptor -- | Get the set of addresses associated with an output descriptor. The -- list will be empty if: -- -- -- -- The list can contain more than one address in the case of the "combo" -- construct. descriptorAddresses :: OutputDescriptor -> [Address] -- | Produce the script described by the descriptor. Fails when any keys in -- the descriptor are indeterminate. compile :: ScriptDescriptor -> Maybe Script