Bitcoin Core (BTC) was created to function as peer-to-peer electronic cash. Whether you are spending or accepting BTC as payment it is prudent to understand how a transaction works. Bitcoin Core transactions are messages, like email, which are digitally signed using cryptography and sent to the entire Bitcoin Network for verification. Transactions are public and can be found on the digital ledger known as the blockchain.
The history of each and every BTC transaction leads back to the point where the bitcoins were first produced. (Update: Bitcoin Core is less usable as money due to much higher fees and delayed transaction times. The Core team has also expressed an interest in keeping these fees high since they view BTC as a "store-of-value" and not something to be transacted on a daily basis. In contrast, Bitcoin Cash's transaction fees cost pennies and payments can be validated even with zero confirmations. These facts make BCH the ideal cryptocurrency for sending and receiving money anywhere in the world.)
We define a bitcoin as a chain of digital signatures. Each owner transfers bitcoin to the next by digitally signing a hash of the previous transaction and the public key of the next owner and adding these to the end of the coin. A payee can verify the signatures to verify the chain of ownership.
— Satoshi Nakamoto, Bitcoin Whitepaper
It's worth mentioning here that Bitcoins (Bitcoin Core) do not "exist" per se. That's right! Those BTC in your wallet do not explicitly exist the way cash, coins, or even stocks do. There are no physical bitcoins anywhere—not on a hard-drive, or a spreadsheet, or a bank account, and not even a server somewhere. Think of the blockchain as a record of the transactions between various bitcoin addresses. These transaction records are updated by the Bitcoin Core network and shared across each of its nodes as balances increase and decrease. You can even use one of our block explorer if you want to see the history as well as current balance of any given BTC address.
Mark wants to send some bitcoin to Jessica. Essentially, a BTC transaction is comprised of three parts:
An input: This is a record of the BTC address from which Mark initially received the bitcoin he wants to send to Jessica.
An amount: This is the specific amount of BTC Mark wants to send Jessica.
An output: This is Jessica's public key; also known as her 'bitcoin address'
Sending BTC requires having access to the public and private keys associated with that amount of bitcoin. When we talk about someone "having bitcoins" what we actually mean is that person has access to a key-pair comprised of:
Public keys, also called a bitcoin addresses, are random sequences of letters and numbers that function similarly to an email address or a social-media site username. They are public so you are safe sharing it with others. In fact, you must give your Bitcoin Core address to others whenever you want them to send you BTC. The private key is another sequence of letters and numbers. However, private keys—like passwords to email or other accounts, are to be kept secret.
Never share your private key with anyone that you do not 100% trust to not steal from you, ever. Also, remember to backup private keys with pen and paper and store them somewhere safe. Your Bitcoin Core address is basically a transparent safe. Others can see what's inside but only those with the private key can unlock the safe to access the funds within. In our example transaction above, Mark wants to send some BTC to Jessica. To do this, he uses his private key to sign a message with the transaction-specific details. This message is then sent to the blockchain and contains an:
This transaction is then broadcast to the Bitcoin Core network where miners verify that Mark's keys are able to access the inputs (i.e. the address(s) from where he previously received BTC) he claims to control. This confirmation process is known as mining because it requires resource-intensive computational labor and rewards miners, in BTC, per block solved. This is also the process by which new Bitcoins are 'created'.
All Bitcoin Core transactions must be verified by miners on the blockchain. Note, miners do not mine transactions; they mine blocks which are collections of transactions. Sometimes your transaction gets left out of the current block and gets put on hold until the next one is assembled. The Bitcoin Core protocol dynamically adjusts requirements to have each block take approximately 10 minutes to mine. Another reason for long confirmation times is that blocks are limited to 1MB by the current Bitcoin Core protocol. This arbitrary limit can be increased but for the present it limits the amount of transactions that may enter a block which effectively slows down confirmation times and by extension, the entire Bitcoin Core network.
Although it would be possible to handle coins individually, it would be unwieldy to make a separate transaction for every cent in a transfer. To allow value to be split and combined, transactions contain multiple inputs and outputs. Normally there will be either a single input from a larger previous transaction or multiple inputs combining smaller amounts, and at most two outputs: one for the payment, and one returning the change, if any, back to the sender
—Satoshi Nakamoto, Bitcoin Whitepaper
Remember how BTCs only 'exist' as records of transactions on the blockchain? This means that sometimes multiple transactions end up being pinned to a particular Bitcoin Core address. Let's say you have 2 BTC in your wallet. These 2 BTC came from four different friends who each sent you .5 BTC for your birthday. For convenience, your wallet interface will display your holdings as, "2 BTC". But, your wallet did not 'add up' each of those .5 BTC inputs into 2 BTC within your wallet. Rather, your wallet just keeps track of the four .5 BTC transactions separately, which total 2 BTC. When you want to buy something with BTC your wallet uses transaction records of varying amounts that add up to the amount of bitcoin you wish to spend. Suppose that number is .25 BTC and you want to use it to buy clothes from a merchant. Based of the info above about your holdings, we know you don't have a single input with exactly .25 BTC. Bitcoin Core users cannot split a transaction into smaller amounts and only the entire output of a transaction can be spent. So, when you open your wallet and type, ".25" in the amount field what technically happens is that one of the .5 BTC transactions (from your generous friend, Chris) will be sent, in its entirety. The difference is then returned via a new transaction. Here is the technical process broken down:
But, your wallet actually creates two outputs for this transaction:
This might seem confusing— the good news is that knowing this stuff is not required to send or receive bitcoin.
Bitcoin Core transaction fees are calculated using a variety of factors. Many wallets allow users to manually set transaction fees. Any portion of a transaction that isn’t owed to the recipient or returned as 'change' is included as a fee. Fees go to miners and can be used to increase speed on confirmation by incentivizing miners to prioritize your transaction(s).
The relation between transactions, miners, and blocks is a fundamental aspect of the Bitcoin Core protocol. It is important to understand the basics of sending and receiving BTC so that things like confirmation time and fees make sense. (Update: Bitcoin Core is less usable as money due to much higher fees and delayed transaction times. The Core team has also expressed an interest in keeping these fees high since they view BTC as a "store-of-value" and not something to be transacted on a daily basis. In contrast, Bitcoin Cash's transaction fees cost pennies and payments can be validated even with zero confirmations. These facts make BCH the ideal cryptocurrency for sending and receiving money anywhere in the world.)