Copyright | No rights reserved |
---|---|
License | MIT |
Maintainer | jprupp@protonmail.ch |
Stability | experimental |
Portability | POSIX |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
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.
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 |
| |
DataCarrier | provably unspendable data carrier |
|
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.
RegularInput | |
| |
ScriptHashInput | |
|
Instances
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.
SpendPK | |
| |
SpendPKHash | |
| |
SpendMulSig | |
|
Instances
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.