-
Notifications
You must be signed in to change notification settings - Fork 416
Add sent_and_received_txouts methods to SPK and Keychain TxOut indexes #2081
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Add sent_and_received_txouts methods to SPK and Keychain TxOut indexes #2081
Conversation
…indexes Implement sent_and_received_txouts methods on SpkTxOutIndex and KeychainTxOutIndex. These methods return actual TxOut structs allowing callers to access complete transaction output information including script pubkeys and values.
b927934 to
c1b4c5f
Compare
| /// // Get sent and received txouts for a transaction across all tracked addresses | ||
| /// let (sent_txouts, received_txouts) = index.sent_and_received_txouts(&tx, ..); | ||
| /// | ||
| /// // Display addresses and amounts |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tnull would this information be useful for LDKnode when handling the transactions in WalletEvents ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, yes, that would be very helpful, we just recently got requests to be able to see which address was sent to: lightningdevkit/ldk-node#684
Do you happen to see a way to include the output's index in this API, too? (cf. lightningdevkit/ldk-node#717). Maybe the return type could be (Vec<(usize, TxOut)>, Vec<(usize, TxOut)>), or a similar struct representation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, since the input & output Vecs of Transaction are in the correct order I'm able to return the index info with the TxOuts. See 6ff9f26.
47a3f66 to
b9aaf05
Compare
Return tuple of (index, TxOut) in sent_and_received_txouts methods to identify which input/output positions the TxOuts correspond to in the original transaction.
b9aaf05 to
6ff9f26
Compare
Description
Implement sent_and_received_txouts methods on SpkTxOutIndex and KeychainTxOutIndex. These methods return actual TxOut structs allowing callers to access complete transaction output information including script pubkeys and values.
Notes to the reviewers
This info is useful to users who use the new WalletEvent data in bitcoindevkit/bdk_wallet#319. In particular to determine the addresses and amounts for TxOuts that are sent/spent or have been received in a newly seen or confirmed transaction. See: bdk_wallet#319 comment
If/when this PR is merged I'll make a corresponding one to add a
Wallet::sent_and_received_txoutsmethod.Changelog notice
Added
Checklists
All Submissions:
New Features: