Repository navigation
feat(electrum): add ElectrumClient.populate_tx_cache - #1150
Merged
thunderbiscuit merged 1 commit intoOct 29, 2026
Merged
Conversation
Expose BdkElectrumClient::populate_tx_cache, which inserts transactions into the client's transaction cache so that it will not re-fetch them. A new ElectrumClient starts with an empty cache, so the first full_scan or sync on it downloads every transaction the wallet already has, one request each. Passing the wallet's transactions to populate_tx_cache first means the scan only downloads new ones. On a testnet4 wallet with 622 transactions, a full scan on a new client against a Fulcrum server went from 43.0 s to 2.1 s.
newtonick
force-pushed
the
electrum-populate-tx-cache
branch
from
October 26, 2026 23:30
b129210 to
9677671
Compare
newtonick
marked this pull request as ready for review
October 26, 2026 23:35
7 of 8 tasks
Member
|
Thanks for opening this! We've been hearing from multiple users now that sync speed and efficiency is paramount, and so I'm happy this API can help you out this way. Will review. Note the other possible improvements coming in #1012 if you'd like to review/comment on this. |
thunderbiscuit
approved these changes
Oct 27, 2026
thunderbiscuit
left a comment
Member
There was a problem hiding this comment.
ACK 9677671.
This is great; thanks for sending me down that rabbit hole, I was not aware of this method on the client! I would have loved an Android test but I think you'd need to create a wallet, populate it, save to persistence, re-build it, etc. Maybe too involved here.
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
bdk_electrum has
populate_tx_cacheand I wanted to expose it for my iOS multisig wallet (Birch) that uses Electrum. This PR exposes it onElectrumClient, so the wallet's transactions can be loaded into the cache before the scan and the scan only downloads new ones. This improves the speed of syncing dramatically. In Swift it looks like this:I benchmarked a full scan on a new client against a Fulcrum server on testnet4 (stop gap 20, batch size 50, median of 5 runs, in Rust with bdk_wallet 3.2.0 and bdk_electrum 0.24.1):
populate_tx_cacheI made the same change on top of 3.1.1, built bdk-swift with it (release) and tested it with my iOS wallet without any issues.
Notes to the reviewers
I kept the same name as bdk_electrum and had it take a list of transactions instead of a
Wallet, since the ADRs indocs/adrsay to keep the Rust names and only wrap when needed. The transactions can come fromWallet.transactions.Documentation
bdk_walletbitcoinuniffiBdkElectrumClient::populate_tx_cacheChangelog
I don't have permission to add labels. I think this should be
changelog: added.Checklists
All Submissions:
cargo fmtandcargo clippybefore committingchangelog:*labelNew Features: