Struct bitcoins::types::utxo::Utxo[][src]

pub struct Utxo {
    pub outpoint: BitcoinOutpoint,
    pub value: u64,
    pub script_pubkey: ScriptPubkey,
    // some fields omitted
}

Information necessary to spend an output.

Fields

outpoint: BitcoinOutpoint

UTXO outpoint

value: u64

UTXO value

script_pubkey: ScriptPubkey

The prevout script pubkey

Implementations

impl Utxo[src]

pub fn new(
    outpoint: BitcoinOutpoint,
    value: u64,
    script_pubkey: ScriptPubkey,
    spend_script: SpendScript
) -> Utxo
[src]

Instantiate a new UTXO with the given arguments. If spend_script is provided, but the script_pubkey does not require a spend script, the spend_script will be discarded.

pub fn from_tx_output<T>(tx: &T, idx: usize) -> Utxo where
    T: BitcoinTransaction
[src]

Produce a UTXO from a transaction output

pub fn from_output_and_outpoint(
    output: &TxOut,
    outpoint: &BitcoinOutpoint
) -> Utxo
[src]

Produce a UTXO from an output and the outpoint that identifies it

pub fn script_pubkey(&self) -> &ScriptPubkey[src]

Return a reference to the script pubkey

pub fn spend_script(&self) -> &SpendScript[src]

Return a reference to the spend script

pub fn signing_script(&self) -> Option<Script>[src]

Return the script that ought to be signed. This is the spend_script (redeem/witness script) if present, the script pubkey if legacy PKH, and the legacy PKH script if WPKH. .

pub fn standard_type(&self) -> ScriptType[src]

Inspect the Script to determine its type.

pub fn set_spend_script(&mut self, script: Script) -> bool[src]

Attempts to set the script. Returns true if succesful, false otherwise. Before setting, we check that the provided script’s hash matches the payload of the script pubkey. As such, this will always fail for UTXOs with PKH or WPKH script pubkeys.

pub fn sighash_args(
    &self,
    index: usize,
    flag: Sighash
) -> Option<LegacySighashArgs>
[src]

Construct LegacySighashArgs from this UTXO. Returns None if the prevout is WSH or SH and the witness or redeem script is Missing. It is safe to unwrap this Option if the signing script is PKH, or WPKH, or if the underlying witness or redeem script is Known.

pub fn witness_sighash_args(
    &self,
    index: usize,
    flag: Sighash
) -> Option<WitnessSighashArgs>
[src]

Construct WitnessSighashArgs from this UTXO. Returns None if the prevout is WSH or SH and the witness or redeem script is Missing. It is safe to unwrap this Option if the signing script is PKH, or WPKH, or if the underlying witness or redeem script is Known.

Trait Implementations

impl Clone for Utxo[src]

impl Debug for Utxo[src]

impl<'de> Deserialize<'de> for Utxo[src]

impl Eq for Utxo[src]

impl Hash for Utxo[src]

impl PartialEq<Utxo> for Utxo[src]

impl Serialize for Utxo[src]

impl StructuralEq for Utxo[src]

impl StructuralPartialEq for Utxo[src]

Auto Trait Implementations

impl RefUnwindSafe for Utxo

impl Send for Utxo

impl Sync for Utxo

impl Unpin for Utxo

impl UnwindSafe for Utxo

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Conv for T

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> FmtForward for T

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Pipe for T

impl<T> PipeAsRef for T

impl<T> PipeBorrow for T

impl<T> PipeDeref for T

impl<T> PipeRef for T

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> Tap for T

impl<T, U> TapAsRef<U> for T where
    U: ?Sized

impl<T, U> TapBorrow<U> for T where
    U: ?Sized

impl<T> TapDeref for T

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> TryConv for T

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.