bdk icon indicating copy to clipboard operation
bdk copied to clipboard

Implement `PrunedBlockchain` backend: RPC on pruned node

Open RCasatta opened this issue 3 years ago • 3 comments

Current RpcBlockchain grants full access to transaction history, however, it requires a non-pruned node (a node storing the full blockchain, which at the time of writing is over 400GB).

However, by renouncing to a wallet full transaction history, it is still possible to compute the wallet balance and be able to spend without needing a non-pruned node.

The key to achieve that is using RPC method scantxoutset

Note: if someone want to turn this into a "summer-of-bitcoin" project is welcome

Summer of Bitcoin Project Proposal

Description

Current RpcBlockchain grants full access to transaction history, however, it requires 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 core full node.

The key to achieve that is using RPC method scantxoutset

Expected Outcomes

  • Implement blockchain::rpc::PrunedRpcBlockchain and blockchain::rpc::PrunedRpcConfig.
  • PrunedRpcBlockchain will use core scantxoutset RPC to compute wallet balances.
  • PrunedRpcBlockchain will create spending transactions with a pruned core full node.

Resources

Skills Required

Mentor(s)
@afilini @RCasatta

Difficulty
Hard

Competency Test (optional)

  • Install rust, compile and run all bdk examples and tests.
  • Read through the BDK docs.
  • Setup a local Bitcoin Core node daemon in Regtest mode.
  • Make a dummy wallet with BDK with RPC blockchain.
  • Familiarity with basic rust, should be able to write basic trait implementations on foreign structures.

RCasatta avatar Jan 19 '22 15:01 RCasatta

We have discussed making the summer of bitcoin tasks a bit easier because most students don't have a lot of experience with Bitcoin or even git sometimes. Though, compared to the other tasks we have this seems relatively easy, so I'm adding the tag anyway..

afilini avatar Jan 20 '22 10:01 afilini

@afilini and @RCasatta would one or both of your be willing to mentor this issue for Summer of Bitcoin? I put you both on it for now. 🙂

notmandatory avatar Feb 14 '22 18:02 notmandatory

Imo we should take into consideration that "pruning" does not prune away transactions already found in the Core wallet, and that it is very simple to change a core node from non-pruned to pruned, and that it is also possible that a user will create a Core wallet very early on in bootstrap (even though pruning is enabled).

It would make sense in some cases to "reuse" the original RpcBlockchain for a pruned node. Imo an elegant implementation should take into consideration all possibilities.

evanlinjin avatar Aug 07 '22 06:08 evanlinjin

Closing this in favor of a new issue based on changing new bdk_bitcoind_rpc crate.

notmandatory avatar Mar 06 '24 21:03 notmandatory