pub struct Utxo {
pub outpoint: BitcoinOutpoint,
pub value: u64,
pub script_pubkey: ScriptPubkey,
/* private fields */
}
Expand description
Information necessary to spend an output.
Fields
outpoint: BitcoinOutpoint
UTXO outpoint
value: u64
UTXO value
script_pubkey: ScriptPubkey
The prevout script pubkey
Implementations
sourceimpl Utxo
impl Utxo
sourcepub fn new(
outpoint: BitcoinOutpoint,
value: u64,
script_pubkey: ScriptPubkey,
spend_script: SpendScript
) -> Utxo
pub fn new(
outpoint: BitcoinOutpoint,
value: u64,
script_pubkey: ScriptPubkey,
spend_script: SpendScript
) -> Utxo
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.
sourcepub fn from_tx_output<T>(tx: &T, idx: usize) -> Utxo where
T: BitcoinTransaction,
pub fn from_tx_output<T>(tx: &T, idx: usize) -> Utxo where
T: BitcoinTransaction,
Produce a UTXO from a transaction output
sourcepub fn from_output_and_outpoint(
output: &TxOut,
outpoint: &BitcoinOutpoint
) -> Utxo
pub fn from_output_and_outpoint(
output: &TxOut,
outpoint: &BitcoinOutpoint
) -> Utxo
Produce a UTXO from an output and the outpoint that identifies it
sourcepub fn script_pubkey(&self) -> &ScriptPubkey
pub fn script_pubkey(&self) -> &ScriptPubkey
Return a reference to the script pubkey
sourcepub fn spend_script(&self) -> &SpendScript
pub fn spend_script(&self) -> &SpendScript
Return a reference to the spend script
sourcepub fn signing_script(&self) -> Option<Script>
pub fn signing_script(&self) -> Option<Script>
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. .
sourcepub fn standard_type(&self) -> ScriptType
pub fn standard_type(&self) -> ScriptType
Inspect the Script
to determine its type.
sourcepub fn set_spend_script(&mut self, script: Script) -> bool
pub fn set_spend_script(&mut self, script: Script) -> bool
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.
sourcepub fn sighash_args(
&self,
index: usize,
flag: Sighash
) -> Option<LegacySighashArgs>
pub fn sighash_args(
&self,
index: usize,
flag: Sighash
) -> Option<LegacySighashArgs>
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
.
sourcepub fn witness_sighash_args(
&self,
index: usize,
flag: Sighash
) -> Option<WitnessSighashArgs>
pub fn witness_sighash_args(
&self,
index: usize,
flag: Sighash
) -> Option<WitnessSighashArgs>
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
sourceimpl<'de> Deserialize<'de> for Utxo
impl<'de> Deserialize<'de> for Utxo
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Utxo
impl StructuralEq for Utxo
impl StructuralPartialEq for Utxo
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more