Copyright | No rights reserved |
---|---|
License | MIT |
Maintainer | [email protected] |
Stability | experimental |
Portability | POSIX |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Haskoin.Script.SigHash
Contents
Description
Transaction signatures and related functions.
Synopsis
- newtype SigHash = SigHash Word32
- data SigHashFlag
- sigHashAll :: SigHash
- sigHashNone :: SigHash
- sigHashSingle :: SigHash
- anyoneCanPay :: SigHash -> Bool
- hasForkIdFlag :: SigHash -> Bool
- setAnyoneCanPay :: SigHash -> SigHash
- setForkIdFlag :: SigHash -> SigHash
- isSigHashAll :: SigHash -> Bool
- isSigHashNone :: SigHash -> Bool
- isSigHashSingle :: SigHash -> Bool
- isSigHashUnknown :: SigHash -> Bool
- sigHashAddForkId :: SigHash -> Word32 -> SigHash
- sigHashGetForkId :: SigHash -> Word32
- sigHashAddNetworkId :: Network -> SigHash -> SigHash
- txSigHash :: Network -> Tx -> Script -> Word64 -> Int -> SigHash -> Hash256
- txSigHashForkId :: Network -> Tx -> Script -> Word64 -> Int -> SigHash -> Hash256
- data TxSignature
- = TxSignature { }
- | TxSignatureEmpty
- decodeTxSig :: Network -> Ctx -> ByteString -> Either String TxSignature
- encodeTxSig :: Network -> Ctx -> TxSignature -> ByteString
Script Signatures
Data type representing the different ways a transaction can be signed.
When producing a signature, a hash of the transaction is used as the message
to be signed. The SigHash
parameter controls which parts of the
transaction are used or ignored to produce the transaction hash. The idea is
that if some part of a transaction is not used to produce the transaction
hash, then you can change that part of the transaction after producing a
signature without invalidating that signature.
If the SIGHASH_ANYONECANPAY
flag is set (true), then only the current input
is signed. Otherwise, all of the inputs of a transaction are signed. The
default value for SIGHASH_ANYONECANPAY
is unset (false).
Instances
data SigHashFlag Source #
Constant representing a SIGHASH flag that controls what is being signed.
Constructors
SIGHASH_ALL | sign all outputs |
SIGHASH_NONE | sign no outputs |
SIGHASH_SINGLE | sign the output index corresponding to the input |
SIGHASH_FORKID | replay protection for Bitcoin Cash transactions |
SIGHASH_ANYONECANPAY | new inputs can be added |
Instances
sigHashAll :: SigHash Source #
SIGHASH_ALL as a byte.
sigHashNone :: SigHash Source #
SIGHASH_NONE as a byte.
sigHashSingle :: SigHash Source #
SIGHASH_SINGLE as a byte.
anyoneCanPay :: SigHash -> Bool Source #
Is the SIGHASH_ANYONECANPAY flag set?
hasForkIdFlag :: SigHash -> Bool Source #
Is the SIGHASH_FORKID flag set?
setAnyoneCanPay :: SigHash -> SigHash Source #
Set SIGHASH_ANYONECANPAY flag.
setForkIdFlag :: SigHash -> SigHash Source #
Set SIGHASH_FORKID flag.
isSigHashAll :: SigHash -> Bool Source #
Returns True
if the SigHash
has the value SIGHASH_ALL
.
isSigHashNone :: SigHash -> Bool Source #
Returns True
if the SigHash
has the value SIGHASH_NONE
.
isSigHashSingle :: SigHash -> Bool Source #
Returns True
if the SigHash
has the value SIGHASH_SINGLE
.
isSigHashUnknown :: SigHash -> Bool Source #
sigHashAddNetworkId :: Network -> SigHash -> SigHash Source #
Add fork id of a particular network to a SigHash
.
Arguments
:: Network | |
-> Tx | transaction to sign |
-> Script | script from output being spent |
-> Word64 | value of output being spent |
-> Int | index of input being signed |
-> SigHash | what to sign |
-> Hash256 | hash to be signed |
Computes the hash that will be used for signing a transaction.
Arguments
:: Network | |
-> Tx | transaction to sign |
-> Script | script from output being spent |
-> Word64 | value of output being spent |
-> Int | index of input being signed |
-> SigHash | what to sign |
-> Hash256 | hash to be signed |
Compute the hash that will be used for signing a transaction. This
function is used when the SIGHASH_FORKID
flag is set.
data TxSignature Source #
Data type representing a signature together with a SigHash
. The SigHash
is serialized as one byte at the end of an ECDSA Sig
. All signatures in
transaction inputs are of type TxSignature
.
Constructors
TxSignature | |
TxSignatureEmpty |
Instances
decodeTxSig :: Network -> Ctx -> ByteString -> Either String TxSignature Source #
encodeTxSig :: Network -> Ctx -> TxSignature -> ByteString Source #