Skip to content

direct_conflicts should guarantee ordering with most recent conflict last #2112

@Camillarhi

Description

@Camillarhi

Describe the enhancement
The TxGraph::direct_conflicts() method returns a Vec<(usize, Txid)> of conflicting transactions, but there's currently no guaranteed ordering. For downstream libraries like bdk-wallet that need to track transaction replacements (RBF, double-spends), it would be helpful if the ordering was guaranteed such that the last entry is always the most recent/canonical transaction that remains in the mempool.

Use case
When generating wallet events for replaced transactions in bdk-wallet, we need to identify which conflicting transaction actually replaced the original one. I'm currently using bdk-wallet in ldk-node and consuming these events, but without guaranteed ordering from direct_conflicts(), there's no reliable way to determine which conflict is the canonical replacement.

Impact

  • Blocking production usage
  • Nice-to-have / UX improvement
  • Developer experience / maintainability

Are you using BDK in a production project?

  • Yes
  • No
  • Not yet, but planning to

Which backend(s) are relevant (if any)?

  • Electrum
  • Esplora
  • Bitcoin Core RPC
  • None / not backend-related (e.g. bdk_chain, bdk_core)
  • Other (please specify): ____

Project or organization (optional)

Additional context
This came up while implementing wallet events (specifically TxReplaced events) in bdk-wallet. Related PR: lightningdevkit/ldk-node#628

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions