How balances are calculated?

4

1

Is it the case that the blockchain has information on the balance associated with each public key-address, such that the client on my PC, say, will look at every public/private keys pair in wallet.dat, find all public keys in the blockchain for each of my private keys, sum up the balances for each, and show me the overall balance?

Strychnine

Posted 2013-04-21T05:42:32.980

Reputation: 43

Essentially, yes.Nick ODell 2013-04-21T06:19:31.827

Answers

1

The Bitcoin-Qt/bitcoind client computes the balance as you describe, by summing up all the transactions for all the Bitcoin addresses in the wallet.dat.

The blockchain contains all transactions since the genesis block (block 0). So the balances are simply all the unspent transaction outputs (UTXOs).

There are third party services which will monitor the blockchain to provide balance info for a specified address or addresses. BTCBalance.net is one.

Stephen Gornick

Posted 2013-04-21T05:42:32.980

Reputation: 26 118

I see, so there are no balances as such, only transactions. If I use the same address to receive / send the money 3 times, what will be recorded for that public key is, +20, -4, +7. These will be summed up along with everything else in the blockchain that corresponds to my wallet.dat when calculating the total balance.Strychnine 2013-04-21T18:20:35.947

And of course, the system rejects any transaction which would cause the balance for the public key used to become negative.Strychnine 2013-04-21T21:44:04.173

How do you go from a public address to a block?user1870400 2017-10-23T05:40:07.447