41

On the person's computer?

On bitcoin.org? :)

Where does that information reside that tells others and me how much bitcoins I have?

I assume it can't be on my PC because I could easily hack the file that contains that data and get myself more bitcoins, right?

  • 1
    All the crypto assets like Bitcoin, Ether etc are stored on the their respective blockchains. The information like your balance is stored on a particular block with other details like creation creation time etc, which can't be altered. The sites like live.blockcypher.com/btc , shows your balance using your public address. Anyone who knows your public keys can know your balance, transaction history as well. However with the access to the private keys, you claim that a particular public address belongs to you, which means you have the "rights" to control your funds(Transfer etc). – bitsabhi Jan 17 '18 at 6:34
51

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.

  • 2
    Excellent explaination, thanks. So you can really just store an offline backup of your wallet on a flash drive and you don't really need to run the wallet client actively until you want to make a transaction? – John Nov 6 '13 at 19:40
  • 3
    Are you sayng that every node on the bitcoin network contains the entire history of all transactions ever perfomed by bitcoin owners? Second, what is a "node"? Any computer with a bitcoin wallet? – Nilzor Mar 11 '14 at 8:15
  • 2
    It depends on what software you're using, actually. Way back when I wrote this answer there was really just the one wallet software and yes, it stored every single transaction ever. Today there are several options and not all of them store all data. Electrum, for example, runs thin clients which connect to servers that store the whole blockchain and many phone wallets only store blocks containing transactions that pertain to them. In general, however, it is considered preferable for each node (computer running software) to store everything. – David Perry Mar 14 '14 at 7:58
  • David, thanks, but there are several vague things i cant understand. I will list: 1) in case all transactions were stored in individual node/pc, so that person (pc holder) can open(view) that data and alter? (yes or no) 2) if he can alter the data, then what happens? the system checks if that data is same as the data what other thousands of nodes store? how it is validated I cant understand, if individuals could change the data... 3) where is the core host(server) or appliance, which gives you permission to reject or add transaction ("generate") to your account? who decides that? – T.Todua Feb 6 '18 at 15:53
  • 4) when transaction happens, where it is stored/updated at first? i.e. on someones node? and in the far side on the earth somewhere, on a node, that transaction update might happen after X seconds/minutes, and if during that time, another transaction happens by the same holder?? – T.Todua Feb 6 '18 at 16:06
12

The information is split. Some information is stored on your PC in the wallet file. Some information is stored in the public blockchain.

Stored in your wallet file is the list of accounts that you control and the secret key needed to spend coins sent to those accounts. Stored in the public blockchain (held on every computer running the Bitcoin client) is the record of every transaction ever made, including any transactions that sent you coins.

When you wish to spend your coins, you check the blockchain to find unspent coins sent to you (or mined by you). You compose a transaction that specifies which unspent coins in the block chain you wish to spend and what account(s) you wish to send those coins to. You can return any 'change' to an account you control. You use the keys in your wallet to sign the transaction.

You then broadcast that transaction to miners. They confirm that your transaction is valid, making sure it spends only coins that exist, are unspent, and that it has the proper signatures. They make sure that the number of coins coming out of the transaction is less than or equal to the number of coins claimed by the transaction. They then commit that transaction into a new block linked into the hash chain, and the transfer is complete.

8

Your coins are stored in addresses in the block chain. Thus your coins and my coins and everyone's coins are stored in every computer which makes up the Bitcoin network. The block chain contains every address in use, and every one that has ever been used along with how many coins are currently at that address.

This is why hacking your own client or wallet.dat isn't useful. Your coins aren't there they are everywhere.

For example you can lookup any of your (or anyone elses) addresses here and see the current value. http://blockexplorer.com/

So what keeps other people from spending YOUR coins?
Spending Bitcoins is to create a transaction moving it from one address to another.

To create a transaction requires that you cryptographically sign the transaction with the private key of the address containing the coins (the public key). Since there is a mathematical relationship between public & private keys the rest of bitcoin network can verify that the transaction is properly signed. The "coins" (technically public key addresses and their current value) can be seen by anyone but those coins can only be moved by the persons in possession of the private key.

Your wallet.dat file contains all your public private key pairs. Anyone in possession of you wall.dat file (and encryption passphrase) can sign transactions as the owner of those public addresses and thus has control over the coins. This highlights why you must always safeguard your wallet.dat and encryption passphrase.

