Struct Input

Source
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

Source

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

Source

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

Source

pub fn sign<C: Signing, F>( &mut self, index: usize, calculate_sighash: F, sk: &SecretKey, secp: &Secp256k1<C>, ) -> Result<(), SignerError>
where F: FnOnce(SignableInput<'_>) -> [u8; 32],

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

Source

pub fn prevout_txid(&self) -> &TxId

The ID of the previous transaction containing the transparent coin being spent by this input.

Source

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.

Source

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).
Source

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.
Source

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.
Source

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.

Source

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.
Source

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.
Source

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.

Source

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 or redeem_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.
Source

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.
Source

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 or redeem_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.
Source

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 or redeem_script.
Source

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 or redeem_script.
Source

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 or redeem_script.
Source

pub fn hash256_preimages(&self) -> &BTreeMap<[u8; 32], Vec<u8>>

Mappings of the form key = SHA256(SHA256(value)).

  • These may be used by the Signer to inspect parts of script_pubkey or redeem_script.
Source

pub fn proprietary(&self) -> &BTreeMap<String, Vec<u8>>

Proprietary fields related to the transparent coin being spent.

Trait Implementations§

Source§

impl Debug for Input

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V