1

How do the miners check that I have enough Bitcoins. I cannot believe that they will walk through the huge and always growing blockchain established from 2009 to check each Transaction I made to calculate my balance ?

  • for better searching by other users in future, I think this question should be split into two. One focussed on blockchain validation, the other transaction validation. – renlord Nov 7 '17 at 10:30
1

Bitcoin uses a thing called the Unspent Transaction Output Set (UTXO set), not accounts or balances. A transaction will consume UTXOs as inputs and create UTXOs as outputs. When a node receives a block (either during initial sync or normal relay), it will update its own internal database which contains the UTXO set. In this update, it removes the UTXOs that have been spent and adds the UTXOs that were created. Because it does this for every block, if a node is fully synced, it should know what all of the UTXOs are and have them stored in the database.

When a node receives your transaction, it will look up the UTXOs that your transaction spends in its database. If they don't exist, then it discards your transaction as invalid. It does not need to traverse the blockchain; the data it needs have been pulled out and put into another place where it can be easily looked up.

| improve this answer | |
0

Once you understand how databases work, it's easier to believe. Besides, it's only the UTXO's (ie Unspent Transaction Outputs) that are needed to calculate your balance.

Bitcoin clients load the blockchain data into an indexed database to allow very quick checks of the data.

More details here: https://en.bitcoin.it/wiki/Bitcoin_Core_0.11_(ch_2):_Data_Storage

| improve this answer | |
  • I do understand how databases work, cause I am an software engineer. I am beginning to read about bitcoin and blockchain, so I have several question the documentation could not answered yet. For me this also means that new miners do have to upload the huge blockchain into a database, which will take a few moments. – LikeTomAndJerry Nov 7 '17 at 16:26
  • Yes, validating the existing chain (which as a side effect builds up the database needed for validation of future blocks) tends to take several hours or more (based on disk, CPU and network speed). Validation of a new block afterwards only takes milliseconds, though. – Pieter Wuille Jan 6 '18 at 7:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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