This method of storing value is unique to Bitcoin (and subsequent copycat coins). To sum it up in a pair of sentences:

Your coins are stored in addresses (public keys), copies are made public and included in every node of the bitcoin network. However the security of those coins are ensured because only the person in possession of the matching private key can create a valid transaction to move them.

  • Great explanation. Tx! – Aniket Thakur Dec 19 '13 at 5:40
  • What happens when you lose your wallet.dat file? – nbkhope Dec 1 '17 at 6:56
  • @DeathAndTaxes "Coins" are not entities stored in the blockchain; they're just an abstraction on top of transaction info like balances. It's the tx info & balances where are stored in the blockchain and associated with addresses. – Matt Jul 27 '18 at 1:28
6

Your wallet.dat contains your keypairs that lets you use your coins. If you lose those, you will lose access to your money.

The actual coins, however, are encoded in the Blockchain. Each time you make a payment with your coins, you have to refer to the last time you made such a payment, so everyone can check if you balance is right. When making a payment, you specify both how many coins you are spending and how much coins you have left. If you manipulate your transaction and state a wrong value, people that will check your transaction will know and will reject it.

There is no place the coins are stored as you'd store physical currency. It is more like a bank balance - just a number. But since all transactions are transparent, everyone would know if you are trying to cheat.

  • 2
    Where is that block-chain database stored? – Alex Oct 17 '11 at 19:43
  • 2
    A copy of it is stored on every computer running the Bitcoin software. – Meni Rosenfeld Oct 17 '11 at 19:50
  • 1
    Blockchain is distributively stored by computers running the Bitocoin software. Most clients do not store the complete blockchain (as it is on the order of 1GB of size), but they store the transactions they are interested in (as in, the ones that have coins that belong to them and the newest blocks). Some clients, however, store the whole blockchain. So, everyone has some blocks, some people have all blocks, and there are multiple copies of the same block stored across the internet. – ThePiachu Oct 17 '11 at 20:27
  • ThePiachu, you're talking about a lightweight client which, to the best of my knowledge, has not yet been implemented. Currently all clients store the whole blockchain. – Meni Rosenfeld Oct 17 '11 at 20:46
  • 2
    Meni, it has been implemented but not in the main client. What ThePiachu is talking about is a "selfish client" as implemented primarily on mobile devices. BitcoinJ, the Java port of Bitcoin currently in use on mobile devices does in fact store only block headers and blocks containing transactions of interest. This has been the subject of at least one question though I'd love to see more - it's an interesting topic. – David Perry Oct 22 '11 at 15:09
3

Information on how many bitcoins belong to each address is stored on a data structure called "the block chain". A copy of this data exists on every node on the Bitcoin network (that is, every computer which has the Bitcoin client software installed has information about all bitcoins in existence). The block chain follows certain rules that make sure that even if one manages to hack most of the stored copies of it, he'll be unable to credit himself with more coins.

The information required to grant you access to the bitcoins owned by your addresses, is stored in the wallet.dat file on your computer. Stealing an unencrypted version of it allows stealing your coins, so it should be guarded (a wallet encryption feature has been recently added to the client, and even better security features are in the works).

1

Bitcoin tokens don't actually "belong" to addresses. The idea of an address is purely a convenient abstraction. Addresses don't truly have a balance (nor does the Bitcoin blockchain even understand that addresses exist), but referring to an address balance is simply a quick way to refer to the total sum of tokens stored in unspent outputs which the owner of a particular address has the ability to spend.

In Bitcoin (and similar UTXO-based blockchains), tokens are "stored" in unspent outputs. The sender of a transaction specifies the requirements that must be fulfilled in order for the transaction's outputs to be spent. Tokens that are "sent" to an address are actually just stored in an output which requires the spender to prove ownership of their address by providing the public key their address is derived from along with a valid signature of the new transaction they wish to create to spend the original output.

The minor distinction between addresses "storing" tokens and addresses being able to spend tokens stored in outputs is important, and allows the creation of more advanced types of transactions (such as P2SH which enables multisig, timelocked and hash-encumbered transactions which allow technologies like atomic swaps and payment channels to function, etc.)

0

In addition to the actual question and the answers posted, it's important to note that the concept of ownership is slightly different in Bitcoin. You don't actually "own" the coins you have, you merely have the right to "control" them however you please, as only you "own" the key to do so.

protected by Community Dec 18 '17 at 15:30

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.