Wallet and User Account in Several Cryptocurrency Systems - Bitcoin
We will first take a look on Bitcoin wallet.
Bitcoin Network and Bitcoin Wallet
Here is a brief introduction about Bitcoin network. Bitcoin network maintains a public ledger, which keeps all the transactions since day one. These transactions, after validation by miners, are recorded in the ledger. Once recorded, the transaction detail cannot be modified, and the ledger keeps growing with all upcoming transactions.
Inside the ledger, there is a concept called Unspent Transaction Outputs (UTXOs). UTXO is a mapping between an address and amount of bitcoins. Here we first see the term “address”.
For example, here is a simplified scenario: we only have several UTXOs in the ledger, corresponding to two addresses. From now on, for sake of simplicity, we take out public key part, but let’s keep in mind a public key is in between.
These UTXO can only be accessed and used by someone who owns the private keys that can generate the addresses. In our case,
- Alice’s wallet holds the private key #1, which generates address #1. Therefore Alice will see 0.5 BTC in her wallet.
- Bob’s wallet holds the private key #2, which generates address #2. Therefore Bob will see total 2.3 BTC as bitcoin wallet will locate all UTXOs associated to that address.
Let’s perform a transaction. Suppose Alice sends 0.3 BTC to Bob. If we ignore the transaction fee. Alice’s wallet will generate a new private key, and therefore a new address (let’s label them #3). The UTXO on original address #1 will be spent (no longer as UTXO). Two new UTXOs are created,
- address #2 0.3 BTC (this is the amount Alice sends to Bob)
- address #3 0.2 BTC (this is the remain after spending the original UTXO 0.5 BTC)
After this transaction is successfully included in the ledger, the UTXO now looks like this. As before, the wallet will locate UTXO that matches the addresses they are hold the corresponding private keys. In this case,
- Alice’s wallet shows 0.2 BTC (from address #3). Note that there is no need to delete the pair #1, as this address is still owned by Alice. Other can still send bitcoins any time to this address and Alice’s wallet will recognize the amount of bitcoins.
- Bob’s wallet shows 2.6 BTC (all from UTXOs associated to address #2)
Bitcoin wallet can have one or many private keys (and therefore addresses). Wallet explores the UTXOs from the ledger and collects the UTXOs associated to these addresses, and then presents the amount of bitcoin the wallet owner owns. The wallet itself can generate new private key - address pair when needed, such as in a transaction. The owner does not need to remember how many addresses he has owned so far: wallet will keep track for the owner.
Here is my Bitcoin wallet in Testnet.
The left hand side is my Bitcoin wallet, in which I see 1.89680120 BTC. As shown in the right hand side, this amount 1.89680120 BTC is composed of three UTXO. These three UTXO are held in two addresses, which my wallet is holding. My wallet may have more addresses, but UTXOs are only found on these two addresses.
Security on Bitcoin Wallet
Security in Bitcoin wallet means the security on the private keys. Once the private key is made known by someone, he can spend the bitcoin associated with that address.
As private keys are stored in wallet, it is therefore the wallet one needs to take care of. Wallet is responsible to create the randomness when generating private keys. And almost all wallets come with the mechanism like password protected, and provides backup / restore / export / import for backup and safety purpose.