Post
Topic
Board Development & Technical Discussion
Re: wallet.dat encrypt by multiple users question
by
JohnB31
on 16/04/2018, 23:50:59 UTC
In fact it is even more complicated and i hope this will explain it a little bit more.
(Perhaps it makes it even more confusing.)
There is no balance in a wallet so it is not 100% correct to say you have 1000 in your wallet, however i will start talking so to explain it later.
If there is 1000 in a wallet and A wants to pay 100 to Z it is possible that A needs to sends 400:
 100 to Z, 295 to himself. and 5 as a fee for the miner.
The wallet does not contain 1000. The wallet only contains keys to unspent transactions.
Perhaps there are two keys to unspent transactions: an unspent 400 and a unspent 600. (This is only an example it can be more complicated.)
Perhaps the software decides to use the key to the unspent 400:
Z will get a key to unspent 100, a (new) key to unspent 295 is send back to the sender (A) and the miner will get a key to 5 (as a fee).
I don't know for sure if B, who had a copy the wallet.dat file, will also receive the key to the unspent 295 but i don't expect so.
If, in this example, the transaction is accepted :
- A will have in the wallet a key to unspent 600 and unspent 295.
- B will have in the wallet a key to unspent 600 and a key to 400 that is already spend.  
If now B wants to send 10 to Y only the key to the unspent 600 can be used. If he wants to pay a fee of 1 the wallet: 10 will be used for a key send to Y, 589 will be used for a key send back to B and 1 will be used for a key for the miner as a transaction fee.
After this next transaction
- A has in the wallet a key to 600 that is already spent and unspent 295. So he (or she) can still spend 295.
- B has in the wallet a key to 589 that still can be spend.
( Z has a key to 100 , Y has a key to 10, a miner has a key to 5 and a miner has a key to 1 )
( 295 + 589 + 100 + 10 + 5 + 1 = 1000 )