work in progress, seeks conceptual review very experimental right now
This adds a hybrid and pure SPV mode to bitcoin cores wallet (including GUI).
The main out-of-band block requests are handled over the new "lock-free" class CBlockRequest.
This is a generic interface to allow retrieving a range of blocks (only headers PoW check, no validation) and throw them through the SyncTransaction() signals (could also be useful for ZMQ, etc,).
Hybrid mode
Can be enabled by -spv.
If enabled, the wallet tries to download blocks from the depth where the wallet was created (oldest key-birthday). Those requested blocks are getting prioritized in FindNextBlocksToDownload().
Once the next block (in order/sequence) has been retrieved, it gets sent through the SyncTransaction signal. Those - non-verified transactions will get a spv=true flag (visible in the GUI as well as over RPC).
The blocks are kept on the disk for later verification.
In the background, the IBD/verification is still processing/downloading blocks. Once a transaction was verified by connecting/verifying its block, the SPV flag gets removed from the transaction.
This result in a hybrid full-block SPV mode where the users doesn't need to download more (they later need to verify the blocks near the tip anyways) but its possible to already see incoming transactions and send out coins
Pure SPV
Can be enabled by -spvonly.
Result in not downloading blocks for verification.
Current limitations
- No SPV 0-conf transactions (those are pretty unsafe anyways)
- Fallback fee for SPV transaction (missing mempool/fee estimator)
- It has only a simple spv re-org handing
- currently incompatible with pruning
Thanks for feedback.