Skip to content

Commit 61033f6

Browse files
committed
docs(wallet): update docs for calculate_fee/fee_rate and add_foreign_utxo
1 parent d37ace5 commit 61033f6

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

crates/bdk/src/wallet/mod.rs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -431,10 +431,17 @@ impl<D> Wallet<D> {
431431
.next()
432432
}
433433

434-
/// Inserts the given foreign `TxOut` at `OutPoint` into the wallet's transaction graph. Any
435-
/// inserted foreign TxOuts are not persisted until [`Self::commit`] is called.
434+
/// Inserts a [`TxOut`] at [`OutPoint`] into the wallet's transaction graph.
435+
/// Any inserted TxOuts are not persisted until [`commit`] is called.
436+
///
437+
/// This can be used to add a `TxOut` that the wallet doesn't own but is used as an input to
438+
/// a [`Transaction`] passed to the [`calculate_fee`] or [`calculate_fee_rate`] functions.
436439
///
437440
/// Only insert TxOuts you trust the values for!
441+
///
442+
/// [`calculate_fee`]: Self::calculate_fee
443+
/// [`calculate_fee_rate`]: Self::calculate_fee_rate
444+
/// [`commit`]: Self::commit
438445
pub fn insert_txout(&mut self, outpoint: OutPoint, txout: TxOut)
439446
where
440447
D: PersistBackend<ChangeSet>,
@@ -445,9 +452,8 @@ impl<D> Wallet<D> {
445452

446453
/// Calculates the fee of a given transaction. Returns 0 if `tx` is a coinbase transaction.
447454
///
448-
/// To calculate the fee for a [`Transaction`] that depends on foreign [`TxOut`] values you must
449-
/// first manually insert the foreign TxOuts into the tx graph using the [`insert_txout`] function.
450-
/// Only insert TxOuts you trust the values for!
455+
/// To calculate the fee for a [`Transaction`] with inputs not owned by this wallet you must
456+
/// manually insert the TxOut(s) into the tx graph using the [`insert_txout`] function.
451457
///
452458
/// Note `tx` does not have to be in the graph for this to work.
453459
///
@@ -458,9 +464,8 @@ impl<D> Wallet<D> {
458464

459465
/// Calculate the [`FeeRate`] for a given transaction.
460466
///
461-
/// To calculate the fee rate for a [`Transaction`] that depends on foreign [`TxOut`] values you
462-
/// must first manually insert the foreign TxOuts into the tx graph using the [`insert_txout`] function.
463-
/// Only insert TxOuts you trust the values for!
467+
/// To calculate the fee rate for a [`Transaction`] with inputs not owned by this wallet you must
468+
/// manually insert the TxOut(s) into the tx graph using the [`insert_txout`] function.
464469
///
465470
/// Note `tx` does not have to be in the graph for this to work.
466471
///
@@ -1073,6 +1078,8 @@ impl<D> Wallet<D> {
10731078
/// *replace by fee* (RBF). If the transaction can be fee bumped then it returns a [`TxBuilder`]
10741079
/// pre-populated with the inputs and outputs of the original transaction.
10751080
///
1081+
///
1082+
///
10761083
/// ## Example
10771084
///
10781085
/// ```no_run

crates/bdk/src/wallet/tx_builder.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,10 @@ impl<'a, D, Cs: CoinSelectionAlgorithm, Ctx: TxBuilderContext> TxBuilder<'a, D,
335335
///
336336
/// This is an **EXPERIMENTAL** feature, API and other major changes are expected.
337337
///
338+
/// In order to use [`Wallet::calculate_fee`] or [`Wallet::calculate_fee_rate`] for a transaction
339+
/// created with foreign UTXO(s) you must manually insert the corresponding TxOut(s) into the tx
340+
/// graph using the [`Wallet::insert_txout`] function.
341+
///
338342
/// # Errors
339343
///
340344
/// This method returns errors in the following circumstances:

0 commit comments

Comments
 (0)