Repository navigation
Conversation
IndexerChangeSet only carried last_revealed, so converting from the upstream keychain_txout::ChangeSet dropped spk_cache and converting back replaced it with an empty default. A wallet using custom persistence with use_spk_cache never stored its script pubkey cache and derived every script pubkey again on load. Add spk_cache to IndexerChangeSet and convert it in both directions. The field defaults to an empty map in the generated constructors, so existing IndexerChangeSet(lastRevealed) calls keep compiling. Fixes bitcoindevkit#1099
This branch has not been deployed
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 #1099.
IndexerChangeSetonly carriedlast_revealed. Converting from the upstreamkeychain_txout::ChangeSetdroppedspk_cache, and converting back filled it withDefault::default(). A wallet using custom persistence withuse_spk_cachetherefore never stored its script pubkey cache, and derived every script pubkey again on each load.This adds
spk_cache: HashMap<DescriptorId, HashMap<u32, Script>>toIndexerChangeSetand converts it in both directions.Notes to the reviewers
#[uniffi(default)], so the generated constructors default it to an empty map (mapOf()in Kotlin,[:]in Swift). ExistingIndexerChangeSet(lastRevealed = ...)calls still compile. The record still gains a field, so I left it to you whether this counts as breaking.lastRevealedkeep working, but they need to storespkCacheas well to benefit from the cache.create. The tests reveal one address before checking what was persisted.Tests (Rust,
src/tests/wallet.rs):test_indexer_changeset_round_trips_spk_cache: upstream changeset →IndexerChangeSet→ upstream is lossless.test_custom_persistence_persists_spk_cache: a customPersistencereceives the cached script pubkeys for both keychains, and they match the wallet's addresses.test_custom_persistence_reloads_spk_cache_without_rederiving: after reloading through the custom persister, the next reveal stages only the one newly derived script pubkey. When the cache is not restored on load, every script pubkey of both keychains is staged again.All three fail on
masterand pass with this change.cargo fmt,cargo clippy --all-targets -- -D warningsandcargo test --lockedpass.Tests (bindings):
CustomPersistenceTests.swiftandCustomPersistenceTest.ktimplementPersistencein the foreign language. They check thatIndexerChangeSet(lastRevealed:)still compiles and defaultsspkCacheto empty, that the persister receives the cache, and that a reload reuses it.swift testafterbuild-xcframework.shon macOS (arm64); the new tests and the existingPersistenceTests/CustomSyncTestspass.connectedAndroidTeston an android-33 arm64 emulator (NDK r27 locally, arm64-v8a only); the new tests andPersistenceTestpass. The twoCustomSyncTestcases that need the regtest Electrum server failed withConnection refusedbecause I didn't run that server locally.Documentation
bdk_walletbdk_chain::indexer::keychain_txout::ChangeSetuniffi: default values for record fieldsChangelog
Suggested label:
changelog: fixed. I can't add labels from a fork, so could a maintainer apply it?Checklists
All Submissions:
cargo fmtandcargo clippybefore committingchangelog:*labelBugfixes: