Please tell me how Wallet displays my balance [SOLVED]

I want to know the function of wallet.

Is the balance displayed in Wallet because it always keeps historical transaction data?
Or are you searching all past blocks every time and calculating the current balance from transactions related to my address?

If Wallet holds past transactions related to me or my balance, I do not think that non-tampering is not guaranteed.
However, it is difficult to refer to past transaction data every time because of speed and load problems.

I believe that Wallet has only private keys.
Then, where is the balance associated with that private key?

Hello,
Only your private key (encrypted with password), account name, address book (probably also some minie data) are stored.
Balance, transactions are fetched from node you have selected (click circle in top right corner to see what node are you using). Nodes store entire blockchain. Wallet get data from node using exposed by node http api.

Thank you for your reply.

Every time Wallet opens, it searches for transactions of his past transaction every time and calculates the current balance?
As time goes on, I think that it will take more time to search past transactions and calculate balance as block height gets bigger.

But in reality it is not a problem.
Is there anything devised?

No. Node returns already calculated balance.

Thanks pawelm,

That means that the node returns the calculated balance for inquiries from Wallet.
In other words, I think that I calculate every time at the node.

So, as the block height increases in the future, does the response time of the balance reference increase?

I learned that Bitcoin uses a mechanism called UTXO,
I learned that NEM and Ethereum can check the balance on account base.

Does this mean that the account always has a calculated balance and is updated each time a related transaction occurs?

So where is the calculated balance recorded?
Is the balance for each account recorded in the block?

How about mosaics?

Not sure how it’s implemented exactly. But blockchain is immutable so node can store calculated balance (also mosaic balance) and update it only based on new blocks.
This allow do it in efficient way.

Tech ref tell a little bit about it (for example point 2.1) https://nem.io/NEM_techRef.pdf

Many thanks pawelm.

I think that it is efficient, too.
I will read NEM_techRef.

Once again, thank you.