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

Subscribe to script hashes when using electrum client #1049

Open
Tracked by #72
yukibtc opened this issue Jul 30, 2023 · 6 comments
Open
Tracked by #72

Subscribe to script hashes when using electrum client #1049

yukibtc opened this issue Jul 30, 2023 · 6 comments
Labels
module-blockchain new feature New feature or request

Comments

@yukibtc
Copy link
Contributor

yukibtc commented Jul 30, 2023

Hi, I'm working on a project that need to handle multiple descriptors (so multiple BDK wallets) at the same time across threads. Currently I execute a wallet sync every N secs but IMO this is a bad solution.
The best solution could be to execute a full sync at start and then subscribe to script hashes. Is there a way to do this?

And, do you plan to make BDK Wallet struct thread-safe?
Currently to "fix" the thread-safe issue, I use the SQLite db since it allow me to open the Wallet multiple times in different threads, but also in this case I thing that it isn't a good solution.
I can't put the Wallet struct inside an Arc<Mutex<>> because it will block the GUI/CLI since I have to perform a wallet sync every N secs (currently 60 secs).

https://github.com/coinstr/coinstr

@yukibtc yukibtc changed the title Subscribe to script hashes when using electrum client and thread-safe issues Subscribe to script hashes when using electrum client Jul 30, 2023
@evanlinjin
Copy link
Member

Seems like you are using the current stable version of BDK.

The new BDK (the work you see in the master branch), also previously known as BDK 1.0, is designed to not block on IO. This will allow you to still wrap Wallet in Arc<Mutex<>> and not have it block.

In terms of having an Electrum chain-source module that allows you to subscribe to specific spks, this is, and has been planned for a while. However, we cannot guarantee a release date. However, contributors are welcome.

@notmandatory
Copy link
Member

I moved this to the 1.1 milestone since it's not out of scope for 1.0 but could be done in a follow-on feature release without changing 1.0 BDK APIs.

@icy-ux
Copy link

icy-ux commented Jan 1, 2024

Adding my 2 cents: yes this would be very useful.

In particular for people who have large wallets with lots of transactions and UTXOs, calling sync on the wallet every time is not practical!

For large wallets and heavy users, being able to subscribe to script hashes is incredibly helpful.

@notmandatory notmandatory added this to BDK Jan 4, 2024
@notmandatory notmandatory removed this from the 1.1.0 milestone Mar 18, 2024
@turbamulta
Copy link

So my personal electrum is logging this error continously ""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"

The wallets devs say they need this enhacement in BDK to fix that, so just adding my +1 for it.

@notmandatory
Copy link
Member

notmandatory commented Mar 21, 2024

@turbamulta which version of bdk are you using? as mentioned above our new 1.0.0-alpha.x versions use a more efficient syncing. With 1.0 you get two options, the "scan all spks until stopgap unused found" which is what pre-1.0 does every time, and a "only scan spks for addresses i've given to the user" which can also be made more efficient by only scanning addresses that haven't received any tx yet.

Long term we would like to support this sort of subscription feature, but we're a small team and are focused right now on getting a final 1.0 release out.

@icy-ux
Copy link

icy-ux commented Mar 21, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module-blockchain new feature New feature or request
Projects
Status: No status
Development

No branches or pull requests

5 participants