Copyright | No rights reserved |
---|---|
License | MIT |
Maintainer | [email protected] |
Stability | experimental |
Portability | POSIX |
Safe Haskell | None |
Language | Haskell2010 |
Haskoin.Script.Standard
Description
Standard scripts like pay-to-public-key, pay-to-public-key-hash, pay-to-script-hash, pay-to-multisig and corresponding SegWit variants.
Synopsis
- data ScriptOutput
- = PayPK { }
- | PayPKHash { }
- | PayMulSig { }
- | PayScriptHash { }
- | PayWitnessPKHash { }
- | PayWitnessScriptHash { }
- | PayWitness {
- version :: !Word8
- bytes :: !ByteString
- | DataCarrier {
- bytes :: !ByteString
- type RedeemScript = ScriptOutput
- isPayPK :: ScriptOutput -> Bool
- isPayPKHash :: ScriptOutput -> Bool
- isPayMulSig :: ScriptOutput -> Bool
- isPayScriptHash :: ScriptOutput -> Bool
- isPayWitness :: ScriptOutput -> Bool
- isPayWitnessPKHash :: ScriptOutput -> Bool
- isPayWitnessScriptHash :: ScriptOutput -> Bool
- isDataCarrier :: ScriptOutput -> Bool
- encodeOutput :: Ctx -> ScriptOutput -> Script
- decodeOutput :: Ctx -> Script -> Either String ScriptOutput
- toP2SH :: Script -> ScriptOutput
- toP2WSH :: Script -> ScriptOutput
- sortMulSig :: Ctx -> ScriptOutput -> ScriptOutput
- data ScriptInput
- = RegularInput {
- get :: !SimpleInput
- | ScriptHashInput {
- get :: !SimpleInput
- redeem :: !RedeemScript
- = RegularInput {
- data SimpleInput
- = SpendPK {
- signature :: !TxSignature
- | SpendPKHash {
- signature :: !TxSignature
- key :: !PublicKey
- | SpendMulSig {
- signatures :: ![TxSignature]
- = SpendPK {
- encodeInput :: Network -> Ctx -> ScriptInput -> Script
- decodeInput :: Network -> Ctx -> Script -> Either String ScriptInput
- isSpendPK :: ScriptInput -> Bool
- isSpendPKHash :: ScriptInput -> Bool
- isSpendMulSig :: ScriptInput -> Bool
- isScriptHashInput :: ScriptInput -> Bool
Standard Script Outputs
data ScriptOutput Source #
Data type describing standard transaction output scripts. Output scripts provide the conditions that must be fulfilled for someone to spend the funds in a transaction output.
Constructors
PayPK | pay to public key |
PayPKHash | pay to public key hash |
PayMulSig | multisig |
PayScriptHash | pay to a script hash |
PayWitnessPKHash | pay to witness public key hash |
PayWitnessScriptHash | pay to witness script hash |
PayWitness | another pay to witness address |
Fields
| |
DataCarrier | provably unspendable data carrier |
Fields
|
Instances
type RedeemScript = ScriptOutput Source #
A redeem script is the output script serialized into the spending input script. It must be included in inputs that spend pay-to-script-hash outputs.
isPayPK :: ScriptOutput -> Bool Source #
Is script a pay-to-public-key output?
isPayPKHash :: ScriptOutput -> Bool Source #
Is script a pay-to-pub-key-hash output?
isPayMulSig :: ScriptOutput -> Bool Source #
Is script a pay-to-multi-sig output?
isPayScriptHash :: ScriptOutput -> Bool Source #
Is script a pay-to-script-hash output?
isPayWitness :: ScriptOutput -> Bool Source #
Is script paying to a different type of witness address?
isPayWitnessPKHash :: ScriptOutput -> Bool Source #
Is script a pay-to-witness-pub-key-hash output?
isPayWitnessScriptHash :: ScriptOutput -> Bool Source #
Is script a pay-to-witness-script-hash output?
isDataCarrier :: ScriptOutput -> Bool Source #
Is script a data carrier output?
encodeOutput :: Ctx -> ScriptOutput -> Script Source #
Computes a Script
from a standard ScriptOutput
.
decodeOutput :: Ctx -> Script -> Either String ScriptOutput Source #
Tries to decode a ScriptOutput
from a Script
. This can fail if the
script is not recognized as any of the standard output types.
toP2SH :: Script -> ScriptOutput Source #
Encode script as pay-to-script-hash script
toP2WSH :: Script -> ScriptOutput Source #
Encode script as a pay-to-witness-script-hash script
sortMulSig :: Ctx -> ScriptOutput -> ScriptOutput Source #
Sort the public keys of a multisig output in ascending order by comparing their compressed serialized representations. Refer to BIP-67.
Standard Script Inputs
data ScriptInput Source #
Standard input script high-level representation.
Constructors
RegularInput | |
Fields
| |
ScriptHashInput | |
Fields
|
Instances
NFData ScriptInput Source # | |||||
Defined in Haskoin.Script.Standard Methods rnf :: ScriptInput -> () # | |||||
Generic ScriptInput Source # | |||||
Defined in Haskoin.Script.Standard Associated Types
| |||||
Read ScriptInput Source # | |||||
Defined in Haskoin.Script.Standard Methods readsPrec :: Int -> ReadS ScriptInput # readList :: ReadS [ScriptInput] # readPrec :: ReadPrec ScriptInput # readListPrec :: ReadPrec [ScriptInput] # | |||||
Show ScriptInput Source # | |||||
Defined in Haskoin.Script.Standard Methods showsPrec :: Int -> ScriptInput -> ShowS # show :: ScriptInput -> String # showList :: [ScriptInput] -> ShowS # | |||||
Eq ScriptInput Source # | |||||
Defined in Haskoin.Script.Standard | |||||
Marshal (Network, Ctx) ScriptInput Source # | |||||
Defined in Haskoin.Script.Standard Methods marshalPut :: MonadPut m => (Network, Ctx) -> ScriptInput -> m () Source # marshalGet :: MonadGet m => (Network, Ctx) -> m ScriptInput Source # | |||||
type Rep ScriptInput Source # | |||||
Defined in Haskoin.Script.Standard type Rep ScriptInput = D1 ('MetaData "ScriptInput" "Haskoin.Script.Standard" "haskoin-core-1.2.2-KRZgNERiAmIGlbgBCYD6En" 'False) (C1 ('MetaCons "RegularInput" 'PrefixI 'True) (S1 ('MetaSel ('Just "get") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 SimpleInput)) :+: C1 ('MetaCons "ScriptHashInput" 'PrefixI 'True) (S1 ('MetaSel ('Just "get") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 SimpleInput) :*: S1 ('MetaSel ('Just "redeem") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 RedeemScript))) |
data SimpleInput Source #
Data type describing standard transaction input scripts. Input scripts provide the signing data required to unlock the coins of the output they are trying to spend, except in pay-to-witness-public-key-hash and pay-to-script-hash transactions.
Constructors
SpendPK | |
Fields
| |
SpendPKHash | |
Fields
| |
SpendMulSig | |
Fields
|
Instances
NFData SimpleInput Source # | |||||
Defined in Haskoin.Script.Standard Methods rnf :: SimpleInput -> () # | |||||
Generic SimpleInput Source # | |||||
Defined in Haskoin.Script.Standard Associated Types
| |||||
Read SimpleInput Source # | |||||
Defined in Haskoin.Script.Standard Methods readsPrec :: Int -> ReadS SimpleInput # readList :: ReadS [SimpleInput] # readPrec :: ReadPrec SimpleInput # readListPrec :: ReadPrec [SimpleInput] # | |||||
Show SimpleInput Source # | |||||
Defined in Haskoin.Script.Standard Methods showsPrec :: Int -> SimpleInput -> ShowS # show :: SimpleInput -> String # showList :: [SimpleInput] -> ShowS # | |||||
Eq SimpleInput Source # | |||||
Defined in Haskoin.Script.Standard | |||||
type Rep SimpleInput Source # | |||||
Defined in Haskoin.Script.Standard type Rep SimpleInput = D1 ('MetaData "SimpleInput" "Haskoin.Script.Standard" "haskoin-core-1.2.2-KRZgNERiAmIGlbgBCYD6En" 'False) (C1 ('MetaCons "SpendPK" 'PrefixI 'True) (S1 ('MetaSel ('Just "signature") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 TxSignature)) :+: (C1 ('MetaCons "SpendPKHash" 'PrefixI 'True) (S1 ('MetaSel ('Just "signature") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 TxSignature) :*: S1 ('MetaSel ('Just "key") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 PublicKey)) :+: C1 ('MetaCons "SpendMulSig" 'PrefixI 'True) (S1 ('MetaSel ('Just "signatures") 'NoSourceUnpackedness 'SourceStrict 'DecidedStrict) (Rec0 [TxSignature])))) |
encodeInput :: Network -> Ctx -> ScriptInput -> Script Source #
Encode a standard input into a script.
decodeInput :: Network -> Ctx -> Script -> Either String ScriptInput Source #
Heuristic to decode a ScriptInput
from a Script
. This function fails if
the script can not be parsed as a standard script input.
isSpendPK :: ScriptInput -> Bool Source #
Returns true if the input script is spending from a pay-to-public-key output.
isSpendPKHash :: ScriptInput -> Bool Source #
Returns true if the input script is spending from a pay-to-public-key-hash output.
isSpendMulSig :: ScriptInput -> Bool Source #
Returns true if the input script is spending a multisig output.
isScriptHashInput :: ScriptInput -> Bool Source #
Returns true if the input script is spending a pay-to-script-hash output.