From: github-actions Date: Tue, 5 Jul 2022 20:37:34 +0000 (+0000) Subject: Publish autogenerated nightly docs X-Git-Url: http://internal-gitweb-vhost/script/%22https:/database/scripts/struct.Impossible.html?a=commitdiff_plain;h=d24de278be26718c3f5742d842a94b38533e2b9a;p=bitcoindevkit.org Publish autogenerated nightly docs --- diff --git a/docs/.vuepress/public/docs-rs/bdk/nightly/latest/bdk/database/memory/index.html b/docs/.vuepress/public/docs-rs/bdk/nightly/latest/bdk/database/memory/index.html index 730b32e429..817a2e8446 100644 --- a/docs/.vuepress/public/docs-rs/bdk/nightly/latest/bdk/database/memory/index.html +++ b/docs/.vuepress/public/docs-rs/bdk/nightly/latest/bdk/database/memory/index.html @@ -6,7 +6,7 @@ logo

Module memory

logo
-

Module bdk::database::memory

source · []
Expand description

In-memory ephemeral database

+

Module bdk::database::memory

source · []
Expand description

In-memory ephemeral database

This module defines an in-memory database type called MemoryDatabase that is based on a BTreeMap.

Structs

diff --git a/docs/.vuepress/public/docs-rs/bdk/nightly/latest/bdk/wallet/enum.AddressIndex.html b/docs/.vuepress/public/docs-rs/bdk/nightly/latest/bdk/wallet/enum.AddressIndex.html index 04550e050c..c4f7658917 100644 --- a/docs/.vuepress/public/docs-rs/bdk/nightly/latest/bdk/wallet/enum.AddressIndex.html +++ b/docs/.vuepress/public/docs-rs/bdk/nightly/latest/bdk/wallet/enum.AddressIndex.html @@ -6,7 +6,7 @@ logo

AddressIndex

