pub trait InputTypeDetection {
Show 16 methods
// Required methods
fn get_type(&self) -> Result<InputType, InputError>;
fn has_witness(&self) -> bool;
fn is_scripthash_input(&self) -> Result<bool, InputError>;
fn is_p2ms(&self, strict_der_sig: bool) -> Result<bool, InputError>;
fn is_p2pk(&self, strict_der_sig: bool) -> Result<bool, InputError>;
fn is_p2pkh(&self, strict_der_sig: bool) -> Result<bool, InputError>;
fn is_p2sh(&self) -> Result<bool, InputError>;
fn is_nested_p2wpkh(&self) -> bool;
fn is_nested_p2wsh(&self) -> bool;
fn is_p2wpkh(&self) -> bool;
fn is_p2wsh(&self) -> bool;
fn is_p2trkp(&self) -> bool;
fn is_p2trsp(&self) -> bool;
fn is_p2a(&self) -> bool;
fn is_coinbase(&self) -> bool;
fn is_coinbase_witness(&self) -> bool;
}
Required Methods§
fn get_type(&self) -> Result<InputType, InputError>
fn has_witness(&self) -> bool
fn is_scripthash_input(&self) -> Result<bool, InputError>
fn is_p2ms(&self, strict_der_sig: bool) -> Result<bool, InputError>
fn is_p2pk(&self, strict_der_sig: bool) -> Result<bool, InputError>
fn is_p2pkh(&self, strict_der_sig: bool) -> Result<bool, InputError>
fn is_p2sh(&self) -> Result<bool, InputError>
fn is_nested_p2wpkh(&self) -> bool
fn is_nested_p2wsh(&self) -> bool
fn is_p2wpkh(&self) -> bool
fn is_p2wsh(&self) -> bool
fn is_p2trkp(&self) -> bool
fn is_p2trsp(&self) -> bool
fn is_p2a(&self) -> bool
fn is_coinbase(&self) -> bool
fn is_coinbase_witness(&self) -> bool
Implementations on Foreign Types§
Source§impl InputTypeDetection for TxIn
impl InputTypeDetection for TxIn
Source§fn has_witness(&self) -> bool
fn has_witness(&self) -> bool
Indicates if the witness contains data.
Source§fn is_scripthash_input(&self) -> Result<bool, InputError>
fn is_scripthash_input(&self) -> Result<bool, InputError>
Indicates if the input is script hash based.
Source§fn is_p2pk(&self, strict_der_sig: bool) -> Result<bool, InputError>
fn is_p2pk(&self, strict_der_sig: bool) -> Result<bool, InputError>
Checks if an input spends a P2PK output.
The caller can decide if the signature must be strictly DER encoded.
All transactions present in the blockchain after July 4th, 2015 have to
be strictly DER encoded as per [BIP-66]. Setting this to false
only
makes sense when working with historical data.
[BIP-66]: https://github.com/bitcoin/bips/blob/master/bip-0066.mediawiki).
A P2PK spend has only a signature in the script_sig and no witness.
script_sig: [ <ECDSA Signature> ]
witness: [ ]
§Errors
Returns a script::Error
if the script_sig can’t be parsed.
Source§fn is_p2ms(&self, strict_der_sig: bool) -> Result<bool, InputError>
fn is_p2ms(&self, strict_der_sig: bool) -> Result<bool, InputError>
Checks if an input spends an P2MS output.
The caller can decide if the signature must be strictly DER encoded.
All transactions present in the blockchain after July 4th, 2015 have to
be strictly DER encoded as per [BIP-66]. Setting this to false
only
makes sense when working with historical data.
[BIP-66]: https://github.com/bitcoin/bips/blob/master/bip-0066.mediawiki).
A P2MS spend has a OP_0 followed by one to three signatures in the script_sig.
It doesn’t have a witness.
script_sig: [ OP_0 <ECDSA Signature> (<ECDSA Signature>) (<ECDSA Signature>) ]
witness: [ ]
Source§fn is_p2pkh(&self, strict_der_sig: bool) -> Result<bool, InputError>
fn is_p2pkh(&self, strict_der_sig: bool) -> Result<bool, InputError>
Checks if an input spends a P2PKH output.
The caller can decide if the signature must be strictly DER encoded.
All transactions present in the blockchain after July 4th, 2015 have to
be strictly DER encoded as per [BIP-66]. Setting this to false
only
makes sense when working with historical data.
[BIP-66]: https://github.com/bitcoin/bips/blob/master/bip-0066.mediawiki).
A P2PKH spend has a public key and a signature in the script_sig. It
doesn’t have a witness.
script_sig: [ <ECDSA Signature> <PublicKey> ]
witness: [ ]
§Errors
Returns a script::Error
if the script_sig can’t be parsed.
Source§fn is_p2sh(&self) -> Result<bool, InputError>
fn is_p2sh(&self) -> Result<bool, InputError>
Checks if an input spends a P2SH output.
A P2SH output has at least an redeem script as last script_sig element.
We can test this by making sure The witness is empty.
script_sig: [ .. <redeem script> ]
witness: [ ]
§Errors
Returns a script::Error
if the script can’t be parsed.
Source§fn is_nested_p2wpkh(&self) -> bool
fn is_nested_p2wpkh(&self) -> bool
Checks if an input spends a Nested P2WPKH output.
A nested P2WPKH output has a OP_PUSHBYTES_22 in the script_sig. The
pushed data contains an OP_0 and an OP_PUSHBYTES_20 pushing a 20 byte
hash. The witness contains an ECDSA signature and a public key. The
signature must be strictly DER encoded.
script_sig: [ <OP_PUSHBYTES_22 [<OP_0 OP_PUSHBYTES_20 [20-byte hash]>]>]
witness: [ <ECDSA Signature> <PublicKey> ]
Source§fn is_nested_p2wsh(&self) -> bool
fn is_nested_p2wsh(&self) -> bool
Checks if an input spends a nested P2WSH output.
A nested P2WSH input has a single PUSH_BYTE_34 instruction which pushes
a nested script containing two instructions: a OP_0 and a PUSH_BYTES_32.
The witness contains at least the redeem script as last element.
script_sig: [ <OP_PUSH_BYTE_34> [OP_0 PUSH_BYTES_32 <32 byte hash>] ]
witness: [ .. <redeem script> ]
Returns a script::Error
if the script can’t be parsed.
Source§fn is_p2wpkh(&self) -> bool
fn is_p2wpkh(&self) -> bool
Checks if an input spends a P2WPKH output.
A P2WPKH output has an empty script_sig. The witness contains an ECDSA
signature and a public key. The signature must be strictly DER encoded.
script_sig: [ ]
witness: [ <ECDSA Signature> <PublicKey> ]
Source§fn is_p2wsh(&self) -> bool
fn is_p2wsh(&self) -> bool
Checks if an input spends a P2WSH output.
A P2WSH output has an empty script_sig. The data is contained in the witness.
script_sig: [ ]
witness: [ .. ]
Source§fn is_p2trkp(&self) -> bool
fn is_p2trkp(&self) -> bool
Checks if an input spends a P2TR-keypath output.
A P2TR output has an empty script_sig. The witness contains a Schnorr signature
and optionally an annex.
script_sig: [ ]
witness: [ <schnorr signature> (<annex>) ]
Source§fn is_p2trsp(&self) -> bool
fn is_p2trsp(&self) -> bool
Checks if an input spends a P2TR-scriptpath output.
A P2TR output has an empty script_sig. The witness script-input-data (zero-to-many),
a script, a control block, and optionally an annex.
script_sig: [ ]
witness: [ (<script input data>, <script input data>, ...) <script> <control block> (<annex>) ]
Source§fn is_p2a(&self) -> bool
fn is_p2a(&self) -> bool
Checks if an input spends a P2A output.
A P2A output has an empty script_sig and an empty witness.
Source§fn is_coinbase(&self) -> bool
fn is_coinbase(&self) -> bool
Checks if an input is a coinbase without witness data.
A coinbase has a an Outpoint with an all zero txid and an output index of 0xffffffff. The witness is empty.
Source§fn is_coinbase_witness(&self) -> bool
fn is_coinbase_witness(&self) -> bool
Checks if an input is a coinbase with witness data. On mainnet, this input type is expected after SegWit activation at height 481824 (24 August 2017).
A coinbase has a an Outpoint with an all zero txid and an output index of 0xffffffff. The witness is not empty.