anychain_bitcoin::transaction

Struct BitcoinTransactionInput

Source
pub struct BitcoinTransactionInput<N: BitcoinNetwork> {
Show 13 fields pub outpoint: Outpoint, pub balance: Option<BitcoinAmount>, pub address: Option<BitcoinAddress<N>>, pub format: Option<BitcoinFormat>, pub script_pub_key: Option<Vec<u8>>, pub redeem_script: Option<Vec<u8>>, pub script_sig: Vec<u8>, pub sequence: Vec<u8>, pub sighash_code: SignatureHash, pub witnesses: Vec<Vec<u8>>, pub is_signed: bool, pub additional_witness: Option<(Vec<u8>, bool)>, pub witness_script_data: Option<Vec<u8>>,
}
Expand description

Represents a Bitcoin transaction input

Fields§

§outpoint: Outpoint

The outpoint (36 bytes)

§balance: Option<BitcoinAmount>

The balance of the utxo pointed by this input (used for SegWit transaction signatures)

§address: Option<BitcoinAddress<N>>

The address of the utxo pointed by this input

§format: Option<BitcoinFormat>

The address format of the utxo pointed by this input

§script_pub_key: Option<Vec<u8>>

The ‘scriptPubkey’ of the utxo pointed by this input

§redeem_script: Option<Vec<u8>>

An optional redeem script in case of an SegWit utxo

§script_sig: Vec<u8>

The transaction input script (variable size)

§sequence: Vec<u8>

The sequence number (4 bytes) (0xFFFFFFFF unless lock > 0) Also used in replace-by-fee (BIP 125)

§sighash_code: SignatureHash

The signature hash (4 bytes) (used in signing raw transaction only)

§witnesses: Vec<Vec<u8>>

The witnesses in a SegWit transaction

§is_signed: bool

If true, the input has been signed

§additional_witness: Option<(Vec<u8>, bool)>

Provide more flexibility for multiple signatures (for P2WSH)

§witness_script_data: Option<Vec<u8>>

Option for additional witness stack script args

Implementations§

Source§

impl<N: BitcoinNetwork> BitcoinTransactionInput<N>

Source

pub fn new( transaction_id: Vec<u8>, index: u32, public_key: Option<BitcoinPublicKey<N>>, format: Option<BitcoinFormat>, address: Option<BitcoinAddress<N>>, balance: Option<BitcoinAmount>, sighash: SignatureHash, ) -> Result<Self, TransactionError>

Returns a new Bitcoin transaction input.

Source

pub fn set_public_key( &mut self, public_key: BitcoinPublicKey<N>, format: BitcoinFormat, ) -> Result<(), TransactionError>

Source

pub fn set_redeem_script( &mut self, redeem_script: Vec<u8>, ) -> Result<(), TransactionError>

Source

pub fn set_format( &mut self, format: BitcoinFormat, ) -> Result<(), TransactionError>

Source

pub fn set_balance(&mut self, balance: i64) -> Result<(), TransactionError>

Source

pub fn set_sequence(&mut self, sequence: u32) -> Result<(), TransactionError>

Source

pub fn set_sighash( &mut self, sighash: SignatureHash, ) -> Result<(), TransactionError>

Source

pub fn get_address(&self) -> Option<BitcoinAddress<N>>

Source

pub fn get_format(&self) -> Option<BitcoinFormat>

Source

pub fn get_balance(&self) -> Option<BitcoinAmount>

Source

pub fn get_sequence(&self) -> u32

Source

pub fn get_sighash(&self) -> SignatureHash

Source

pub fn read<R: Read>(reader: &mut R) -> Result<Self, TransactionError>

Read and output a Bitcoin transaction input

Source

pub fn serialize(&self, raw: bool) -> Result<Vec<u8>, TransactionError>

Returns the serialized transaction input.

Source

pub fn sign( &mut self, signature: Vec<u8>, public_key: Vec<u8>, ) -> Result<(), TransactionError>

Insert ‘signature’ and ‘public_key’ into this input to make it signed

Trait Implementations§

Source§

impl<N: Clone + BitcoinNetwork> Clone for BitcoinTransactionInput<N>

Source§

fn clone(&self) -> BitcoinTransactionInput<N>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<N: Debug + BitcoinNetwork> Debug for BitcoinTransactionInput<N>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<N: PartialEq + BitcoinNetwork> PartialEq for BitcoinTransactionInput<N>

Source§

fn eq(&self, other: &BitcoinTransactionInput<N>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<N: Eq + BitcoinNetwork> Eq for BitcoinTransactionInput<N>

Source§

impl<N: BitcoinNetwork> StructuralPartialEq for BitcoinTransactionInput<N>

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

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

Source§

fn vzip(self) -> V