0

I am reading and watching about transactions and they say a transaction's input is previous transaction's output. They all show diagrams in which these transactions are consecutive.

How an account's balance is found if the latest input and previous output are away from each other away more than 1 transaction.

Also how an account's balance is found if there are some outputs to that account with small values in different transactions and another output which is account's balance? How they are gathered?

With which algorithm wallets traverse blockchain?

I am making my own node and wallet to grasp bitcoin better and couldn't understand these things about transactions.

0

How an account's balance is found if the latest input and previous output are away from each other away more than 1 transaction.

They never are. They are the same. Someone's input becomes someone else's output, until he decides to spent said output as an input in a new transaction.

Or, am i not understanding the question? Are you asking why a wallet understands why an output ...(that he received more than X blocks away) still belongs to him? See =>

Also how an account's balance is found if there are some outputs to that account with small values in different transactions and another output which is account's balance? How they are gathered?

I don't really understand what you're asking here, but your node keeps track of every transaction, and then creates a UTXO set- Unspent Transaction Output. In this set are all the unspent outputs of the entire network. The wallet then checks if any of these outputs belong to an adress you own (Note: the wallet doesn't actually directly use the adress to scan for UTXO's, but rather the output script, but for practicality you can just see it as an adress, i guess.) (have the private key of), and if so - will show it as belonging to you - and thus your (account) balance.

| improve this answer | |
  • Isn't storing an entire UTXOs set ineffective? I mean, there are millions of bitcoin accounts – Mehmet Egemen Albayrak Jan 18 at 15:39
  • 2
    @mehmet bitcoin does not operate on account based model but UTXO based models. You need to consume an entire boutput of previous transaction as an input to the next transaction that you create. If you did not maintain an UTXO model you would have to scan each past block to look if the transaction mentioned is a double spend transaction. Caching the UTXO set in the RAM allows for much faster verification of transactions. – Ugam Kamat Jan 18 at 17:35
0

In the backend of the bitcoin network's operation, there is no concept of 'account balance'. Rather, the network keeps track of coin ownership via a UTXO model.

So when a node validates the history of the network during the initial sync, it will construct a UTXO set and update it accordingly as it works through history. So a node will store the blockchain history (or a pruned version of it), along with a 'UTXO set', that represents all coins on the network. Once caught up to the chain tip, the wallet software can present the user with their balance, by simply summing up the value of all UTXOs that the wallet knows it can sign for (ie, the UTXOs it owns).

| improve this answer | |

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.