Bitcoin Transactions for Mere Mortals

Posted in: Archive
October 11, 2014 1:34 AM UTC

Even though, terms like ‘mining’ and ‘blocks’ are used in Bitcoin they may not be the best metaphors. For practical users, Bitcoin is better thought of as a network of private accountants. The accountants compete against one another in the world’s fastest guessing game to maintain a ledger. When an accountant makes a correct guess they get to write a new page and receive a wage.

The Bitcoin protocol enforces strict rules on the accountants. New pages follow a template. The accountant records a little “for office use only” information and fills the rest of the page with Bitcoin transactions from users around the world.

Also read: How a Bitcoin Transaction Works

One of the biggest misconceptions is that someone sends bitcoins. When Alice sends Bob bitcoins, she’s actually sending Bitcoin transactions to all of the accountants. A transaction is a set of instructions. Alice’s client includes ledger ‘receipts’ that prove she previously received bitcoins. Bob is the a recipient in the transaction; his address is the output. When one of the accountants write a new page in the ledger they transfer Alice’s balance to Bob. If the amount of coins moving to Bob is less than the total of Alice’s receipts, her client will generate a new address and include it with the output to receive the change.

Not all Bitcoin Transactions are Created Equal

On January 3rd at 18:15:05 GMT Satoshi generated the Genesis Block. When Satoshi first started mining in 2009, he was the only accountant on the network. Every hash on Satoshi’s CPU was a guess in the game. Of course, the Bitcoin block chain is the accounting ledger, miners the accountants and blocks are the pages in the ledger.

Though we say mining creates new bitcoins, transactions are how bitcoins are created and change ownership. Bitcoin transactions contain two lists, inputs and outputs. Inputs are previous transactions sent to your wallet. Outputs are the instructions for sending the input balance to new addresses. If the total output is less than the total input, the remainder is given to the miner as a tip.

The first line of every new block contains a generation transaction. The input of a generation transaction is the coinbase and ignored. Because the generation transaction’s coinbase lists no inputs bitcoins are created from nothing. This is the reward to the miner who submits the block. A block is not valid without this transaction. The output of the first transaction lists the miner’s Bitcoin address as the recipient of the block reward. That requirement is the synergy between mining and transactions being responsible for creating new bitcoins.

The first user-to-user Bitcoin transaction was Satoshi Nakamoto sending Hal Finney 10 BTC. Because Satoshi’s wallet contained nothing but 50 BTC block rewards, Hal’s address receives 10 BTC and Satoshi’s client generated a new key pair and transferred the remaining 40 BTC in change to his new address. Over 92,000 blocks later Hal created a transaction to spend those coins and sent them to a new address. This method of referencing previous Bitcoin transactions is the manner within which all bitcoins can be traced forward and back through the block chain.

Under the Hood

When Satoshi told his client to send Hal 10 BTC his input transaction was the block reward he received for mining block 9. It could have been a previous transaction where they received bitcoins from someone else but those transactions did not exist yet. His client built the transaction with his signature and public key attached so the miners could verify Satoshi’s transaction.

Miners check that the public key hashes to the address and that it matches the signature. The checks prove the creator of the transaction owns the keys to that address. If the Bitcoin transaction is valid, it waits to be added to the next block. After a transaction is recorded, it receives its first confirmation. For each block mined afterwards the transaction receives another confirmation.

Merchants and exchanges require confirmation time minimums to protect against double spending. Although Bitcoin solves many of the double spending problems of digital currency, there are still three major ways to double spend coins.

Race the Network
Send out competing transactions that send the same inputs to different outputs.

Finney Attack
Withhold a block and include your transaction. Release a competing transaction before broadcasting the block

51% Attack
A miner with vast resources sends out a transaction and begins mining a separate chain. In the separate chain, they spend a competing transaction. If the attacker’s chain is longer than the public chain, it can be released to the wild and overtake the public chain and undo the transaction.

There is no correct number of confirmations to wait before a transaction is ‘confirmed.’ The ability of an attacker to undo past transactions with a 51% becomes more difficult with time.

This has been a high-level view of how Bitcoin transactions work within Bitcoin. There are much more advanced features not listed here worth checking out. For me, the most important take-away responsible for sparking my interest in Bitcoin was learning that bitcoins, technically, don’t exist, and of the true power of the block chain to achieve a distributed consensus. Bitcoin Transactions are one of the most important ways data is moved across the Bitcoin Network.

Images from Shutterstock.

Last modified: June 13, 2020 9:34 PM UTC

Show comments