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

Add scanblocks rpc, questions about RpcBlockchain #1224

Open
chrisguida opened this issue Nov 17, 2023 · 5 comments
Open

Add scanblocks rpc, questions about RpcBlockchain #1224

chrisguida opened this issue Nov 17, 2023 · 5 comments
Labels
module-blockchain new feature New feature or request

Comments

@chrisguida
Copy link

chrisguida commented Nov 17, 2023

I'm adding a new RPC to the rust-bitcoincore-rpc crate, and I'd love to know how I can use this in BDK.

The reason for this is that I'm rewriting my plugin, smaug, to use an RPC backend instead of an Esplora backend, since (to my knowledge) there are no public mainnet Esplora instances that don't ratelimit the BDK wallet scanning, and presumably Esplora is also not great for privacy.

The idea with scanblocks is that you give it one or more wallet descriptors and it returns a list of relevant block hashes after a few minutes. It's much better than any other wallet rescanning method I'm aware of, but I need to be able to easily get the blockhashes that result from this call and turn around and ask bitcoind for a full block for each block hash, then scan each block against my BDK Wallet to see which transactions belong to me.

There don't seem to be any examples for how to use the RpcBlockchain struct in such a custom way, though perhaps I'm not looking in the right place. It seems to simply store the wallet inside bitcoind, is that correct?

I currently have this Esplora code; how can I adapt this to use RpcBlockchain instead of EsploraBlockchain? Does it work in an async context? (ie does it work with cln-plugin?) And can I use a custom rust-bitcoincore-rpc crate (ie my PR listed above) as an upstream to bdk?

If not, is this even the right approach?

I'd love some guidance here; I'm a bit lost as to where my efforts are best spent. I'm completely happy to contribute any missing pieces :)

@chrisguida chrisguida added the new feature New feature or request label Nov 17, 2023
@notmandatory
Copy link
Member

One of the reasons BDK based wallets are getting rate limited is because they do a full scan for used addresses every time. The new BDK 1.0 API will give an option to do a "full_scan" or a simple "sync". The simple "sync" only checks addresses (SPKs, script pub keys) that the wallet has given out, and has the option for a super fast scan to only check SPKs that were given out but haven't been used yet. Check out #1194 see a bit more about how this will likely work.

@notmandatory
Copy link
Member

As for the RPC client, I'm not sure yet if we're going to call what it does scanning or syncing, but I think it will only do a sync since it doesn't need to do the stopgap based full scan, but anyway it will be able to efficiently sync the transactions for wallets will a large number of SPKs to track.

@chrisguida
Copy link
Author

chrisguida commented Nov 17, 2023

Ok, thanks! I'm just looking for some example of the RPC client that works now. I can update the references once BDK 1.0 is released.

I'm thinking scanblocks to get all relevant blockhashes, then some kind of Wallet.scan_block_for_my_txs(block) for each block after retrieving them from the RPC?

@chrisguida
Copy link
Author

Made a little example of how this would work: vladimirfomene#2

@notmandatory notmandatory added this to BDK Dec 5, 2023
@notmandatory notmandatory moved this to Todo in BDK Dec 5, 2023
@notmandatory notmandatory added this to the 1.0.0-beta.0 milestone Dec 5, 2023
@notmandatory
Copy link
Member

I put this in the beta.0 milestone to make sure any questions here about how to use the RPC blockchain client are resolved.

@notmandatory notmandatory removed this from the 1.0.0-beta milestone Mar 18, 2024
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: Todo
Development

No branches or pull requests

2 participants