07 / 736HASH

Mining

Bitcoin mining

How pending payments become a confirmed block, what miners get paid for, and why everyone else still needs to check their work.

Mining is the competition to add the next block to Bitcoin’s history. Miners assemble transactions into blocks and perform computational work to find a result that others can easily verify. A successful block can earn its miner newly issued bitcoin and fees from the included payments. Miners do not set the rules, however: other computers on the network independently check each proposal and reject invalid blocks.

Mining: operating result modelCompare an expected share of block subsidy with electricity costs at your chosen hashrate, power draw and pool fee.

Mining does not dig up coins hidden inside a computer. It is a competition to propose the next valid block: a batch of transactions extending the existing history. A miner searches for a computational result that is difficult to obtain for that proposal. Once successful, the miner sends the block to others. They check both the computation and the transactions, using the same rules to determine whether they can accept it. Newly issued bitcoin forms part of the reward for this work, but issuing coins is not mining’s only purpose. For someone making a payment, the important change is from a pending transaction to one recorded in a history that can be verified. [1] [2]

When you send a payment, it first spreads between nodes. A node is a computer participating in the Bitcoin network; its mempool is a local collection of unconfirmed transactions. There is no single queue managed for everybody. Miners build candidate blocks from the available transactions, taking account of fees and limited space. If a transaction spends an output from another unconfirmed transaction, that earlier transaction must come first in the block. The getblocktemplate command supplies information for building a block, including these dependencies. Block-weight limits and limits on signature-checking work also constrain the selection. [1]

A block’s first transaction is called the Coinbase Transaction. It has nothing to do with an account at the exchange of the same name: it is a special transaction through which miners assign themselves the permitted reward. That reward combines the block subsidy, newly created bitcoin, with the fees from the block’s other transactions. A fee is the difference between the value of a transaction’s inputs and outputs, so it only transfers existing bitcoin. If miners claim too much, nodes reject the entire block. Even a correct reward cannot be spent immediately: a Coinbase Transaction output can first be spent in a block 100 heights later. [2]

Imagine a lottery where nobody knows the winning result in advance, but everyone can quickly recognize it once published. Miners calculate a hash, a digital fingerprint of data that can also be read as a large number. For a Bitcoin block, that number must be less than or equal to a threshold called the target. This is the Proof of Work requirement. Specifically, the SHA-256 hash function is applied twice to the block’s 80-byte header, which holds its essential summary data. Miners are not solving individual payments. They change the data used in the calculation and test whether the new result meets the condition. [3]

An ASIC is a chip designed for a particular computational task; a Bitcoin mining ASIC repeatedly applies double SHA-256 to variants of an 80-byte header. One field miners change is the nonce, a four-byte number in the header. Its range is finite. Once exhausted, miners can change the extra nonce, additional data inside the Coinbase Transaction. This changes the Merkle Root, a combined fingerprint of the transactions, and then the header, opening up more candidates to try. No failed attempt brings the machine closer to a guaranteed win. Nor are ten minutes promised to an individual miner: that is the target average for the whole network. [3]

Miners have a reason to build valid blocks: a rejected proposal earns no usable reward. Their checks do not replace everybody else’s, though. A Full Node is a computer that independently verifies Bitcoin’s rules, including transactions, rewards and Proof of Work. It rejects a block that creates more bitcoin than permitted, for example, even if the miner invested substantial computing power. Running a node means a user need not rely on a miner’s claim that a block is sound. [2] [4]

A solo miner may wait a very long time for success. A Mining Pool lets participants share work and income. To estimate each machine’s contribution, the operator also accepts results meeting an easier internal target. Such a result is called a share. Most shares are insufficient for the Bitcoin network; only some also meet its stricter requirement. Payments to participants depend on the chosen payout model, agreed terms and pool fees. Working through a pool does not give miners the right to change Bitcoin’s rules. Nor must the operator own the connected machines. Its proportion of blocks found does not establish ownership of the equipment. [3]

After a successful calculation, the complete block still has to reach other nodes. Two miners may find different valid blocks extending the same predecessor almost simultaneously. Part of the network then briefly knows one branch, while another part knows the other. Nodes follow the valid branch with the greatest accumulated work, the sum of the work attributed to its blocks. The next block found can therefore tip the choice toward one branch. A block on the abandoned branch may itself be valid, yet its reward does not become part of the active history. Miners therefore care about propagating results quickly and avoiding further work on an outdated proposal after receiving a new chain tip. [4]

Hashrate measures hashing attempts per second. A miner’s share of the network’s total computing power helps estimate how often it might succeed, but guarantees no regular income. Income is not profit either: electricity, cooling, equipment, maintenance and pool fees must be deducted. Downtime can make the outcome worse. Watch the units as well: TH/s measures computing performance, while watts measure power consumption. A powerful machine can lose money when electricity is expensive, and one lucky find says little about long-term profitability. [3]

On your own node, you can compare a proposal from getblocktemplate with the header, Coinbase Transaction and ordinary transactions of a block that was actually found. Commands such as getblocktemplate belong to the node’s technical interface; they are not a service you must entrust with money. The submitblock command passes a completed block to a node for checking; successful local acceptance does not guarantee that it will permanently remain in the network’s history. At a pool, distinguish three things: submitted shares, accepted Bitcoin blocks and amounts actually paid out. Together with operating costs, these show how mining worked out economically. [5]

For the clearest picture, read this entry together with Proof of Work, Difficulty Adjustment, Block Subsidy, Transaction Fees, Mempool. The reverse links also lead from Proof of Work, Difficulty Adjustment, Block Subsidy, Halving.

DOC · 001Bitcoin Core v29.0: block assemblerPrimary DOC · 002Bitcoin Core v29.0: block validationPrimary DOC · 003Bitcoin Developer Guide: MiningPrimary DOC · 004Bitcoin whitepaperPrimary DOC · 005BIP 22: getblocktemplatePrimary
Revised: Source-first · No investment advice