]> Untitled Git - bdk/commit
Fix: Wallet sync may decrement address index
author志宇 <hello@evanlinjin.me>
Sun, 3 Jul 2022 06:32:05 +0000 (14:32 +0800)
committer志宇 <hello@evanlinjin.me>
Mon, 11 Jul 2022 09:52:36 +0000 (17:52 +0800)
commitaf6bde3997ac2fe4cfdbb691f2af2e802f0ab7c6
tree71b4e7825eda5de2df50e1232cc2c78571210239
parent4bd1fd2441ae2e264df24652b42d113b016aac6c
Fix: Wallet sync may decrement address index

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.
CHANGELOG.md
src/blockchain/rpc.rs
src/blockchain/script_sync.rs
src/testutils/blockchain_tests.rs