8

This is possibly a duplicate but, since I am a Bitcoin dummy I cannot find it.

Anyhow; as I understand (and I will make some assumptions here), a block in the blockchain contains one or more transactions.

Transactions are typically bits of information which contains delta's, I mean e.g.: Alice transfers 2 bitcoins to Bert.

So, to determine or verify my bitcoin balance (in order to make a valid transaction), does the whole chain needs to be analysed? If so, is this optimized in any way?

Or am I completely off track here?

2
  • related: Can someone explain how the Bitcoin Blockchain works?
    – Murch
    Feb 28, 2017 at 16:13
  • 1
    You are on the right track, actually. Each transactions tracks changes in the ownership of bitcoin, so in order to get the total current balance for a particular address, you do need to look at every record of change for said address. Unfortunately, the only way to do that is to analyze every transaction involving that address ever.
    – John Henry
    Mar 1, 2017 at 18:37

2 Answers 2

8

The blockchain defines your balance, but it doesn't have a specific field in which your balance is stored.

Yes, it needs to be analyzed to find your balance. However, it doesn't have to be analyzed all over again, just to check for the balance of a new address. Instead, checking the UTXO set (which only has to be created once and then to be updated every time new blocks are received) is sufficient. Furthermore, not the entire UTXO set has to be traversed. There are things like hash maps which make this a lot easier.

5

Your balance is the sum of UTXO (unspent transaction output) values in the blockchain since genesis block (block#0).

UTXO is the coins that the addresses' you control (by having their private keys) received and you haven't spend.

Your wallet keep reference to your UTXOs. So, no need to scan blockchain every time you spend.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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