<blockquote>
<p>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?</p>
</blockquote>
<p>SPV nodes store only block headers which have the <strong>merkle root hash</strong>. 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.</p>
<p><a href="https://i.sstatic.net/OEA0t.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/OEA0t.png" alt="The merkle tree verification" /></a></p>
<p>For example, your SPV wallet sends transaction hash of your interest to full node which is H<sub>k</sub> 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.</p>
<p>For example,</p>
<blockquote>
<p>(H<sub>k</sub> + H<sub>L</sub>)-&gt;H<sub>KL</sub></p>
</blockquote>
<blockquote>
<p>(H<sub>KL</sub> + H<sub>IJ</sub>)-&gt;H<sub>IJKL</sub></p>
</blockquote>
<blockquote>
<p>(H<sub>IJKL</sub> + H<sub>MNOP</sub>)-&gt;H<sub>IJKLMNOP</sub></p>
</blockquote>
<blockquote>
<p>(H<sub>IJKLMNOP</sub> + H<sub>ABCDEFGH</sub>)-&gt;H<sub>ABCDEFGHIJKLMNOP</sub></p>
</blockquote>
<p>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 <strong>full node is lying</strong>.</p>
<p>How to get around full node lying?</p>
<p>Here comes bloom filters. Bloom filters are like the description of a pattern that you can send to full node and ask <strong>give me all transactions matching this pattern</strong>. 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 <strong>some redundant patterns</strong>. 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.</p>
<blockquote>
<p>What does Electrum server do differently than just connecting an SPV node to the bitcoin network or a personal node?</p>
</blockquote>
<p>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 <strong>centralised server</strong> in most cases for using their <strong>hosted nodes</strong>. Electrum server is built on the full node. The ElectrumX implementation runs with <strong>txindex = 1</strong> and downloads full blocks to your system. Check out <a href="https://electrumx-spesmilo.readthedocs.io/en/latest/index.html" rel="nofollow noreferrer">ElectrumX</a> which lets you run an Electrum server.</p>
<p>From there, your can configure your SPV wallet to connect to the electrum server you are running.</p>

CC BY-SA 4.0
2021-10-14T03:54:25.577Z
2021-10-14T03:54:25.577Z
Pranay Reddy
<p>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.</p>
<p>My questions, then, are:</p>
<ol>
<li>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?</li>
<li>What does Electrum server do differently than just connecting an SPV node to the bitcoin network or a personal node?</li>
</ol>
<p>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 &quot;just work&quot;.</p>

<bitcoin-core><full-node><spv><electrum-server>
SPV wallet connecting to personal bitcoin node
Grub
# SPV wallet connecting to personal bitcoin node

(Asked by: username_0 on 2021-07-17)

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".

**Tags:** bitcoin-core, full-node, spv, electrum-server


---

## 1 answers

### Answer by username_1 on 2021-10-14. Score: 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](https://i.sstatic.net/OEA0t.png)](https://i.sstatic.net/OEA0t.png)

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](https://electrumx-spesmilo.readthedocs.io/en/latest/index.html) which lets you run an Electrum server.

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


---

