bdk icon indicating copy to clipboard operation
bdk copied to clipboard

Update bdk_bitcoind_rpc module to work with a pruned bitcoind node

Open notmandatory opened this issue 1 year ago • 9 comments

Summer of Bitcoin Project Proposal

Description

The current bdk_bitcoind_rpc module requires full access to transaction history using a non-pruned node (a node storing the full blockchain, which at the time of writing is over 400GB).

However, even without a wallet's full transaction history it is still possible to compute the wallet balance and be able to spend with only a pruned bitcoind node using the RPC method scantxoutset. This project will update the existing bdk_bitcoind_rpc module to work with a pruned bitcoind node.

Expected Outcomes

  • Updatefull_scan to use the scantxoutset if the bitcoind node is pruned.
  • Create tests to confirm full_scan works with a pruned node.
  • Update rpc examples and test with a pruned bitcoind node.

Resources

Skills Required

Mentor(s)
@notmandatory

Difficulty
Hard

Competency Test

  • Install rust, compile and run all bdk examples and tests.
  • Setup a local Bitcoin Core pruned node daemon in regtest mode.
  • Make a wallet with example_bitcoind_rpc_polling example wallet and receive and send regtest bitcoin.

notmandatory avatar Mar 06 '24 22:03 notmandatory

Mind if I work on this? I'm not SOB but I am doing a similar program haha

rustaceanrob avatar Mar 26 '24 02:03 rustaceanrob

Is this still open? Would like to give it a shot

c0llinx avatar Apr 04 '24 07:04 c0llinx

Not sure if our architecture actually supports this kind of usage. The problem is how do you figure out when an output has been spent? The only way is that it is no longer returned from the scantxoutset output. But in bdk_chain we tell it outputs are spent by providing a full transaction that spent it. We can't get that here.

It can be used to find your current balance, but can't be used in a way where you persist anything. So the workflow would be to just scantxout then get the outputs, create a transaction from them and spend them. You could .insert_txout them into a temporary Wallet and create transactions from there. I think that's the only way to get value from bdk with this atm.

LLFourn avatar Apr 05 '24 12:04 LLFourn

Hey @notmandatory the link you shared for rpc commands (https://developer.bitcoin.org/reference/rpc/) is somehow not working.

star-gazer111 avatar Apr 08 '24 10:04 star-gazer111

Hey @notmandatory the link you shared for rpc commands (https://developer.bitcoin.org/reference/rpc/) is somehow not working.

I think this can be a good alternative resource for the same.

star-gazer111 avatar Apr 08 '24 10:04 star-gazer111

@star-gazer111 https://chainquery.com/bitcoin-cli i prefer to use this one, its kinda better.

jaoleal avatar Apr 08 '24 15:04 jaoleal

@LLFourn what if we use the RPC syncing as it is now but with a bitcoind node set to "manual" pruning? then we just have to add functionality to call the "pruneblockchain" command after syncing to remove old (maybe older than 1000 deep or so) already ingested blocks.

notmandatory avatar Apr 08 '24 16:04 notmandatory

@notmandatory yeah cool I didn't know about this setting but that also works. I feel like the usage is a little niche:

  1. You don't want to run an archival node
  2. You can guarantee your wallet will come online often enough to drain the blocks and prune.
  3. You only have one wallet system.

Certainly not an unlikely situation within a small Bitcoin startup. Also can exist in user facing software that actually embeds a pruned node.

LLFourn avatar Apr 09 '24 07:04 LLFourn

This looks interesting, I think I will give it a shot

luisschwab avatar Apr 25 '24 23:04 luisschwab