bcoin-org / bcoin

Javascript bitcoin library for node.js and browsers
https://bcoin.io
Other
3.02k stars 808 forks source link

SPV node + wallet process has missing transactions #935

Open braydonf opened 4 years ago

braydonf commented 4 years ago

Description

When running an SPV node with a wallet as a process there will be missing transactions from blocks.

Reproduce

  1. Run a full node in regtest. This could be ./src/bitcoind -regtest from another implementation.
  2. Run an SPV node in regtest and only connect to that full node. This can be done using ./bin/bcoin --spv --no-wallet --network=regtest --only=127.0.0.1:18444.
  3. Run a wallet process ./bin/bwallet --network=regtest.
  4. Mine 100+ blocks on the full node. Such as ./src/bitcoin-cli -regtest generatetoaddress 150 <address> after getting a mining address via ./src/bitcoin-cli -regtest getnewaddress.
  5. Generate an address from the wallet using /bin/bwallet-cli --network=regtest address default.
  6. Send a few transactions to that address using ./src/bitcoin-cli -regtest sendtoaddress <address> 0.5.
  7. Mine a block and watch the block be added to the wallet using /src/bitcoin-cli -regtest generatetoaddress 1 <address>.
  8. The transaction will not appear in the wallet however the block was added, as can be seen with ./bin/bwallet --network=regtest balance.

Current Solution

martindale commented 4 years ago

Run the SPV node and wallet in the same process as a plugin.

Can you share a brief example?

braydonf commented 4 years ago

It's the default behavior for a SPV node, so I believe just:

./bin/bcoin --spv