Cryptocurrency
Where are the user's bitcoins actually stored?
It seems like what's called for here is a basic explanation of two of Bitcoin's big concepts: the wallet and the blockchain:
- A "wallet" is a collection of ECDSA keypairs. For those not familiar with cryptography, a keypair consists of a "public key" and a "private key" which can be used to encrypt or sign bits of data. The public key, as the name suggests, is known to everyone and can be used to encrypt messages in such a way that the holder of the private key alone may decrypt them. The private key may also be used to sign messages in such a way that anyone holding the public key may verify that the message truly came from you. Every Bitcoin address consists of such a keypair - the "address" you send people is the public half and the private half resides in your wallet.dat file.
- The "blockchain" is a constantly growing database of transaction information which is sent out to all nodes in the Bitcoin network. When you perform a transaction, that transaction is distributed to the network and assuming the transaction is valid, will be included in the next "block." This is where the coins themselves are stored. When you initiate a transaction, all previous transactions to or from that address are scanned and a balance is calculated. If your transaction exceeds this available balance, it will be rejected by the network and will not be included in a block.
It's also important to note that the blockchain technically doesn't store "coins" it stores transaction information. The coins themselves are not discrete things which need storage - when coins are mined the miner's balance is credited via a "generate" transaction which adds to his or her available balance. When coins are sent from A to B, that transaction subtracts from A's balance and adds to B's balance. This is similar to the way that your employer may, via EFT, send "money" to your bank and you can use your debit card to spend that "money" in a store, all without anyone ever seeing a discrete physical dollar bill. Most money in the world today exists merely as transaction histories and balances - Bitcoin is no exception.