4

I have decided I want to run a bitcoin node both to support the network, learn more about how it works and also so I can participate while minimising trust in external parties. I have a bitcoin core full node connected with the initial block download completed but am trying to figure out how to connect a mobile wallet to it. From my understanding of SPV wallets they should be able to connect directly with a bitcoin core node to request the block headers and transactions through the SPV process, but I don't see any way of doing this in most mobile wallets. There does, however, seem to be a way to connect to an Electrum server.

My questions, then, are:

  1. How does a mobile SPV wallet actually talk to the bitcoin network, and can I make my mobile SPV wallet talk to my bitcoin code node only?
  2. What does Electrum server do differently than just connecting an SPV node to the bitcoin network or a personal node?

I have tried to do some reading on these subjects but am struggling to really pin down what each is trying to do and as a result how I should attempt to set up my node to achieve full self-reliance. I would rather understand what's going on rather than have something "just work".

1 Answer 1

2

How does a mobile SPV wallet actually talk to the bitcoin network, and can I make my mobile SPV wallet talk to my bitcoin code node only?

SPV nodes store only block headers which have the merkle root hash. When an SPV node asks a full node details of a transaction, the full node gives the sibling merkle node hashes which let the SPV node verify if the transaction was really included in the blockchain or not.

The merkle tree verification

For example, your SPV wallet sends transaction hash of your interest to full node which is Hk assume here. The full node then sends back all the blue shaded merkle sibling hashes. Your SPV node then uses sibling hashes to compute parent hash and then so on till the root level.

For example,

(Hk + HL)->HKL

(HKL + HIJ)->HIJKL

(HIJKL + HMNOP)->HIJKLMNOP

(HIJKLMNOP + HABCDEFGH)->HABCDEFGHIJKLMNOP

Now because your SPV node has the root merkle hash, the end result of the above computation should exactly match. Not a match means the transaction isn't included in the blockchain or the full node is lying.

How to get around full node lying?

Here comes bloom filters. Bloom filters are like the description of a pattern that you can send to full node and ask give me all transactions matching this pattern. The beauty of bloom filters is that many patterns can be kind of etched onto the same area. And the SPV node will also include the patterns it is interested in and also some redundant patterns. This helps improve your privacy by not directly sending full node your data and also reduces the chance for full node to lie. There are wallets like BreadWallet that support custom SPV connections but I'm not sure if the feature is still available.

What does Electrum server do differently than just connecting an SPV node to the bitcoin network or a personal node?

It is just like another mobile or node less wallets. There's no node maintenance burden on you but the client/app you are using will ping a centralised server in most cases for using their hosted nodes. Electrum server is built on the full node. The ElectrumX implementation runs with txindex = 1 and downloads full blocks to your system. Check out ElectrumX which lets you run an Electrum server.

From there, your can configure your SPV wallet to connect to the electrum server you are running.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.