Add sent_and_received method on Wallet #428
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Adds the functionality for sent_and_received
sent_and_received
was a new method added in BDK.Computes total input value going from script pubkeys in the wallet (sent) and the total output value going to script pubkeys in the wallet (received) in the tx passed into the function.
For sent the function needs historical information about the outputs being spent (which are assumed to be indexed), while for received it can rely solely on the tx's outputs without needing prior indexing of spent outputs.
Notes to the reviewers
At the moment I decided to not add a code comment above the
sent_and_received
function in thewallet.rs
file; my thinking was I would like to add a code comment similar to what is in the BDK documentation, but since the BDK documentation is still evolving I wouldn't want to add a code comment in bdk-ffi now but never get back around to updating it as the BDK documentation changes, and thus have a misleading code comment in the future.Changelog notice
Checklists
All Submissions:
cargo fmt
andcargo clippy
before committingNew Features:
Bugfixes: