Skip to content

Conversation

@notmandatory
Copy link
Member

@notmandatory notmandatory commented Dec 10, 2025

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_txouts method.

Changelog notice

Added

  • New sent_and_received_txouts methods on SpkTxOutIndex and KeychainTxOutIndex.

Checklists

All Submissions:

New Features:

  • I've added tests for the new feature
  • I've added docs for the new feature

@notmandatory notmandatory added this to the Chain 0.24.0 milestone Dec 10, 2025
@notmandatory notmandatory self-assigned this Dec 10, 2025
@notmandatory notmandatory added the new feature New feature or request label Dec 10, 2025
…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.
@notmandatory notmandatory force-pushed the feat/send_recvd_txouts branch from b927934 to c1b4c5f Compare December 10, 2025 22:26
@notmandatory notmandatory moved this to Needs Review in BDK Chain Dec 10, 2025
@notmandatory notmandatory changed the title Add send_and_received_txouts methods to SPK and Keychain TxOut indexes Add sent_and_received_txouts methods to SPK and Keychain TxOut indexes Dec 10, 2025
/// // 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
Copy link
Member Author

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 ?

Copy link
Contributor

@tnull tnull Dec 11, 2025

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?

Copy link
Member Author

@notmandatory notmandatory Dec 11, 2025

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.

@notmandatory notmandatory force-pushed the feat/send_recvd_txouts branch 2 times, most recently from 47a3f66 to b9aaf05 Compare December 11, 2025 17:36
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.
@notmandatory notmandatory force-pushed the feat/send_recvd_txouts branch from b9aaf05 to 6ff9f26 Compare December 11, 2025 17:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new feature New feature or request

Projects

Status: Needs Review

Development

Successfully merging this pull request may close these issues.

2 participants