0
A transaction has in-bitcoin address. Transaction tells to transfer that address (in fraction or whole) to another address. Since the source of truth is block-chain, how does miner know that in-bitcoin address has said amount of data ? And how does miner check it efficiently ?
I have read about Merkel trees. My understanding is that they help to find whether a transaction is present in specific order in a block. But a block chain will have many blocks. So, how is it done efficiently by miners ?
Will not creating a hashmap from bitcoin-address to amount will be easier ?
Thanks for your answer.. Can you explain how this is done efficiently :
and makes sure that no other transaction has spent those outputs already.? – Ashish Negi – 2017-07-05T06:24:02.757And how does it find the bitcoin-value in previous transaction outputs (i think this is what is called in-addresses) ? Is it encoded in address itself ? (i doubt..) – Ashish Negi – 2017-07-05T06:26:31.353
The value is in the transaction output itself. – Andrew Chow – 2017-07-05T06:46:05.340
To ensure that no other transaction has spent the outputs spent by a transaction, the node maintains a list of all unspent transaction outputs. It updates this list as it receives new transactions, adding outputs that were created and removing ones that were spent. It can efficiently see if an output was already spent by checking if it is in the list. If it is, the output has not been spent. If it is not, then it has been spent or the transaction does not exist. – Andrew Chow – 2017-07-05T06:48:41.157
I guess it will be a hash-set .. just to be precise as this question is about efficiently finding the information. – Ashish Negi – 2017-07-05T07:50:39.453
In Bitcoin Core it is called the UTXO set, and stored as a LevelDB database (which is internally several overlapping sorted lists), and cached aggressively in RAM in a hashtable. – Pieter Wuille – 2017-07-05T17:15:43.040