Need to retrieve all of Alice’s transactions stored in a block and calculate their balance?
No one but Alice cares about her balance. This is because Bitcoin is cash, not a bank account. When you hand a store owner a $10 bill, they don’t want to know how much cash you have in your wallet, they just want to make sure the $10 is real. Bitcoin does not track balances per account holder. There are no accounts, people, or balances on the Bitcoin network or blockchain.
Bitcoin works on the basis of tracking UTXOs (Unspent Transaction Outputs). UTXOs are roughly equivalent to bills or coins. When someone spends a UTXO, all other nodes check to see if the UTXO exists and has not already been spent.
You can generate a list of UTXOs by reading the blockchain once from the beginning.
Bitcoin wallets, such as Bitcoin Core, can provide a way to view data from a copy of the blockchain. For example, Bitcoin Core has an RPC API that includes the following features: getreceivedbyaddress
– Typically only works with your own address, not someone else’s.
There are tools that can help you find out the balance of an address. But my question is how does this tool work? How do I request a blockchain?
They can use the Bitcoin network protocol to collect and index their own copy of the blockchain and then perform their own analysis on that data.
The Bitcoin network protocol allows a new node, such as a wallet, to discover several other nodes and request copies of blockchain data one by one.
Normally address balance doesn’t matter at all. They play no role in how Bitcoin works. You might dig through your pockets and rainy day coin jars and write down the total amount of money you find, but no one else really cares.