pub struct Input { /* private fields */ }
Expand description
Information about a transparent spend within a transaction.
This struct is for representing transparent spends in a partially-created transaction.
If you have a fully-created transaction, use the regular TxIn
struct.
Implementations§
Source§impl Input
impl Input
Sourcepub fn parse(
prevout_txid: [u8; 32],
prevout_index: u32,
sequence: Option<u32>,
required_time_lock_time: Option<u32>,
required_height_lock_time: Option<u32>,
script_sig: Option<Vec<u8>>,
value: u64,
script_pubkey: Vec<u8>,
redeem_script: Option<Vec<u8>>,
partial_signatures: BTreeMap<[u8; 33], Vec<u8>>,
sighash_type: u8,
bip32_derivation: BTreeMap<[u8; 33], Bip32Derivation>,
ripemd160_preimages: BTreeMap<[u8; 20], Vec<u8>>,
sha256_preimages: BTreeMap<[u8; 32], Vec<u8>>,
hash160_preimages: BTreeMap<[u8; 20], Vec<u8>>,
hash256_preimages: BTreeMap<[u8; 32], Vec<u8>>,
proprietary: BTreeMap<String, Vec<u8>>,
) -> Result<Self, ParseError>
pub fn parse( prevout_txid: [u8; 32], prevout_index: u32, sequence: Option<u32>, required_time_lock_time: Option<u32>, required_height_lock_time: Option<u32>, script_sig: Option<Vec<u8>>, value: u64, script_pubkey: Vec<u8>, redeem_script: Option<Vec<u8>>, partial_signatures: BTreeMap<[u8; 33], Vec<u8>>, sighash_type: u8, bip32_derivation: BTreeMap<[u8; 33], Bip32Derivation>, ripemd160_preimages: BTreeMap<[u8; 20], Vec<u8>>, sha256_preimages: BTreeMap<[u8; 32], Vec<u8>>, hash160_preimages: BTreeMap<[u8; 20], Vec<u8>>, hash256_preimages: BTreeMap<[u8; 32], Vec<u8>>, proprietary: BTreeMap<String, Vec<u8>>, ) -> Result<Self, ParseError>
Parses a PCZT input from its component parts.
Source§impl Input
impl Input
Sourcepub fn verify(&self) -> Result<(), VerifyError>
pub fn verify(&self) -> Result<(), VerifyError>
Verifies the consistency of this transparent input.
If the redeem_script
field is set, its validity will be checked.
Source§impl Input
impl Input
Sourcepub fn sign<C: Signing, F>(
&mut self,
index: usize,
calculate_sighash: F,
sk: &SecretKey,
secp: &Secp256k1<C>,
) -> Result<(), SignerError>
pub fn sign<C: Signing, F>( &mut self, index: usize, calculate_sighash: F, sk: &SecretKey, secp: &Secp256k1<C>, ) -> Result<(), SignerError>
Signs the transparent spend with the given spend authorizing key.
It is the caller’s responsibility to perform any semantic validity checks on the PCZT (for example, comfirming that the change amounts are correct) before calling this method.
Source§impl Input
impl Input
Sourcepub fn prevout_txid(&self) -> &TxId
pub fn prevout_txid(&self) -> &TxId
The ID of the previous transaction containing the transparent coin being spent by this input.
Sourcepub fn prevout_index(&self) -> &u32
pub fn prevout_index(&self) -> &u32
The index of the entry in the vout
field of the previous transaction containing
the transparent coin being spent by this input.
Sourcepub fn sequence(&self) -> &Option<u32>
pub fn sequence(&self) -> &Option<u32>
The sequence number of this input.
- This is set by the Constructor.
- If omitted, the sequence number is assumed to be the final sequence number
(
0xffffffff
).
Sourcepub fn required_time_lock_time(&self) -> &Option<u32>
pub fn required_time_lock_time(&self) -> &Option<u32>
The minimum Unix timstamp that this input requires to be set as the transaction’s lock time.
- This is set by the Constructor.
- This must be greater than or equal to 500000000.
Sourcepub fn required_height_lock_time(&self) -> &Option<u32>
pub fn required_height_lock_time(&self) -> &Option<u32>
The minimum block height that this input requires to be set as the transaction’s lock time.
- This is set by the Constructor.
- This must be greater than 0 and less than 500000000.
Sourcepub fn script_sig(&self) -> &Option<Script>
pub fn script_sig(&self) -> &Option<Script>
A satisfying witness for the script_pubkey
of the input being spent.
This is set by the Spend Finalizer.
Sourcepub fn value(&self) -> &Zatoshis
pub fn value(&self) -> &Zatoshis
The value of the input being spent.
- This is set by the Constructor.
- This is required by the IO Finalizer and Transaction Extractor, to derive the shielded sighash needed for computing the binding signatures.
Sourcepub fn script_pubkey(&self) -> &Script
pub fn script_pubkey(&self) -> &Script
The script_pubkey
of the input being spent.
- This is set by the Constructor.
- This is required by the IO Finalizer and Transaction Extractor, to derive the shielded sighash needed for computing the binding signatures.
Sourcepub fn redeem_script(&self) -> &Option<Script>
pub fn redeem_script(&self) -> &Option<Script>
The script required to spend this output, if it is P2SH.
Set to None
if this is a P2PKH output.
Sourcepub fn partial_signatures(&self) -> &BTreeMap<[u8; 33], Vec<u8>>
pub fn partial_signatures(&self) -> &BTreeMap<[u8; 33], Vec<u8>>
A map from a pubkey to a signature created by it.
- Each pubkey should appear in
script_pubkey
orredeem_script
. - Each entry is set by a Signer, and should contain an ECDSA signature that is valid under the corresponding pubkey.
- These are required by the Spend Finalizer to assemble
script_sig
.
Sourcepub fn sighash_type(&self) -> &SighashType
pub fn sighash_type(&self) -> &SighashType
The sighash type to be used for this input.
- Signers must use this sighash type to produce their signatures. Signers that cannot produce signatures for this sighash type must not provide a signature.
- Spend Finalizers must fail to finalize inputs which have signatures that do not match this sighash type.
Sourcepub fn bip32_derivation(&self) -> &BTreeMap<[u8; 33], Bip32Derivation>
pub fn bip32_derivation(&self) -> &BTreeMap<[u8; 33], Bip32Derivation>
A map from a pubkey to the BIP 32 derivation path at which its corresponding spending key can be found.
- The pubkeys should appear in
script_pubkey
orredeem_script
. - Each entry is set by an Updater.
- Individual entries may be required by a Signer.
- It is not required that the map include entries for all of the used pubkeys. In particular, it is not possible to include entries for non-BIP-32 pubkeys.
Sourcepub fn ripemd160_preimages(&self) -> &BTreeMap<[u8; 20], Vec<u8>>
pub fn ripemd160_preimages(&self) -> &BTreeMap<[u8; 20], Vec<u8>>
Mappings of the form key = RIPEMD160(value)
.
- These may be used by the Signer to inspect parts of
script_pubkey
orredeem_script
.
Sourcepub fn sha256_preimages(&self) -> &BTreeMap<[u8; 32], Vec<u8>>
pub fn sha256_preimages(&self) -> &BTreeMap<[u8; 32], Vec<u8>>
Mappings of the form key = SHA256(value)
.
- These may be used by the Signer to inspect parts of
script_pubkey
orredeem_script
.
Sourcepub fn hash160_preimages(&self) -> &BTreeMap<[u8; 20], Vec<u8>>
pub fn hash160_preimages(&self) -> &BTreeMap<[u8; 20], Vec<u8>>
Mappings of the form key = RIPEMD160(SHA256(value))
.
- These may be used by the Signer to inspect parts of
script_pubkey
orredeem_script
.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Input
impl RefUnwindSafe for Input
impl Send for Input
impl Sync for Input
impl Unpin for Input
impl UnwindSafe for Input
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more