Wallet balances
Understanding how and where balances are stored in the Ledger
Keeping track of balances is the most important feature of the Ledger.
In our previous lesson you could see that the wallet
record doesn't actually hold any balance information.
Instead, it's located in the wallet-balance
record.
Getting balance
When we run minka wallet balances demo-bank-wallet
CLI command we see that we're sending wallet
handle. Also, the CLI returns the actual balance:
However, we already saw that this balance is not stored in the wallet record.
So where is it?
Getting wallet balance record
Let's request this same command with -v
verbose flag:
From the record luid
we can see that the ballance is stored in wallet-balance
record:
And the amount is expressed in fractions of the currency. This was defined during the creation of new currency through symbol
record in one of the earlier lessons.
Updating balances
When we create a new intent
(for example - type transfer
), Ledger will check whether there are sufficient balances.
If a transaction is valid, the balances will be updated. If not, the transfer will fail.
Also, whenever the amount is changed, this change must also be signed. This ensures the integrity of the balances.
You can see the history of all signatures in the proofs
array.