47

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
  • 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
    Commented Jan 17, 2018 at 6:34

8 Answers 8

59

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.

9
  • 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
    Commented Nov 6, 2013 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
    Commented Mar 11, 2014 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. Commented Mar 14, 2014 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
    Commented Feb 6, 2018 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
    Commented Feb 6, 2018 at 16:06
14

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.

12

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.

3
  • Great explanation. Tx! Commented Dec 19, 2013 at 5:40
  • What happens when you lose your wallet.dat file?
    – nbkhope
    Commented Dec 1, 2017 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.
    – Matthew
    Commented Jul 27, 2018 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.

6
  • 2
    Where is that block-chain database stored?
    – Alex
    Commented Oct 17, 2011 at 19:43
  • 2
    A copy of it is stored on every computer running the Bitcoin software. Commented Oct 17, 2011 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
    Commented Oct 17, 2011 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. Commented Oct 17, 2011 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. Commented Oct 22, 2011 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.

0

A Bitcoin (BTC) is not a physical object. Conceptually speaking we can say that BTC (in the digital world) is somehow like water in the physical world. Just like there is a finite amount of water on earth there is a finite amount of BTC on the Blockchain. Just like a water quantity can be split into its smallest quantum (an H2O molecule), a quantity of BTC can be split into its smallest quantum, a Satoshi (0.00000001 BTC). A quantity of BTC is represented by a number, such as 3,728BTC. So, if a number can represent some BTC then all that is required to store some BTC is the ability to record a number. In the digital world you store information in files. Hence, Bitcoins are literally stored into files. What these files contain are (amongst other information) a whole bunch of addresses to which are sequentially attached a number, the actual amount of BTC to a specific address.

A Block is a bunch of addresses with its corresponding number ( the amount of BTC) that has been verified by miners. The Block is "locked", approved and spread over all the Blockchain nodes around the world. That newly created (approved) Block is then attached at the end of the Blockchain in every nodes. Once this action is done it is irreversible (according to the Bitcoin Algorithm, which is the consensus amongst all nodes).

So, where are the user's Bitcoin actually stored? They are stored in the approved Blocks part of the single one and only version Blockchain, which a copy exist in every computer running a node around the world.

When you want to "spend" some BTC for a purchase of some kind, you need your unique private number to open the possibility to change the amount of BTC attached to a particular address such that this amount is allowed to be transferred into another address (the recipient address). All these number are what's recorded in the upcoming new Block, the one that will include your newly created transaction.

This whole strategy is described with words that find parallel in the physical world, such as wallet, money, account, and more. All these concepts are digitally represented in the numbers stored in those files called Blocks.

2
  • 1
    While the general gist is right, this answer is oversimplifying. "Quantities of BTC" are stored in utxo, they are a bit more than just an address and a number, most notably there is a cryptographic lock to spending. Also, blocks are not irreversible. The chaintip is always probabilistic. A block could be overtaken by a competing chaintip and end up not being part of the best chain. Check out the tag chain-reorganization to read more.
    – Murch
    Commented Sep 21, 2020 at 19:51
  • Good point Murch. Thanks for the comment. My intention was to offer a view that would have helped me back when I was first introduced to cryptocurrencies. I wish someone could have explained it as such. It would have saved me hours of research. Commented Sep 27, 2020 at 19:52

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