Merge bitcoindevkit/bdk#1285: doc(wallet): improve docs for Wallet::sent_and_received

08b745ec9f16fa8ef18b0d9c92feb9d8ab87a184 doc(wallet): improve docs for `Wallet::sent_and_received` (vmammal)

Pull request description:

  Thank you @thunderbiscuit for raising this issue. I noticed this method borrows the language from `SpkTxOutIndex::sent_and_received`, which this PR doesn't touch. I think in general it's desirable that methods in `bdk_chain` crate would refer to some of the core structures directly.

  ### Checklists

  #### All Submissions:

  * [x] I've signed all my commits
  * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md)
  * [x] I ran `cargo fmt` and `cargo clippy` before committing

ACKs for top commit:
  evanlinjin:
    ACK 08b745ec9f16fa8ef18b0d9c92feb9d8ab87a184

Tree-SHA512: 7f1285c4baa5fb56fd65baa5585bd343338de9988b941618a2b9ab628d869563f6f71ce842f936e7e1fb6a56f2f1e50fc3deaff858e830b7039888e4e496ce9a
This commit is contained in:
志宇 2024-01-19 23:37:59 +08:00
commit 8d916d7a10
No known key found for this signature in database
GPG Key ID: F6345C9837C2BDE8

View File

@ -992,12 +992,11 @@ impl<D> Wallet<D> {
})
}
/// 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
///