A Bitcoin transaction involves multiple steps that happen behind the scenes after users press the ‘send’ button:
- Creating a new unique Bitcoin address.
- Submitting the payment.
- Verifying the transaction.
- Encoding the information in a new block.
- Validating payments using only unspent transaction outputs (UTXOs) as inputs.
For a deep dive into Bitcoin itself, read What Is Bitcoin? A Complete Guide for Crypto Beginners.
The Behind-the-Scenes Bitcoin Transaction Process
Let’s introduce Bitcoin transaction procedures with the following scenario:
Bob, an online merchant, decides to accept Bitcoin as payment.
Alice, a buyer, has bitcoins and wants to purchase merchandise from Bob.
Wallets are files that provide access to multiple Bitcoin addresses. An address is a string of letters and numbers, such as: 1HULMwZEPkjEPech43BeKJL1ybLCWrfDpN. Each address has its own balance of bitcoins, and users can create as many addresses as they want. Imagine the addresses as bank accounts that work a bit differently.
Creating a New Address
Bitcoin client software generates Bitcoin addresses for users. When Bob creates a new address, what he’s really doing is generating a ‘cryptographic key pair’, composed of a private key (which only the user knows) and a public key (which is known to anyone).
When signing a message with a private key, it can be verified by using the matching public key. Bob’s new Bitcoin address represents a unique public key, and the corresponding private key is stored in his wallet. The public key allows anyone to verify that a message signed with the private key is valid.
Submitting a Payment
Alice’s wallet holds the private keys to each of her addresses. She tells her Bitcoin client that she’d like to transfer bitcoins to Bob’s address. The Bitcoin client then signs her transaction request with the private key of the address she is transferring bitcoins from. Anyone on the network can now use the public key to verify that the transaction request is actually coming from the legitimate account owner.
In other words:
The public key is used to receive bitcoins.
The private key is used to sign transactions to spend those bitcoins.
When spending bitcoins, the current owner presents their public key and digital signature in a Bitcoin transaction. The transaction is digitally signed by a private key, which indicates the authorisation to spend the funds referenced by the transaction.
With the public key and the digital signature, everyone in the Bitcoin network can verify and accept the transaction as valid, confirming that the person transferring the bitcoins had owned them at the time of the transfer.
How Miners Make Money: Miner Awards for Verifying Transactions
Assume Gary, Glenn, and George are Bitcoin miners. Their computers bundle the transactions of the past 10 minutes into a new transaction block. Each block includes a ‘coinbase’ transaction that pays out 50 bitcoins to the winning miner — in this case, Gary. A new address is created in Gary’s wallet with the balance of newly minted bitcoins.
Additionally, miners are awarded the fees paid by users sending transactions. The fee is an incentive for the miner to include the transaction in their block.
- The transaction is broadcast on the Bitcoin network, where each participant validates and propagates the transaction until it reaches almost every node in the network.
- The transaction is verified by a mining node and included in a block of transactions that is recorded on the blockchain.
- Once recorded on the blockchain and confirmed by sufficient subsequent blocks, the transaction becomes a permanent part of the Bitcoin open-distributed ledger and is accepted as valid by all participants.
- The bitcoins received by the new owner as a part of the transaction can then be spent in a new transaction.
Encoding Information in a Block: Cryptographic Hashes
It is the cryptographic encoding that makes blockchain so secure, where cryptographic hash functions transform a collection of data into an alphanumeric string with a fixed length, called a hash value.
Even tiny changes in the original data will drastically change the resulting hash value. It’s essentially impossible to predict which initial data set will create a specific hash value.
To create different hash values from the same data, Bitcoin uses nonces. Changing the nonce results in a widely different hash value.
The mining computers calculate new hash values based on a combination of the previous hash value, the new transaction block, and a nonce. Creating hashes is computationally trivial, but the Bitcoin system requires the new hash value to have a particular form — specifically, it must start with a certain number of zeros.
The miners have no way to predict which nonce will produce a hash value with the required number of leading zeros. So they are forced to generate many hashes with different nonces until they happen upon the one that works.
But Where Is Alice’s Transaction in the Nonce?
In the meantime, Alice’s transfer to Bob gets buried beneath other, more recent transactions. For anyone to modify the details, they would need to redo the work that Gary did — as any changes would require a completely different winning nonce — and then redo the work of all the subsequent miners, which is nearly impossible.
Unspent Transaction Output (UTXO)
Before introducing unspent transaction outputs (UTXOs), we need to know the input and output of Bitcoin transactions.
An input is a reference to an output from a previous transaction. All of the new transaction’s input values (the total coin value of the previous outputs referenced by the new transaction’s inputs) are added up, and the total (less any transaction fee) is completely used by the outputs of the new transaction.
Often, a transaction includes multiple inputs.
An output contains instructions for sending bitcoins. A transaction output includes the value that this output will be worth when claimed.
Unspent Transaction Output (UTXO)
Because each output of a particular transaction can only be spent once, the outputs of all transactions included in the blockchain can be categorised as either unspent transaction outputs (UTXOs) or spent transaction outputs. For a payment to be valid, it must only use UTXOs as inputs.
The figure above shows the main parts of a Bitcoin transaction. Each transaction has at least one input and one output, and each input spends the satoshis paid to a previous output. Each output then waits as a UTXO until a later input spends it. When a user’s Bitcoin wallet indicates a balance of 10,000 satoshis, it actually means they have 10,000 satoshis waiting in one or more UTXOs.
UTXO During Transactions
Imagine someone used the address 1HULMwZEPkjEPech43BeKJL1ybLCWrfDpN to receive bitcoins twice before. The transaction on 5 February 2019 contains 4,000 satoshis, and the transaction on 9 March 2019 contains 6,000 satoshis. Bitcoin’s blockchain will not help them add up the balance such that there exists a record with 1HULMwZEPkjEPech43BeKJL1ybLCWrfDpN: 10,000. Instead, every time a user wants to spend their bitcoins, they must unlock those transactions that belong to them (with bitcoins sent to their public key) one by one.
For example, to send 3,000 satoshis, one need only to unlock either the transaction dated 5 February 2019 or the transaction dated 9 March 2019 since both of them contain larger than 3,000 satoshis.
But to send 8,000 satoshis, both transactions need to be unlocked to spend all the bitcoins in a new transaction since partial spending is not allowed; the user must use all bitcoins they have unlocked. If they intended to send only 8,000 satoshis, they still need to spend 10,000 satoshis in the new transaction, then send 2,000 satoshis back to an address that belongs to them.
Final Words — Paying With Bitcoin
While Bitcoin transactions work seamlessly, real-life retail payments with BTC are still hampered by slow transaction speeds. Yet, making actual payments with Bitcoin is one of the key functionalities of BTC that Satoshi Nakamoto envisioned in the Bitcoin white paper. Bitcoin’s Layer-2, termed the Lightning Network, currently provides a solution to this scalability problem.
Read more about making near-instant payments with Bitcoin through the Lightning Network.
Due Diligence and Do Your Own Research
All examples listed in this article are for informational purposes only. You should not construe any such information or other material as legal, tax, investment, financial, or other advice. Nothing contained herein shall constitute a solicitation, recommendation, endorsement, or offer by Crypto.com to invest, buy, or sell any digital assets. Returns on the buying and selling of digital assets may be subject to tax, including capital gains tax and/or income tax, in your jurisdiction or the jurisdictions in which you are a resident for tax purposes. Any descriptions of Crypto.com products or features are merely for illustrative purposes and do not constitute an endorsement, invitation, or solicitation.
Past performance is not a guarantee or predictor of future performance. The value of digital assets can increase or decrease, and you could lose all or a substantial amount of your purchase price. When assessing a digital asset, it’s essential for you to do your own research and due diligence to make the best possible judgement, as any purchases shall be your sole responsibility.