bdk
bdk copied to clipboard
Use `srcipthash_subscribe` when syncing `ElectrumBlockchain`
Describe
Not a bug :) More a question:
We noticed that electrs is printing warnings in the log, e.g.
[2022-06-02T07:35:12.036Z INFO electrs::electrum] your wallet uses less efficient method of querying electrs, consider contacting the developer of your wallet. Reason: blockchain.scripthash.get_history called for unsubscribed scripthash: 2b3ce0a1810e2255eb556532a94273496bdeb705323adcfbd30e7fa673d8ba84
[2022-06-02T07:35:12.044Z INFO electrs::electrum] your wallet uses less efficient method of querying electrs, consider contacting the developer of your wallet. Reason: blockchain.scripthash.get_history called for unsubscribed scripthash: 1787b9cfe70daf31e0cbebbf684d1565ef866e350e6031ee4051e5094ef99275
[2022-06-02T07:35:12.053Z INFO electrs::electrum] your wallet uses less efficient method of querying electrs, consider contacting the developer of your wallet. Reason: blockchain.scripthash.get_history called for unsubscribed scripthash: 89be2a62b1ae5b1f74396bcbeb131c888222ec74b305169f81a5402fb0b8f9b7
[2022-06-02T07:35:12.061Z INFO electrs::electrum] your wallet uses less efficient method of querying electrs, consider contacting the developer of your wallet. Reason: blockchain.scripthash.get_history called for unsubscribed scripthash: 1772e81bbfbe92d289a175b4e366a4312e267c003bf381f662716bf693a846ea
[2022-06-02T07:35:12.069Z INFO electrs::electrum] your wallet uses less efficient method of querying electrs, consider contacting the developer of your wallet. Reason: blockchain.scripthash.get_history called for unsubscribed scripthash: 0b45a072c427744ffb7bb5df0557c3c40eb4d6ef1c8d6f4fb085fb2823195810
When digging deeper into the code base, we saw that this message is printed when trying to get the history for a scripthash, i.e. this warning seems to be printed here:
https://github.com/romanz/electrs/blob/ca2841f43263db7f211f63c7448c1bc6e7a3f1c7/src/electrum.rs#L266-L282
Which seems to be coming from the sync/wallet_setup function of the electrum client here:
https://github.com/bitcoindevkit/bdk/blob/9c405e9c70e417dea0e610f9d44e99911d6b4e44/src/blockchain/electrum.rs#L123
This ticket on electrs is related: https://github.com/romanz/electrs/issues/652
The question is, can we use the recommended functionality of scripthash_subscribe
here instead?
To Reproduce
- create a wallet using
ElectrumBlockchain
- connect to a electrs server where you have access to the logs
- sync your wallet
- check electrs logs :)
Build environment
- BDK tag/commit: fbd98b4c5a88a10f8dfc22b4c54187eba4d68afe (but also older versions)
I don't get why that warning exists at all. The whole advantage of using electrum is stateless querying.
Being able to subscribe instead of querying every scripthash every time would be very useful.
Currently, to check the balance of the wallet, we have to query every scripthash. For wallets with a large transaction history this takes a very long time.
If we could subscribe then it would massively speed up bdk
based applications.
see also #1049