logo
pub enum AddressIndex {
+    

Enum bdk::wallet::AddressIndex

source · []
pub enum AddressIndex {
     New,
     LastUnused,
     Peek(u32),
@@ -31,7 +31,7 @@ then the returned address and subsequent addresses returned by calls to Ad
 and AddressIndex::LastUsed may have already been used. Also if the index is reset to a
 value earlier than the crate::blockchain::Blockchain stop_gap (default is 20) then a
 larger stop_gap should be used to monitor for all possibly used addresses.

-

Trait Implementations

Formats the value using the given formatter. Read more

+

Trait Implementations

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

diff --git a/docs/.vuepress/public/docs-rs/bdk/nightly/latest/bdk/wallet/fn.get_funded_wallet.html b/docs/.vuepress/public/docs-rs/bdk/nightly/latest/bdk/wallet/fn.get_funded_wallet.html index e778581ad1..3f9d1e9799 100644 --- a/docs/.vuepress/public/docs-rs/bdk/nightly/latest/bdk/wallet/fn.get_funded_wallet.html +++ b/docs/.vuepress/public/docs-rs/bdk/nightly/latest/bdk/wallet/fn.get_funded_wallet.html @@ -6,6 +6,6 @@ logo
logo
pub fn get_funded_wallet(
    descriptor: &str
) -> (Wallet<AnyDatabase>, (String, Option<String>), Txid)
Expand description

Return a fake wallet that appears to be funded for testing.

+

Function bdk::wallet::get_funded_wallet

source · []
pub fn get_funded_wallet(
    descriptor: &str
) -> (Wallet<AnyDatabase>, (String, Option<String>), Txid)
Expand description

Return a fake wallet that appears to be funded for testing.

\ No newline at end of file diff --git a/docs/.vuepress/public/docs-rs/bdk/nightly/latest/bdk/wallet/fn.wallet_name_from_descriptor.html b/docs/.vuepress/public/docs-rs/bdk/nightly/latest/bdk/wallet/fn.wallet_name_from_descriptor.html index 4f5ce8d61c..6580a58edc 100644 --- a/docs/.vuepress/public/docs-rs/bdk/nightly/latest/bdk/wallet/fn.wallet_name_from_descriptor.html +++ b/docs/.vuepress/public/docs-rs/bdk/nightly/latest/bdk/wallet/fn.wallet_name_from_descriptor.html @@ -6,7 +6,7 @@ logo
logo
pub fn wallet_name_from_descriptor<T>(
    descriptor: T,
    change_descriptor: Option<T>,
    network: Network,
    secp: &Secp256k1<All>
) -> Result<String, Error> where
    T: IntoWalletDescriptor
Expand description

Deterministically generate a unique name given the descriptors defining the wallet

+

Function bdk::wallet::wallet_name_from_descriptor

source · []
pub fn wallet_name_from_descriptor<T>(
    descriptor: T,
    change_descriptor: Option<T>,
    network: Network,
    secp: &Secp256k1<All>
) -> Result<String, Error> where
    T: IntoWalletDescriptor
Expand description

Deterministically generate a unique name given the descriptors defining the wallet

Compatible with wallet_name_from_descriptor

\ No newline at end of file diff --git a/docs/.vuepress/public/docs-rs/bdk/nightly/latest/bdk/wallet/index.html b/docs/.vuepress/public/docs-rs/bdk/nightly/latest/bdk/wallet/index.html index 8f94797ee7..4e95a97936 100644 --- a/docs/.vuepress/public/docs-rs/bdk/nightly/latest/bdk/wallet/index.html +++ b/docs/.vuepress/public/docs-rs/bdk/nightly/latest/bdk/wallet/index.html @@ -6,7 +6,7 @@ logo

Module wallet

logo
-

Module bdk::wallet

source · []
Expand description

Wallet

+

Module bdk::wallet

source · []
Expand description

Wallet

This module defines the Wallet structure.

Modules

Address validation callbacks

diff --git a/docs/.vuepress/public/docs-rs/bdk/nightly/latest/bdk/wallet/struct.AddressInfo.html b/docs/.vuepress/public/docs-rs/bdk/nightly/latest/bdk/wallet/struct.AddressInfo.html index ed9bde40ff..ced51e4b4c 100644 --- a/docs/.vuepress/public/docs-rs/bdk/nightly/latest/bdk/wallet/struct.AddressInfo.html +++ b/docs/.vuepress/public/docs-rs/bdk/nightly/latest/bdk/wallet/struct.AddressInfo.html @@ -6,7 +6,7 @@ logo

AddressInfo

logo
pub struct AddressInfo {
+    

Struct bdk::wallet::AddressInfo

source · []
pub struct AddressInfo {
     pub index: u32,
     pub address: Address,
     pub keychain: KeychainKind,
@@ -52,14 +52,14 @@ given key. For taproot addresses, the supplied key is assumed to be tweaked

Returns true if the supplied xonly public key can be used to derive the address.

This will only work for Taproot addresses. The Public Key is assumed to have already been tweaked.

-

Trait Implementations

Formats the value using the given formatter. Read more

-

The resulting type after dereferencing.

-

Dereferences the value.

-

Formats the value using the given formatter. Read more

-

This method tests for self and other values to be equal, and is used +

Trait Implementations

Formats the value using the given formatter. Read more

+

The resulting type after dereferencing.

+

Dereferences the value.

+

Formats the value using the given formatter. Read more

+

This method tests for self and other values to be equal, and is used by ==. Read more

-

This method tests for !=.

-

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

+

This method tests for !=.

+

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

diff --git a/docs/.vuepress/public/docs-rs/bdk/nightly/latest/bdk/wallet/struct.SyncOptions.html b/docs/.vuepress/public/docs-rs/bdk/nightly/latest/bdk/wallet/struct.SyncOptions.html index 7ff3c104a9..89e85eec52 100644 --- a/docs/.vuepress/public/docs-rs/bdk/nightly/latest/bdk/wallet/struct.SyncOptions.html +++ b/docs/.vuepress/public/docs-rs/bdk/nightly/latest/bdk/wallet/struct.SyncOptions.html @@ -6,12 +6,12 @@ logo

SyncOptions

logo
pub struct SyncOptions {
+    

Struct bdk::wallet::SyncOptions

source · []
pub struct SyncOptions {
     pub progress: Option<Box<dyn Progress>>,
 }
Expand description

Options to a sync.

Fields

progress: Option<Box<dyn Progress>>

The progress tracker which may be informed when progress is made.

-

Trait Implementations

Formats the value using the given formatter. Read more

-

Returns the “default value” for a type. Read more

+

Trait Implementations

Formats the value using the given formatter. Read more

+

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

diff --git a/docs/.vuepress/public/docs-rs/bdk/nightly/latest/bdk/wallet/struct.Wallet.html b/docs/.vuepress/public/docs-rs/bdk/nightly/latest/bdk/wallet/struct.Wallet.html index 5298dec9d9..3be7f893bb 100644 --- a/docs/.vuepress/public/docs-rs/bdk/nightly/latest/bdk/wallet/struct.Wallet.html +++ b/docs/.vuepress/public/docs-rs/bdk/nightly/latest/bdk/wallet/struct.Wallet.html @@ -6,7 +6,7 @@ logo

Wallet

logo
-

Struct bdk::wallet::Wallet

source · []
pub struct Wallet<D> { /* private fields */ }
Expand description

A Bitcoin wallet

+

Struct bdk::wallet::Wallet

source · []
pub struct Wallet<D> { /* private fields */ }
Expand description

A Bitcoin wallet

The Wallet struct acts as a way of coherently interfacing with output descriptors and related transactions. Its main components are:

    @@ -14,47 +14,47 @@ Its main components are:

  1. A Database where it tracks transactions and utxos related to the descriptors.
  2. signers that can contribute signatures to addresses instantiated from the descriptors.
-

Implementations

👎 Deprecated:

Just use Wallet::new – all wallets are offline now!

+

Implementations

👎 Deprecated:

Just use Wallet::new – all wallets are offline now!

Create a new “offline” wallet

-

Create a wallet.

+

Create a wallet.

The only way this can fail is if the descriptors passed in do not match the checksums in database.

-

Get the Bitcoin network the wallet is using.

-

Return a derived address using the external descriptor, see AddressIndex for +

Get the Bitcoin network the wallet is using.

+

Return a derived address using the external descriptor, see AddressIndex for available address index selection strategies. If none of the keys in the descriptor are derivable (ie. does not end with /*) then the same address will always be returned for any AddressIndex.

-

Return a derived address using the internal (change) descriptor.

+

Return a derived address using the internal (change) descriptor.

If the wallet doesn’t have an internal descriptor it will use the external descriptor.

see AddressIndex for available address index selection strategies. If none of the keys in the descriptor are derivable (ie. does not end with /*) then the same address will always be returned for any AddressIndex.

-

Ensures that there are at least max_addresses addresses cached in the database if the +

Ensures that there are at least max_addresses addresses cached in the database if the descriptor is derivable, or 1 address if it is not. Will return Ok(true) if there are new addresses generated (either external or internal), and Ok(false) if all the required addresses are already cached. This function is useful to explicitly cache addresses in a wallet to do things like check Wallet::is_mine on transaction output scripts.

-

Return whether or not a script is part of this wallet (either internal or external)

-

Return the list of unspent outputs of this wallet

+

Return whether or not a script is part of this wallet (either internal or external)

+

Return the list of unspent outputs of this wallet

Note that this method only operates on the internal database, which first needs to be Wallet::sync manually.

-

Returns the UTXO owned by this wallet corresponding to outpoint if it exists in the +

Returns the UTXO owned by this wallet corresponding to outpoint if it exists in the wallet’s database.

-

Return a single transactions made and received by the wallet

+

Return a single transactions made and received by the wallet

Optionally fill the TransactionDetails::transaction field with the raw transaction if include_raw is true.

Note that this method only operates on the internal database, which first needs to be Wallet::sync manually.

-

Return the list of transactions made and received by the wallet

+

Return the list of transactions made and received by the wallet

Optionally fill the TransactionDetails::transaction field with the raw transaction if include_raw is true.

Note that this methods only operate on the internal database, which first needs to be Wallet::sync manually.

-

Return the balance, meaning the sum of this wallet’s unspent outputs’ values

+

Return the balance, meaning the sum of this wallet’s unspent outputs’ values

Note that this methods only operate on the internal database, which first needs to be Wallet::sync manually.

-

Add an external signer

+

Add an external signer

See the signer module for an example.

-

Get the signers

+

Get the signers

Example
let wallet = Wallet::new("wpkh(tprv8ZgxMBicQKsPe73PBRSmNbTfbcsZnwWhz5eVmhHpi31HW29Z7mc9B4cWGRQzopNUzZUT391DeDJxL2PefNunWyLgqCKRMDkU1s2s8bAfoSk/84'/0'/0'/0/*)", None, Network::Testnet, MemoryDatabase::new())?;
 for secret_key in wallet.get_signers(KeychainKind::External).signers().iter().filter_map(|s| s.descriptor_secret_key()) {
@@ -63,10 +63,10 @@ wallet’s database.

} Ok::<(), Box<dyn std::error::Error>>(())
-

Add an address validator

+

Add an address validator

See the address_validator module for an example.

-

Get the address validators

-

Start building a transaction.

+

Get the address validators

+

Start building a transaction.

This returns a blank TxBuilder from which you can specify the parameters for the transaction.

Example
let (psbt, details) = {
@@ -77,7 +77,7 @@ wallet’s database.

}; // sign and broadcast ...
-

Bump the fee of a transaction previously created with this wallet.

+

Bump the fee of a transaction previously created with this wallet.

Returns an error if the transaction is already confirmed or doesn’t explicitly signal replace by fee (RBF). If the transaction can be fee bumped then it returns a TxBuilder pre-populated with the inputs and outputs of the original transaction.

@@ -102,7 +102,7 @@ pre-populated with the inputs and outputs of the original transaction.

let _ = wallet.sign(&mut psbt, SignOptions::default())?; let fee_bumped_tx = psbt.extract_tx(); // broadcast fee_bumped_tx to replace original
-

Sign a transaction with all the wallet’s signers, in the order specified by every signer’s +

Sign a transaction with all the wallet’s signers, in the order specified by every signer’s SignerOrdering

The SignOptions can be used to tweak the behavior of the software signers, and the way the transaction is finalized at the end. Note that it can’t be guaranteed that every @@ -116,20 +116,20 @@ in this library will.

}; let finalized = wallet.sign(&mut psbt, SignOptions::default())?; assert!(finalized, "we should have signed all the inputs");
-

Return the spending policies for the wallet’s descriptor

-

Return the “public” version of the wallet’s descriptor, meaning a new descriptor that has +

Return the spending policies for the wallet’s descriptor

+

Return the “public” version of the wallet’s descriptor, meaning a new descriptor that has the same structure but with every secret key removed

This can be used to build a watch-only version of a wallet

-

Try to finalize a PSBT

+

Try to finalize a PSBT

The SignOptions can be used to tweak the behavior of the finalizer.

-

Return the secp256k1 context used for all signing operations

-

Returns the descriptor used to create addresses for a particular keychain.

-

get the corresponding PSBT Input for a LocalUtxo

-

Return an immutable reference to the internal database

-

Sync the internal database with the blockchain

-

Return the checksum of the public descriptor associated to keychain

+

Return the secp256k1 context used for all signing operations

+

Returns the descriptor used to create addresses for a particular keychain.

+

get the corresponding PSBT Input for a LocalUtxo

+

Return an immutable reference to the internal database

+

Sync the internal database with the blockchain

+

Return the checksum of the public descriptor associated to keychain

Internally calls Self::get_descriptor_for_keychain to fetch the right descriptor

-

Trait Implementations

Formats the value using the given formatter. Read more

+

Trait Implementations

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

diff --git a/docs/.vuepress/public/docs-rs/bdk/nightly/latest/bdk/wallet/tx_builder/enum.ChangeSpendPolicy.html b/docs/.vuepress/public/docs-rs/bdk/nightly/latest/bdk/wallet/tx_builder/enum.ChangeSpendPolicy.html index f9c3e48175..06973400c6 100644 --- a/docs/.vuepress/public/docs-rs/bdk/nightly/latest/bdk/wallet/tx_builder/enum.ChangeSpendPolicy.html +++ b/docs/.vuepress/public/docs-rs/bdk/nightly/latest/bdk/wallet/tx_builder/enum.ChangeSpendPolicy.html @@ -6,7 +6,7 @@ logo

ChangeSpendPolicy

logo
pub enum ChangeSpendPolicy {
+    

Enum bdk::wallet::tx_builder::ChangeSpendPolicy

source · []
pub enum ChangeSpendPolicy {
     ChangeAllowed,
     OnlyChange,
     ChangeForbidden,
@@ -14,27 +14,27 @@
 

Variants

ChangeAllowed

Use both change and non-change outputs (default)

OnlyChange

Only use change outputs (see TxBuilder::only_spend_change)

ChangeForbidden

Only use non-change outputs (see TxBuilder::do_not_spend_change)

-

Trait Implementations

Returns a copy of the value. Read more

+

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

-

Formats the value using the given formatter. Read more

-

Returns the “default value” for a type. Read more

-

Feeds this value into the given Hasher. Read more

+

Formats the value using the given formatter. Read more

+

Returns the “default value” for a type. Read more

+

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

-

This method returns an Ordering between self and other. Read more

+

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

-

This method tests for self and other values to be equal, and is used +

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

-

This method returns an ordering between self and other values if one exists. Read more

+

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

-

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

+

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

diff --git a/docs/.vuepress/public/docs-rs/bdk/nightly/latest/bdk/wallet/tx_builder/enum.TxOrdering.html b/docs/.vuepress/public/docs-rs/bdk/nightly/latest/bdk/wallet/tx_builder/enum.TxOrdering.html index 009688e069..15ab89acf2 100644 --- a/docs/.vuepress/public/docs-rs/bdk/nightly/latest/bdk/wallet/tx_builder/enum.TxOrdering.html +++ b/docs/.vuepress/public/docs-rs/bdk/nightly/latest/bdk/wallet/tx_builder/enum.TxOrdering.html @@ -6,7 +6,7 @@ logo

TxOrdering

logo
pub enum TxOrdering {
+    

Enum bdk::wallet::tx_builder::TxOrdering

source · []
pub enum TxOrdering {
     Shuffle,
     Untouched,
     Bip69Lexicographic,
@@ -14,28 +14,28 @@
 

Variants

Shuffle

Randomized (default)

Untouched

Unchanged

Bip69Lexicographic

BIP69 / Lexicographic

-

Implementations

Sort transaction inputs and outputs by TxOrdering variant

-

Trait Implementations

Returns a copy of the value. Read more

+

Implementations

Sort transaction inputs and outputs by TxOrdering variant

+

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

-

Formats the value using the given formatter. Read more

-

Returns the “default value” for a type. Read more

-

Feeds this value into the given Hasher. Read more

+

Formats the value using the given formatter. Read more

+

Returns the “default value” for a type. Read more

+

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

-

This method returns an Ordering between self and other. Read more

+

This method returns an Ordering between self and other. Read more

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

-

This method tests for self and other values to be equal, and is used +

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

-

This method returns an ordering between self and other values if one exists. Read more

+

This method returns an ordering between self and other values if one exists. Read more

This method tests less than (for self and other) and is used by the < operator. Read more

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

This method tests greater than (for self and other) and is used by the > operator. Read more

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

-

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

+

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

diff --git a/docs/.vuepress/public/docs-rs/bdk/nightly/latest/bdk/wallet/tx_builder/index.html b/docs/.vuepress/public/docs-rs/bdk/nightly/latest/bdk/wallet/tx_builder/index.html index b465fd7963..704879ed29 100644 --- a/docs/.vuepress/public/docs-rs/bdk/nightly/latest/bdk/wallet/tx_builder/index.html +++ b/docs/.vuepress/public/docs-rs/bdk/nightly/latest/bdk/wallet/tx_builder/index.html @@ -6,7 +6,7 @@ logo

Module tx_builder

logo
-

Module bdk::wallet::tx_builder

source · []
Expand description

Transaction builder

+

Module bdk::wallet::tx_builder

source · []
Expand description

Transaction builder

Example

// create a TxBuilder from a wallet
 let mut tx_builder = wallet.build_tx();
diff --git a/docs/.vuepress/public/docs-rs/bdk/nightly/latest/bdk/wallet/tx_builder/struct.TxBuilder.html b/docs/.vuepress/public/docs-rs/bdk/nightly/latest/bdk/wallet/tx_builder/struct.TxBuilder.html
index ae39e6a80b..f0990fd8cc 100644
--- a/docs/.vuepress/public/docs-rs/bdk/nightly/latest/bdk/wallet/tx_builder/struct.TxBuilder.html
+++ b/docs/.vuepress/public/docs-rs/bdk/nightly/latest/bdk/wallet/tx_builder/struct.TxBuilder.html
@@ -37,7 +37,7 @@ as in the following example:

At the moment coin_selection is an exception to the rule as it consumes self. This means it is usually best to call coin_selection on the return value of build_tx before assigning it.

For further examples see this module’s documentation;

-

Implementations

Set a custom fee rate

+

Implementations

Set a custom fee rate

Set an absolute fee

Set the policy path to use while creating the transaction for a given keychain.

This method accepts a map where the key is the policy node id (see @@ -171,14 +171,21 @@ BitBox and ColdCard are known to require this.

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.

-

Set the current blockchain height.

-

This will be used to set the nLockTime for preventing fee sniping. If the current height is -not provided, the last sync height will be used instead.

-

Note: This will be ignored if you manually specify a nlocktime using TxBuilder::nlocktime.

-

Replace the recipients already added with a new list

-

Add a recipient to the internal list

-

Add data as an output, using OP_RETURN

-

Sets the address to drain excess coins to.

+

Set the current blockchain height.

+

This will be used to:

+
    +
  1. Set the nLockTime for preventing fee sniping. +Note: This will be ignored if you manually specify a nlocktime using TxBuilder::nlocktime.
  2. +
  3. Decide whether coinbase outputs are mature or not. If the coinbase outputs are not +mature at current_height, we ignore them in the coin selection. +If you want to create a transaction that spends immature coinbase inputs, manually +add them using TxBuilder::add_utxos.
  4. +
+

In both cases, if you don’t provide a current height, we use the last sync height.

+

Replace the recipients already added with a new list

+

Add a recipient to the internal list

+

Add data as an output, using OP_RETURN

+

Sets the address to drain excess coins to.

Usually, when there are excess coins they are sent to a change address generated by the wallet. This option replaces the usual change address with an arbitrary script_pubkey of your choosing. Just as with a change output, if the drain output is not needed (the excess @@ -203,7 +210,7 @@ single address.

.fee_rate(FeeRate::from_sat_per_vb(5.0)) .enable_rbf(); let (psbt, tx_details) = tx_builder.finish()?;
-

Explicitly tells the wallet that it is allowed to reduce the amount of the output matching this +

Explicitly tells the wallet that it is allowed to reduce the amount of the output matching this script_pubkey in order to bump the transaction fee. Without specifying this the wallet will attempt to find a change output to shrink instead.

Note that the output may shrink to below the dust limit and therefore be removed. If it is diff --git a/docs/.vuepress/public/docs-rs/bdk/nightly/latest/src/bdk/database/memory.rs.html b/docs/.vuepress/public/docs-rs/bdk/nightly/latest/src/bdk/database/memory.rs.html index b099511bbb..6eff42dbe7 100644 --- a/docs/.vuepress/public/docs-rs/bdk/nightly/latest/src/bdk/database/memory.rs.html +++ b/docs/.vuepress/public/docs-rs/bdk/nightly/latest/src/bdk/database/memory.rs.html @@ -626,6 +626,14 @@ 619 620 621 +622 +623 +624 +625 +626 +627 +628 +629

// Bitcoin Dev Kit
 // Written in 2020 by Alekos Filini <alekos.filini@gmail.com>
 //
@@ -1110,15 +1118,23 @@
 /// don't have `test` set.
 macro_rules! populate_test_db {
     ($db:expr, $tx_meta:expr, $current_height:expr$(,)?) => {{
+        $crate::populate_test_db!($db, $tx_meta, $current_height, (@coinbase false))
+    }};
+    ($db:expr, $tx_meta:expr, $current_height:expr, (@coinbase $is_coinbase:expr)$(,)?) => {{
         use std::str::FromStr;
         use $crate::database::BatchOperations;
         let mut db = $db;
         let tx_meta = $tx_meta;
         let current_height: Option<u32> = $current_height;
+        let input = if $is_coinbase {
+            vec![$crate::bitcoin::TxIn::default()]
+        } else {
+            vec![]
+        };
         let tx = $crate::bitcoin::Transaction {
             version: 1,
             lock_time: 0,
-            input: vec![],
+            input,
             output: tx_meta
                 .output
                 .iter()
diff --git a/docs/.vuepress/public/docs-rs/bdk/nightly/latest/src/bdk/wallet/mod.rs.html b/docs/.vuepress/public/docs-rs/bdk/nightly/latest/src/bdk/wallet/mod.rs.html
index 8613f16c3c..343d8cded1 100644
--- a/docs/.vuepress/public/docs-rs/bdk/nightly/latest/src/bdk/wallet/mod.rs.html
+++ b/docs/.vuepress/public/docs-rs/bdk/nightly/latest/src/bdk/wallet/mod.rs.html
@@ -4692,6 +4692,97 @@
 4685
 4686
 4687
+4688
+4689
+4690
+4691
+4692
+4693
+4694
+4695
+4696
+4697
+4698
+4699
+4700
+4701
+4702
+4703
+4704
+4705
+4706
+4707
+4708
+4709
+4710
+4711
+4712
+4713
+4714
+4715
+4716
+4717
+4718
+4719
+4720
+4721
+4722
+4723
+4724
+4725
+4726
+4727
+4728
+4729
+4730
+4731
+4732
+4733
+4734
+4735
+4736
+4737
+4738
+4739
+4740
+4741
+4742
+4743
+4744
+4745
+4746
+4747
+4748
+4749
+4750
+4751
+4752
+4753
+4754
+4755
+4756
+4757
+4758
+4759
+4760
+4761
+4762
+4763
+4764
+4765
+4766
+4767
+4768
+4769
+4770
+4771
+4772
+4773
+4774
+4775
+4776
+4777
+4778
 
// Bitcoin Dev Kit
 // Written in 2020 by Alekos Filini <alekos.filini@gmail.com>
 //
@@ -4767,6 +4858,7 @@
 use crate::types::*;
 
 const CACHE_ADDR_BATCH_SIZE: u32 = 100;
+const COINBASE_MATURITY: u32 = 100;
 
 /// A Bitcoin wallet
 ///
@@ -5459,6 +5551,7 @@
             params.drain_wallet,
             params.manually_selected_only,
             params.bumping_fee.is_some(), // we mandate confirmed transactions if we're bumping the fee
+            current_height,
         )?;
 
         let coin_selection = coin_selection.coin_select(
@@ -6036,6 +6129,7 @@
     /// Given the options returns the list of utxos that must be used to form the
     /// transaction and any further that may be used if needed.
     #[allow(clippy::type_complexity)]
+    #[allow(clippy::too_many_arguments)]
     fn preselect_utxos(
         &self,
         change_policy: tx_builder::ChangeSpendPolicy,
@@ -6044,6 +6138,7 @@
         must_use_all_available: bool,
         manual_only: bool,
         must_only_use_confirmed_tx: bool,
+        current_height: Option<u32>,
     ) -> Result<(Vec<WeightedUtxo>, Vec<WeightedUtxo>), Error> {
         //    must_spend <- manually selected utxos
         //    may_spend  <- all other available utxos
@@ -6062,23 +6157,44 @@
             return Ok((must_spend, vec![]));
         }
 
-        let satisfies_confirmed = match must_only_use_confirmed_tx {
-            true => {
-                let database = self.database.borrow();
-                may_spend
-                    .iter()
-                    .map(|u| {
-                        database
-                            .get_tx(&u.0.outpoint.txid, true)
-                            .map(|tx| match tx {
-                                None => false,
-                                Some(tx) => tx.confirmation_time.is_some(),
-                            })
+        let database = self.database.borrow();
+        let satisfies_confirmed = may_spend
+            .iter()
+            .map(|u| {
+                database
+                    .get_tx(&u.0.outpoint.txid, true)
+                    .map(|tx| match tx {
+                        // We don't have the tx in the db for some reason,
+                        // so we can't know for sure if it's mature or not.
+                        // We prefer not to spend it.
+                        None => false,
+                        Some(tx) => {
+                            // Whether the UTXO is mature and, if needed, confirmed
+                            let mut spendable = true;
+                            if must_only_use_confirmed_tx && tx.confirmation_time.is_none() {
+                                return false;
+                            }
+                            if tx
+                                .transaction
+                                .expect("We specifically ask for the transaction above")
+                                .is_coin_base()
+                            {
+                                if let Some(current_height) = current_height {
+                                    match &tx.confirmation_time {
+                                        Some(t) => {
+                                            // https://github.com/bitcoin/bitcoin/blob/c5e67be03bb06a5d7885c55db1f016fbf2333fe3/src/validation.cpp#L373-L375
+                                            spendable &= (current_height.saturating_sub(t.height))
+                                                >= COINBASE_MATURITY;
+                                        }
+                                        None => spendable = false,
+                                    }
+                                }
+                            }
+                            spendable
+                        }
                     })
-                    .collect::<Result<Vec<_>, _>>()?
-            }
-            false => vec![true; may_spend.len()],
-        };
+            })
+            .collect::<Result<Vec<_>, _>>()?;
 
         let mut i = 0;
         may_spend.retain(|u| {
@@ -9378,6 +9494,72 @@
             "The signature should have been made with the right sighash"
         );
     }
+
+    #[test]
+    fn test_spend_coinbase() {
+        let descriptors = testutils!(@descriptors (get_test_wpkh()));
+        let wallet = Wallet::new(
+            &descriptors.0,
+            None,
+            Network::Regtest,
+            AnyDatabase::Memory(MemoryDatabase::new()),
+        )
+        .unwrap();
+
+        let confirmation_time = 5;
+
+        crate::populate_test_db!(
+            wallet.database.borrow_mut(),
+            testutils! (@tx ( (@external descriptors, 0) => 25_000 ) (@confirmations 0)),
+            Some(confirmation_time),
+            (@coinbase true)
+        );
+
+        let not_yet_mature_time = confirmation_time + COINBASE_MATURITY - 1;
+        let maturity_time = confirmation_time + COINBASE_MATURITY;
+
+        // The balance is nonzero, even if we can't spend anything
+        // FIXME: we should differentiate the balance between immature,
+        // trusted, untrusted_pending
+        // See https://github.com/bitcoindevkit/bdk/issues/238
+        let balance = wallet.get_balance().unwrap();
+        assert!(balance != 0);
+
+        // We try to create a transaction, only to notice that all
+        // our funds are unspendable
+        let addr = Address::from_str("2N1Ffz3WaNzbeLFBb51xyFMHYSEUXcbiSoX").unwrap();
+        let mut builder = wallet.build_tx();
+        builder
+            .add_recipient(addr.script_pubkey(), balance / 2)
+            .set_current_height(confirmation_time);
+        assert!(matches!(
+            builder.finish().unwrap_err(),
+            Error::InsufficientFunds {
+                needed: _,
+                available: 0
+            }
+        ));
+
+        // Still unspendable...
+        let mut builder = wallet.build_tx();
+        builder
+            .add_recipient(addr.script_pubkey(), balance / 2)
+            .set_current_height(not_yet_mature_time);
+        assert!(matches!(
+            builder.finish().unwrap_err(),
+            Error::InsufficientFunds {
+                needed: _,
+                available: 0
+            }
+        ));
+
+        // ...Now the coinbase is mature :)
+        let mut builder = wallet.build_tx();
+        builder
+            .add_recipient(addr.script_pubkey(), balance / 2)
+            .set_current_height(maturity_time);
+        builder.finish().unwrap();
+    }
 }
 
diff --git a/docs/.vuepress/public/docs-rs/bdk/nightly/latest/src/bdk/wallet/tx_builder.rs.html b/docs/.vuepress/public/docs-rs/bdk/nightly/latest/src/bdk/wallet/tx_builder.rs.html index 2c5994081a..2d922df69d 100644 --- a/docs/.vuepress/public/docs-rs/bdk/nightly/latest/src/bdk/wallet/tx_builder.rs.html +++ b/docs/.vuepress/public/docs-rs/bdk/nightly/latest/src/bdk/wallet/tx_builder.rs.html @@ -914,6 +914,11 @@ 907 908 909 +910 +911 +912 +913 +914
// Bitcoin Dev Kit
 // Written in 2020 by Alekos Filini <alekos.filini@gmail.com>
 //
@@ -1463,10 +1468,15 @@
 
     /// Set the current blockchain height.
     ///
-    /// This will be used to set the nLockTime for preventing fee sniping. If the current height is
-    /// not provided, the last sync height will be used instead.
-    ///
+    /// This will be used to:
+    /// 1. Set the nLockTime for preventing fee sniping.
     /// **Note**: This will be ignored if you manually specify a nlocktime using [`TxBuilder::nlocktime`].
+    /// 2. Decide whether coinbase outputs are mature or not. If the coinbase outputs are not
+    ///    mature at `current_height`, we ignore them in the coin selection.
+    ///    If you want to create a transaction that spends immature coinbase inputs, manually
+    ///    add them using [`TxBuilder::add_utxos`].
+    ///
+    /// In both cases, if you don't provide a current height, we use the last sync height.
     pub fn set_current_height(&mut self, height: u32) -> &mut Self {
         self.params.current_height = Some(height);
         self