TxBuilder

A TxBuilder is created by calling build_tx on a wallet. After assigning it, you set options on it until finally calling finish to consume the builder and generate the transaction.

Constructors

Link copied to clipboard
constructor(pointer: Pointer)
constructor(noPointer: NoPointer)

This constructor can be used to instantiate a fake object. Only used for tests. Any attempt to actually use an object constructed this way will fail as there is no connected Rust object.

constructor()

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
open override fun addData(data: ByteArray): TxBuilder

Add data as an output using OP_RETURN.

Link copied to clipboard
open override fun addGlobalXpubs(): TxBuilder

Fill-in the PSBT_GLOBAL_XPUB field with the extended keys contained in both the external and internal descriptors.

Link copied to clipboard
open override fun addRecipient(script: Script, amount: Amount): TxBuilder

Add a recipient to the internal list of recipients.

Link copied to clipboard
open override fun addUnspendable(unspendable: OutPoint): TxBuilder

Add a utxo to the internal list of unspendable utxos.

Link copied to clipboard
open override fun addUtxo(outpoint: OutPoint): TxBuilder

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

Link copied to clipboard
open override fun addUtxos(outpoints: List<OutPoint>): TxBuilder

Add the list of outpoints to the internal list of UTXOs that must be spent.

Link copied to clipboard
open override fun allowDust(allowDust: Boolean): TxBuilder

Set whether or not the dust limit is checked.

Link copied to clipboard
open override fun changePolicy(changePolicy: ChangeSpendPolicy): TxBuilder

Set a specific ChangeSpendPolicy. See TxBuilder::do_not_spend_change and TxBuilder::only_spend_change for some shortcuts. This method assumes the presence of an internal keychain, otherwise it has no effect.

Link copied to clipboard
open override fun close()
Link copied to clipboard
open override fun currentHeight(height: UInt): TxBuilder

Set the current blockchain height.

Link copied to clipboard
open override fun destroy()
Link copied to clipboard
open override fun doNotSpendChange(): TxBuilder

Do not spend change outputs.

Link copied to clipboard
open override fun drainTo(script: Script): TxBuilder

Sets the address to drain excess coins to.

Link copied to clipboard
open override fun drainWallet(): TxBuilder

Spend all the available inputs. This respects filters like TxBuilder::unspendable and the change policy.

Link copied to clipboard
open override fun feeAbsolute(feeAmount: Amount): TxBuilder

Set an absolute fee The fee_absolute method refers to the absolute transaction fee in Amount. If anyone sets both the fee_absolute method and the fee_rate method, the FeePolicy enum will be set by whichever method was called last, as the FeeRate and FeeAmount are mutually exclusive.

Link copied to clipboard
open override fun feeRate(feeRate: FeeRate): TxBuilder

Set a custom fee rate.

Link copied to clipboard
open override fun finish(wallet: Wallet): Psbt

Finish building the transaction.

Link copied to clipboard
open override fun manuallySelectedOnly(): TxBuilder

Only spend utxos added by TxBuilder::add_utxo.

Link copied to clipboard
open override fun nlocktime(locktime: LockTime): TxBuilder

Use a specific nLockTime while creating the transaction.

Link copied to clipboard
open override fun onlySpendChange(): TxBuilder

Only spend change outputs.

Link copied to clipboard
open override fun policyPath(policyPath: Map<String, List<ULong>>, keychain: KeychainKind): TxBuilder

The TxBuilder::policy_path is a complex API. See the Rust docs for complete information: https://docs.rs/bdk_wallet/latest/bdk_wallet/struct.TxBuilder.html#method.policy_path

Link copied to clipboard
open override fun setExactSequence(nsequence: UInt): TxBuilder

Set an exact nSequence value.

Link copied to clipboard
open override fun setRecipients(recipients: List<ScriptAmount>): TxBuilder

Replace the recipients already added with a new list of recipients.

Link copied to clipboard
fun uniffiClonePointer(): Pointer
Link copied to clipboard
open override fun unspendable(unspendable: List<OutPoint>): TxBuilder

Replace the internal list of unspendable utxos with a new list.

Link copied to clipboard
open override fun version(version: Int): TxBuilder

Build a transaction with a specific version.