3

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?

  • 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 '17 at 18:37
6

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.

4

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, privacy policy and cookie policy

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