Author

Topic: Doubt on double spending (Read 274 times)

staff
Activity: 3458
Merit: 6793
Just writing some code
February 26, 2020, 01:08:46 PM
#2
This method of pruning was never implemented. Bitcoin Core uses a different method for pruning that is more efficient.

With this method of pruning, parts of the merkle tree is still stored, not just the root hash. It's more than just the block header. As transactions get spent, their txids get pruned from the merkle tree and the intermediate merkle branch hashes are stored. So if you were to perform a double spend, looking up the input would fail either because the txid is no longer stored as it has been hashed with others into a merkle branch, or it is still there but the particular output you are spending has been marked as spent. Either way, it is still safe.

But this is not as efficient and harder to reason about than how Bitcoin Core does pruning today. Bitcoin Core today builds a separate database of just the UTXOs. As a block is processed, all of the transactions are verified and the UTXO set is updated. When a block is done processing, it actually doesn't need to keep the block around because the UTXO set is what determines the chain state. So in Bitcoin Core, after a block is deep enough, its transaction data is discarded in entirety. The block header is still kept in another database, but the block data itself is deleted. This is safe because all of the important information, the UTXOs, are stored separately in the UTXO database. So if a double spend were to occur with a transaction that has been pruned, the output being spent would not exist in the UTXO database and thus that double spend is invalid.
hero member
Activity: 2702
Merit: 716
Nothing lasts forever
February 26, 2020, 11:38:55 AM
#1
I started learning more technical aspects of bitcoin lately and so I started reading it's whitepaper. I have a doubt in the 'reclaiming the disk space' section from the bitcoin whitepaper.

Quote
Once the latest transaction in a coin is buried under enough blocks, the spent transactions before
it can be discarded to save disk space. To facilitate this without breaking the block's hash,
transactions are hashed in a Merkle Tree [7][2][5], with only the root included in the block's hash.
Old blocks can then be compacted by stubbing off branches of the tree. The interior hashes do
not need to be stored.

As per the above, it is enough to store the block header and discard all the transactions inside the block by just keeping the root hash.

Now assume I am trying to double spend a transaction which was previously mined and buried under many lateral blocks.
How will the miner validate that the transaction is not being double spent since the miner will only be validating the block header and not all the transactions inside it?

Could someone clear my understanding ?
Jump to: