Skip to content

Commit

Permalink
docs(wallet): update docs for calculate_fee/fee_rate and add_foreign_…
Browse files Browse the repository at this point in the history
…utxo
  • Loading branch information
notmandatory committed Aug 24, 2023
1 parent d37ace5 commit 61033f6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
23 changes: 15 additions & 8 deletions crates/bdk/src/wallet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -431,10 +431,17 @@ impl<D> Wallet<D> {
.next()
}

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

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

/// Calculate the [`FeeRate`] for a given transaction.
///
/// To calculate the fee rate for a [`Transaction`] that depends on foreign [`TxOut`] values you
/// must first manually insert the foreign TxOuts into the tx graph using the [`insert_txout`] function.
/// Only insert TxOuts you trust the values for!
/// To calculate the fee rate for a [`Transaction`] with inputs not owned by this wallet you must
/// manually insert the TxOut(s) into the tx graph using the [`insert_txout`] function.
///
/// Note `tx` does not have to be in the graph for this to work.
///
Expand Down Expand Up @@ -1073,6 +1078,8 @@ impl<D> Wallet<D> {
/// *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.
///
///
///
/// ## Example
///
/// ```no_run
Expand Down
4 changes: 4 additions & 0 deletions crates/bdk/src/wallet/tx_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,10 @@ impl<'a, D, Cs: CoinSelectionAlgorithm, Ctx: TxBuilderContext> TxBuilder<'a, D,
///
/// This is an **EXPERIMENTAL** feature, API and other major changes are expected.
///
/// In order to use [`Wallet::calculate_fee`] or [`Wallet::calculate_fee_rate`] for a transaction
/// created with foreign UTXO(s) you must manually insert the corresponding TxOut(s) into the tx
/// graph using the [`Wallet::insert_txout`] function.
///
/// # Errors
///
/// This method returns errors in the following circumstances:
Expand Down

0 comments on commit 61033f6

Please sign in to comment.