Struct revault_tx::transactions::SpendTransaction
source · [−]pub struct SpendTransaction(_);
Expand description
The transaction spending the unvaulting transaction, paying to one or multiple externally-controlled addresses, and possibly to a new deposit txo for the change.
Implementations
sourceimpl SpendTransaction
impl SpendTransaction
sourcepub fn new(
unvault_inputs: Vec<UnvaultTxIn>,
spend_txouts: Vec<SpendTxOut>,
change_txout: Option<DepositTxOut>,
cpfp_descriptor: &DerivedCpfpDescriptor,
lock_time: u32,
insane_fee_check: bool
) -> Result<SpendTransaction, TransactionCreationError>
pub fn new(
unvault_inputs: Vec<UnvaultTxIn>,
spend_txouts: Vec<SpendTxOut>,
change_txout: Option<DepositTxOut>,
cpfp_descriptor: &DerivedCpfpDescriptor,
lock_time: u32,
insane_fee_check: bool
) -> Result<SpendTransaction, TransactionCreationError>
A spend transaction can batch multiple unvault txouts, and may have any number of txouts (destination and change) in addition to the CPFP one..
The insane fees check is gated behind the insane_fee_checks
parameter as the caller
may want to create a transaction without a change output.
BIP174 Creator and Updater roles.
sourcepub fn cpfp_txout(
unvault_inputs: Vec<UnvaultTxIn>,
spend_txouts: Vec<SpendTxOut>,
change_txout: Option<DepositTxOut>,
cpfp_descriptor: &DerivedCpfpDescriptor,
lock_time: u32
) -> CpfpTxOut
pub fn cpfp_txout(
unvault_inputs: Vec<UnvaultTxIn>,
spend_txouts: Vec<SpendTxOut>,
change_txout: Option<DepositTxOut>,
cpfp_descriptor: &DerivedCpfpDescriptor,
lock_time: u32
) -> CpfpTxOut
Get the CPFP transaction output for a Spend transaction spending these unvault_inputs
and creating these spend_txouts
.
The CPFP output value is dependant on the transaction size, see practical-revaul t for more details.
sourcepub fn from_raw_psbt(
raw_psbt: &[u8]
) -> Result<Self, TransactionSerialisationError>
pub fn from_raw_psbt(
raw_psbt: &[u8]
) -> Result<Self, TransactionSerialisationError>
Parse a Spend transaction from a PSBT
Trait Implementations
sourceimpl Clone for SpendTransaction
impl Clone for SpendTransaction
sourcefn clone(&self) -> SpendTransaction
fn clone(&self) -> SpendTransaction
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl CpfpableTransaction for SpendTransaction
impl CpfpableTransaction for SpendTransaction
sourcefn max_weight(&self) -> u64
fn max_weight(&self) -> u64
Get the size of this transaction, assuming fully-satisfied inputs. If the transaction is already finalized, returns the exact size in witness units. Otherwise computes the maximum reasonable weight of a satisfaction. Read more
sourcefn cpfp_txin(
&self,
cpfp_descriptor: &CpfpDescriptor,
secp: &Secp256k1<impl Verification>
) -> Option<CpfpTxIn>
fn cpfp_txin(
&self,
cpfp_descriptor: &CpfpDescriptor,
secp: &Secp256k1<impl Verification>
) -> Option<CpfpTxIn>
Return the txin refering to the output to spend to CPFP this transaction, if any.
sourcefn max_feerate(&self) -> u64
fn max_feerate(&self) -> u64
Get the feerate of this transaction, assuming fully-satisfied inputs. If the transaction is already finalized, returns the exact feerate. Otherwise computes the maximum reasonable weight of a satisfaction and returns the feerate based on this estimation. Read more
sourceimpl Debug for SpendTransaction
impl Debug for SpendTransaction
sourceimpl Display for SpendTransaction
impl Display for SpendTransaction
sourceimpl FromStr for SpendTransaction
impl FromStr for SpendTransaction
sourceimpl PartialEq<SpendTransaction> for SpendTransaction
impl PartialEq<SpendTransaction> for SpendTransaction
sourcefn eq(&self, other: &SpendTransaction) -> bool
fn eq(&self, other: &SpendTransaction) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &SpendTransaction) -> bool
fn ne(&self, other: &SpendTransaction) -> bool
This method tests for !=
.
impl StructuralPartialEq for SpendTransaction
Auto Trait Implementations
impl RefUnwindSafe for SpendTransaction
impl Send for SpendTransaction
impl Sync for SpendTransaction
impl Unpin for SpendTransaction
impl UnwindSafe for SpendTransaction
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
sourceimpl<T> RevaultTransaction for T where
T: PrivateInnerMut + Debug + Clone + PartialEq<T>,
impl<T> RevaultTransaction for T where
T: PrivateInnerMut + Debug + Clone + PartialEq<T>,
sourcefn is_finalizable(&self, ctx: &Secp256k1<impl Verification>) -> bool
fn is_finalizable(&self, ctx: &Secp256k1<impl Verification>) -> bool
Check the transaction is valid (fully-signed) and can be finalized. Slighty more efficient than calling RevaultTransaction::finalize on a clone as it gets rid of the belt-and-suspenders checks.
sourcefn is_finalized(&self) -> bool
fn is_finalized(&self) -> bool
Check if the transaction was already finalized.
sourcefn verify_inputs(&self) -> Result<(), Error>
fn verify_inputs(&self) -> Result<(), Error>
Verify all PSBT inputs against libbitcoinconsensus
sourcefn into_bitcoin_serialized(self) -> Vec<u8, Global>
fn into_bitcoin_serialized(self) -> Vec<u8, Global>
Get the network-serialized (inner) transaction. You likely want to be sure the transaction [RevaultTransaction.is_finalized] before serializing it.
The BIP174 Transaction Extractor (without any check, which are done in [RevaultTransaction.finalize]).
sourcefn as_psbt_serialized(&self) -> Vec<u8, Global>
fn as_psbt_serialized(&self) -> Vec<u8, Global>
Get the BIP174-serialized (inner) transaction.
sourcefn as_psbt_string(&self) -> String
fn as_psbt_string(&self) -> String
Get the BIP174-serialized (inner) transaction encoded in base64.
sourcefn from_psbt_str(psbt_str: &str) -> Result<T, TransactionSerialisationError>
fn from_psbt_str(psbt_str: &str) -> Result<T, TransactionSerialisationError>
Create a RevaultTransaction from a base64-encoded BIP174-serialized transaction.
sourcefn from_psbt_serialized(
raw_psbt: &[u8]
) -> Result<T, TransactionSerialisationError>
fn from_psbt_serialized(
raw_psbt: &[u8]
) -> Result<T, TransactionSerialisationError>
Create a RevaultTransaction from a base64-encoded BIP174-serialized transaction.
sourcefn into_tx(self) -> Transaction
fn into_tx(self) -> Transaction
Extract the inner transaction of the inner PSBT. You likely want to be sure the transaction [RevaultTransaction.is_finalized] before serializing it.
The BIP174 Transaction Extractor (without any check, which are done in [RevaultTransaction.finalize]).
sourcefn signature_hash(
&self,
input_index: usize
) -> Result<SigHash, InputSatisfactionError>
fn signature_hash(
&self,
input_index: usize
) -> Result<SigHash, InputSatisfactionError>
Get the sighash for an input of a Revault transaction. Will deduce the scriptCode from the previous witness script. NOTE: transactions are always signed with the SIGHASH_ALL flag. Read more
sourcefn signature_hash_cached(
&self,
input_index: usize,
cache: &mut SigHashCache<&Transaction>
) -> Result<SigHash, InputSatisfactionError>
fn signature_hash_cached(
&self,
input_index: usize,
cache: &mut SigHashCache<&Transaction>
) -> Result<SigHash, InputSatisfactionError>
Cached version of RevaultTransaction::signature_hash
sourcefn add_signature<C>(
&mut self,
input_index: usize,
pubkey: PublicKey,
signature: Signature,
secp: &Secp256k1<C>
) -> Result<Option<Vec<u8, Global>>, InputSatisfactionError> where
C: Verification,
fn add_signature<C>(
&mut self,
input_index: usize,
pubkey: PublicKey,
signature: Signature,
secp: &Secp256k1<C>
) -> Result<Option<Vec<u8, Global>>, InputSatisfactionError> where
C: Verification,
Add a signature in order to eventually satisfy this input. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more