Skip to content

Conversation

evanlinjin
Copy link
Member

@evanlinjin evanlinjin commented Aug 2, 2025

Description

This PR changes the behavior of IndexedTxGraph insert-if-relevant methods to consider relevant-tx-conflicts as relevant.

Affected methods:

  • .apply_block_relevant
  • .batch_insert_relevant
  • .batch_insert_relevant_unconfirmed

Rationale

It is useful to be able to determine:

  • Why something is no longer part of the best history.
  • Whether it is possible that something can reappear in the best history.

In order to do this, we need to track conflicts of spk-relevant transactions.

For example, an incoming transaction may be evicted from the mempool due to insufficient fees or cancelled (a conflicting transaction is confirmed). The caller may want to handle these two possibilities differently:

  • Transaction has insufficient fees - the caller may want to CPFP the transaction.
  • Transaction is cancelled/replaced - The user may want to forget about this transaction once the conflict reaches x confirmations.

The IntentTracker will make use of these relevant-conflicts to help determine the course of action.

Side note about chain sources

For some chain sources, obtaining relevant-conflicts is extremely costly or downright impossible (i.e. Electrum, BIP-158 filters).

bdk_bitcoind_rpc::Emitter is still the most robust chain source to use.

Changelog notice

Changed:
- Behavior of `IndexedTxGraph` methods (`apply_block_relevant`, `batch_insert_relevant` and `batch_insert_relevant_unconfirmed`) to also consider conflicts of spk-relevant transactions as relevant.

Checklists

All Submissions:

New Features:

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

Change behavior of {insert|apply}-if-relevant methods of `IndexedTxGraph`
to also consider txs that conflict with relevant txs as relevant.

Rationale:

It is useful to determine why something is evicted from the mempool.

For example, an incoming transaction may be evicted from the mempool due
to insufficient fees or a conflicting transaction is confirmed.

* Insufficient fees - the user may want to CPFP the tx.
* Conflicting tx is confirmed - the sender probably purposefully
  cancelled the tx. The user may want to forget about this tx once it
  reaches x confirmations.

The `IntentTracker` will make use of these relevant-conflicts.

A note about chain sources:

For some chain sources, obtaining relevant-conflicts is extremely
costly or downright impossible (i.e. Electrum, BIP-158 filters).

`bdk_bitcoind_rpc::Emitter` is still the most robust chain source to use.
@evanlinjin evanlinjin self-assigned this Aug 2, 2025
@evanlinjin evanlinjin marked this pull request as ready for review August 2, 2025 09:22
@evanlinjin evanlinjin moved this to Needs Review in BDK Chain Aug 2, 2025
@evanlinjin evanlinjin requested review from LagginTimes, ValuedMammal and nymius and removed request for ValuedMammal August 3, 2025 13:24
@ValuedMammal
Copy link
Collaborator

Concept ACK

Copy link
Contributor

@nymius nymius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 6938c8b

@evanlinjin evanlinjin force-pushed the feature/relevant_conflicts branch from 6938c8b to c846ad8 Compare August 7, 2025 03:41
Copy link
Contributor

@LagginTimes LagginTimes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 7ca58b3

Copy link
Contributor

@nymius nymius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 7ca58b3

@evanlinjin evanlinjin merged commit 8d9df97 into bitcoindevkit:master Aug 10, 2025
19 checks passed
@github-project-automation github-project-automation bot moved this from Needs Review to Done in BDK Chain Aug 10, 2025
@oleonardolima oleonardolima mentioned this pull request Sep 12, 2025
24 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants