From 08b745ec9f16fa8ef18b0d9c92feb9d8ab87a184 Mon Sep 17 00:00:00 2001 From: vmammal Date: Wed, 17 Jan 2024 13:00:27 -0500 Subject: [PATCH] doc(wallet): improve docs for `Wallet::sent_and_received` --- crates/bdk/src/wallet/mod.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/crates/bdk/src/wallet/mod.rs b/crates/bdk/src/wallet/mod.rs index ce152cb5..ab78b36b 100644 --- a/crates/bdk/src/wallet/mod.rs +++ b/crates/bdk/src/wallet/mod.rs @@ -914,12 +914,11 @@ impl Wallet { }) } - /// Computes total input value going from script pubkeys in the index (sent) and the total output - /// value going to script pubkeys in the index (received) in `tx`. + /// Compute the `tx`'s sent and received amounts (in satoshis). /// - /// For the `sent` to be computed correctly, the outputs being spent must have already been - /// scanned by the index. Calculating received just uses the [`Transaction`] outputs directly, - /// so it will be correct even if it has not been scanned. + /// This method returns a tuple `(sent, received)`. Sent is the sum of the txin amounts + /// that spend from previous txouts tracked by this wallet. Received is the summation + /// of this tx's outputs that send to script pubkeys tracked by this wallet. /// /// # Examples ///