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

<p>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. </p>

<p>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 =></p>

<blockquote>
  <p>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?</p>
</blockquote>

<p>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. </p>

CC BY-SA 4.0
2020-01-18T15:39:16.937Z
Isn't storing an entire UTXOs set ineffective? I mean, there are millions of bitcoin accounts
Mehmet Egemen Albayrak
CC BY-SA 4.0
2020-01-18T17:35:27.803Z
@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
CC BY-SA 4.0
2020-01-18T12:09:17.583Z
2020-01-18T12:09:17.583Z
Jan Janssen
<p>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. </p>

<p>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). </p>

CC BY-SA 4.0
2020-01-18T22:10:00.083Z
2020-01-18T22:10:00.083Z
chytrik
<p>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.</p>

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

<p>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?</p>

<p>With which algorithm wallets traverse blockchain?</p>

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

<transactions>
How bitcoin finds a few transactions earlier account balance from outputs?
Mehmet Egemen Albayrak
# How bitcoin finds a few transactions earlier account balance from outputs?

(Asked by: username_0 on 2020-01-18)

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.

**Tags:** transactions


---

## 2 answers

### Answer by username_1 on 2020-01-18. Score: 0 | Accepted answer

> 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.

> **Comments:**
> **username_0**: Isn't storing an entire UTXOs set ineffective? I mean, there are millions of bitcoin accounts  
> **username_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.  

---

### Answer by username_3 on 2020-01-18. Score: 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).


---

