Fix: Wallet sync may decrement address index#653
Merged
afilini merged 1 commit intobitcoindevkit:release/0.20.0from Jul 11, 2022
Merged
Conversation
49cae10 to
f7ec271
Compare
07fa29e to
06c76a5
Compare
1123954 to
f4975d1
Compare
d09efa9 to
a8f470f
Compare
24 tasks
afilini
reviewed
Jul 6, 2022
dcddd61 to
6f6d923
Compare
notmandatory
reviewed
Jul 6, 2022
b4b2ad9 to
edf5ab7
Compare
rajarshimaitra
suggested changes
Jul 7, 2022
Contributor
rajarshimaitra
left a comment
There was a problem hiding this comment.
Concept ACK..
I verified that the test is only failing for Electrum, but not for RPC or Esplora.. Maybe worth exploring further..
I have a code suggestion for the same checking logic.. It seems we can get the check done in much sorter codes.
edf5ab7 to
ac5f0af
Compare
rajarshimaitra
approved these changes
Jul 8, 2022
Contributor
rajarshimaitra
left a comment
There was a problem hiding this comment.
tACK ac5f0af
Thanks for the quick update..
ac5f0af to
6f0ed1b
Compare
This bug seems to be Electrum-specific. The fix is to check the proposed changes against the current state of the database. Ensure newly suggested indexes are not smaller than indexes already in database. Changes: * Check index updates before they are applied to database during Electrum Blockchain sync (Thank you @rajarshimaitra for providing an elegant solution). Tests added: * bdk_blockchain_tests!::test_sync_address_index_should_not_decrement * bdk_blockchain_tests!::test_sync_address_index_should_increment These tests ensure there will be no unexpected address reuse when grabbing a new address via `Wallet::get_address` with `AddressIndex::New`. Other changes: * Tweak `rpc.rs` so that clippy is happy.
6f0ed1b to
af6bde3
Compare
Member
|
ACK af6bde3 I'll wait for the CI to finish and then I'll merge this. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #649
It is critical to ensure
Wallet::get_addresswithAddressIndex::newalways returns a new and unused address.This bug seems to be Electrum-specific. The fix is to check address index updates to ensure that newly suggested indexes are not smaller than indexes already in database.
Notes to the reviewers
I have written new tests in
/testutils/blockchain_tests.rsthat tests allBlockchainimplementations.Checklists
All Submissions:
cargo fmtandcargo clippybefore committingBugfixes:
* [ ] This pull request breaks the existing API