Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use srcipthash_subscribe when syncing ElectrumBlockchain #618

Open
bonomat opened this issue Jun 3, 2022 · 3 comments
Open

Use srcipthash_subscribe when syncing ElectrumBlockchain #618

bonomat opened this issue Jun 3, 2022 · 3 comments
Labels
bug Something isn't working discussion There's still a discussion ongoing

Comments

@bonomat
Copy link
Contributor

bonomat commented Jun 3, 2022

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:

.batch_script_get_history(scripts)

This ticket on electrs is related: romanz/electrs#652

The question is, can we use the recommended functionality of scripthash_subscribe here instead?

To Reproduce

  1. create a wallet using ElectrumBlockchain
  2. connect to a electrs server where you have access to the logs
  3. sync your wallet
  4. check electrs logs :)

Build environment

  • BDK tag/commit: fbd98b4 (but also older versions)
@bonomat bonomat added the bug Something isn't working label Jun 3, 2022
@LLFourn
Copy link
Contributor

LLFourn commented Jun 3, 2022

I don't get why that warning exists at all. The whole advantage of using electrum is stateless querying.

@icy-ux
Copy link

icy-ux commented Dec 31, 2023

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.

@notmandatory
Copy link
Member

see also #1049

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working discussion There's still a discussion ongoing
Projects
Status: No status
Development

No branches or pull requests

4 participants