[][src]Struct magical::wallet::tx_builder::TxBuilder

pub struct TxBuilder<Cs: CoinSelectionAlgorithm> { /* fields omitted */ }

A transaction builder

This structure contains the configuration that the wallet must follow to build a transaction.

For an example see this module's documentation;

Implementations

impl TxBuilder<DefaultCoinSelectionAlgorithm>[src]

pub fn new() -> Self[src]

Create an empty builder

pub fn with_recipients(recipients: Vec<(Script, u64)>) -> Self[src]

Create a builder starting from a list of recipients

impl<Cs: CoinSelectionAlgorithm> TxBuilder<Cs>[src]

pub fn set_recipients(self, recipients: Vec<(Script, u64)>) -> Self[src]

Replace the recipients already added with a new list

pub fn add_recipient(self, script_pubkey: Script, amount: u64) -> Self[src]

Add a recipient to the internal list

pub fn send_all(self) -> Self[src]

Send all the selected utxos to a single output

Adding more than one recipients with this option enabled will result in an error.

The value associated with the only recipient is irrelevant and will be replaced by the wallet.

pub fn fee_rate(self, fee_rate: FeeRate) -> Self[src]

Set a custom fee rate

pub fn policy_path(self, policy_path: BTreeMap<String, Vec<usize>>) -> Self[src]

Set the policy path to use while creating the transaction

This method accepts a map where the key is the policy node id (see Policy::id) and the value is the list of the indexes of the items that are intended to be satisfied from the policy node (see SatisfiableItem::Thresh::items).

pub fn utxos(self, utxos: Vec<OutPoint>) -> Self[src]

Replace the internal list of utxos that must be spent with a new list

These have priority over the "unspendable" utxos, meaning that if a utxo is present both in the "utxos" and the "unspendable" list, it will be spent.

pub fn add_utxo(self, utxo: OutPoint) -> Self[src]

Add a utxo to the internal list of utxos that must be spent

These have priority over the "unspendable" utxos, meaning that if a utxo is present both in the "utxos" and the "unspendable" list, it will be spent.

pub fn unspendable(self, unspendable: Vec<OutPoint>) -> Self[src]

Replace the internal list of unspendable utxos with a new list

It's important to note that the "must-be-spent" utxos added with TxBuilder::utxos and TxBuilder::add_utxo have priority over these. See the docs of the two linked methods for more details.

pub fn add_unspendable(self, unspendable: OutPoint) -> Self[src]

Add a utxo to the internal list of unspendable utxos

It's important to note that the "must-be-spent" utxos added with TxBuilder::utxos and TxBuilder::add_utxo have priority over this. See the docs of the two linked methods for more details.

pub fn sighash(self, sighash: SigHashType) -> Self[src]

Sign with a specific sig hash

Use this option very carefully

pub fn ordering(self, ordering: TxOrdering) -> Self[src]

Choose the ordering for inputs and outputs of the transaction

pub fn nlocktime(self, locktime: u32) -> Self[src]

Use a specific nLockTime while creating the transaction

This can cause conflicts if the wallet's descriptors contain an "after" (OP_CLTV) operator.

pub fn enable_rbf(self) -> Self[src]

Enable signaling RBF

This will use the default nSequence value of 0xFFFFFFFD.

pub fn enable_rbf_with_sequence(self, nsequence: u32) -> Self[src]

Enable signaling RBF with a specific nSequence value

This can cause conflicts if the wallet's descriptors contain an "older" (OP_CSV) operator and the given nsequence is lower than the CSV value.

If the nsequence is higher than 0xFFFFFFFD an error will be thrown, since it would not be a valid nSequence to signal RBF.

pub fn version(self, version: u32) -> Self[src]

Build a transaction with a specific version

The version should always be greater than 0 and greater than 1 if the wallet's descriptors contain an "older" (OP_CSV) operator.

pub fn do_not_spend_change(self) -> Self[src]

Do not spend change outputs

This effectively adds all the change outputs to the "unspendable" list. See TxBuilder::unspendable.

pub fn only_spend_change(self) -> Self[src]

Only spend change outputs

This effectively adds all the non-change outputs to the "unspendable" list. See TxBuilder::unspendable.

pub fn change_policy(self, change_policy: ChangeSpendPolicy) -> Self[src]

pub fn force_non_witness_utxo(self) -> Self[src]

Fill-in the psbt::Input::non_witness_utxo field even if the wallet only has SegWit descriptors.

This is useful for signers which always require it, like Trezor hardware wallets.

pub fn coin_selection<P: CoinSelectionAlgorithm>(
    self,
    coin_selection: P
) -> TxBuilder<P>
[src]

Choose the coin selection algorithm

Overrides the DefaultCoinSelectionAlgorithm.

Trait Implementations

impl<Cs: Debug + CoinSelectionAlgorithm> Debug for TxBuilder<Cs>[src]

impl<Cs: Default + CoinSelectionAlgorithm> Default for TxBuilder<Cs>[src]

Auto Trait Implementations

impl<Cs> RefUnwindSafe for TxBuilder<Cs> where
    Cs: RefUnwindSafe

impl<Cs> Send for TxBuilder<Cs> where
    Cs: Send

impl<Cs> Sync for TxBuilder<Cs> where
    Cs: Sync

impl<Cs> Unpin for TxBuilder<Cs> where
    Cs: Unpin

impl<Cs> UnwindSafe for TxBuilder<Cs> where
    Cs: UnwindSafe

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> From<T> for T[src]

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

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.

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