Friday, 17 August 2018

How exactly does a SPV wallet determine the correct chain and confirm transactions

It’s important to realize that an SPV wallet does not merely rely on the other network nodes to determine the longest chain of blocks. It looks at the best header chain: the chain of valid block headers that has the most cumulative proof of work. A good SPV implementation also ensures that this proof of work is of the appropriate hashing difficulty level.

I'm trying to fully understand this, so correct me if I'm wrong:

When an SPV wallet is presented with a new chain, it checks every block header from the genesis block in that chain. The block header is inextricably linked with the block itself. This means it is impossible to provide a header that doesn't match the block, so the block must have had the same degree of PoW done as the header. Thereby, determining the hashing difficulty of each block header and summing them is enough to determine the total PoW for the chain.

After finding the chain with the most PoW, if the SPV wallet makes a transaction it actually dives into the blocks to find the transaction (I assume starting from the end of the chain and working backwards). It doesn't check any other transactions.

The SPV wallet can be fooled into accepting an invalid block, but the SPV can still determine the hashing difficulty of the block by the header. So in effect the chain with invalid block(s) would grow slower than the chain with valid blocks as long as the invalid block producers have less than 50% hashpower. As soon as the SPV is presented with the valid chain with more PoW (determined by block headers) it drops the chain with invalid blocks.

submitted by /u/Rolling_Civ
[link] [comments]

source https://www.reddit.com/r/btc/comments/982oz9/how_exactly_does_a_spv_wallet_determine_the/

No comments:

Post a Comment