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.
This commit is contained in:
@@ -340,7 +340,7 @@ impl WalletSync for RpcBlockchain {
|
||||
),
|
||||
received,
|
||||
sent,
|
||||
fee: tx_result.fee.map(|f| f.as_sat().abs() as u64),
|
||||
fee: tx_result.fee.map(|f| f.as_sat().unsigned_abs()),
|
||||
};
|
||||
debug!(
|
||||
"saving tx: {} tx_result.fee:{:?} td.fees:{:?}",
|
||||
|
||||
Reference in New Issue
Block a user