-
Notifications
You must be signed in to change notification settings - Fork 325
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
fix(chain): detect incoming transaction being replaced/canceled #1765
base: master
Are you sure you want to change the base?
Conversation
11c1eb3
to
3545b48
Compare
0dc826d
to
43bca86
Compare
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.
This behaves as expected! However, I think including the conflicting transaction in the wallet's Tx graph may create unnecessary noise/confusion. Since these conflicts don't represent actual wallet activity.
Perhaps irrelevant transactions could be filtered out either directly in list_canonical_txs
or in the wallet crate. Alternatively, marking the existing wallet tx as conflicting without inserting the external conflicting transactions into the graph.
That's a good point. It's a one line change to have |
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.
ConceptACK
I'm requesting the following changes:
- Better clarity with the tests.
- Update docs of the methods that are changed (since we changed the definition of what is relevant).
I expect a follow-up PR which tests against a block-by-block chain source (bdk_bitcoind_rpc
). I think this test can exist in bdk_bitcoind_rpc
.
…ctions 75fae3e test(wallet): verify Wallet::transactions method only returns relevant txs (Steve Myers) 3e1fd2b fix(wallet): `transactions` method should only return relevant txs (志宇) Pull request description: Fixes #1239 ### Description Currently the behavior of `Wallet::transactions` is not well defined and unintuitive. The approach taken in this PR is to make `Wallet::transactions` return what most wallets would like the caller to see (i.e. transactions that are part of the canonical history and spend from/to a tracked spk). A.k.a make the method more restrictive. Documentation is updated to refer the caller to the underlying `bdk_chain` structures for any over usecase. After #1765 gets merged, the behavior of `Wallet::transactions` will become even more unintuitive. Refer to #1765 (review). ### Notes to the reviewers **Why not have multiple methods in `Wallet` that return different sets of transactions?** I think it's better to only provide common usecase histories from `Wallet` and I can only think of one. ### Changelog notice * Change `Wallet::transactions` to only include "relevant" transactions. ### Checklists #### All Submissions: * [x] I've signed all my commits * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md) * [x] I ran `cargo fmt` and `cargo clippy` before committing ACKs for top commit: luisschwab: tACK 75fae3e notmandatory: tACK 75fae3e oleonardolima: tACK 75fae3e ValuedMammal: ACK 75fae3e Tree-SHA512: abf159e0c5d44842d7e0fc5ebc6829d34646fbc45d07bb145ce327f368db0e571ab7c5731a12e63258dfc74abb9d4ff1b841842de8341e0f21b5cbb2becc5e5f
43bca86
to
d9a699d
Compare
@LagginTimes I rebased and forced push. The last commit I added provides unconfirmed spends to spk-based chain sources. This should be enough to fully fix #1740 but we need to test. I expect a |
d9a699d
to
afb6cad
Compare
IndexedTxGraph
The title needs to highlight what is being fixed, not what is changed to do the fix. Suggestion: Detect incoming transaction being replaced/canceled. |
afb6cad
to
23af05f
Compare
A transaction's relevancy was originally only determined by the spks referenced by the tx's inputs and outputs. A new rule is added where if a tx shares inputs with anything contained in TxGraph, then it should also be considered relevant. This fixes a potential double spending problem.
Unconfirmed outputs can now be easily provided to the `SyncRequest` via `SyncRequestExt::unconfirmed_spends`. This allows the chain src to detect receiving txs being replaced/cancelled. `Wallet::start_sync_with_revealed_spks` has been deprecated in favor of `start_sync` which included unconfirmed spends.
23af05f
to
58a6704
Compare
Fixes #1740.
Description
This PR addresses a potential double-spending issue by implementing the following changes:
Redefine Transaction Relevancy in
IndexedTxGraph
Transactions are now considered relevant if they:
TxGraph
.Include Unconfirmed Spends in Chain Sync Requests
SyncRequestExt::unconfirmed_spends
, which enables the chain source to detect replaced or canceled transactions.Wallet::start_sync_with_revealed_spks
in favor ofstart_sync
, which supports unconfirmed spends.Notes to the reviewers
Changelog notice
IndexedTxGraph
.Wallet::start_sync_with_revealed_spks
in favor of the more comprehensiveWallet::start_sync
.Checklists
All Submissions:
cargo fmt
andcargo clippy
before committingBugfixes: