Bitcoin mining works by computers repeatedly hashing a candidate block’s 80-byte header with double SHA-256, changing a number called the nonce each time, until the result falls below a target the network sets. The first miner to find such a hash broadcasts the block and claims the new-coin subsidy plus the transaction fees inside it.

That is the whole mechanism in two sentences. The rest of this piece is how bitcoin mining works in detail: what goes into a block, what the hash has to beat, how the target moves, and how the reward is fixed. It is written as an evergreen explainer, not a news story. The rules it describes are long-standing consensus code, and every constant below is read from Bitcoin Core’s own source rather than from another explainer.

What is bitcoin mining, in one paragraph?

Mining is how new blocks get added to Bitcoin’s chain, and how new coins enter circulation. Anyone running mining software competes to produce the next block. The competition is a lottery weighted by computing work: there is no clever shortcut, only guesses, and each guess costs energy. Whoever wins writes the next page of the ledger and pays themselves a reward that the rest of the network will only accept if it obeys the rules.

The code describes this in a comment of its own. Bitcoin Core’s block header file says that nodes “collect new transactions into a block, hash them into a hash tree”, and “scan through nonce values” to satisfy proof-of-work. That is the job, in the developers’ words.

How is bitcoin mined, step by step?

1. Gather transactions into a candidate block

A miner takes waiting transactions and puts them in a block. The first transaction is special: it is the coinbase transaction, which creates new coins and pays them to an address the miner chooses. Blocks are size-limited; Bitcoin Core’s consensus header sets MAX_BLOCK_WEIGHT{4'000'000}, citing BIP 141, so a miner cannot simply include everything.

2. Build the block header

The transactions are hashed into a tree, and the top of that tree (the Merkle root) goes into a short header. This desk read Bitcoin Core’s primitives/block.h on 23 October 2026. The header class holds six fields: nVersion, hashPrevBlock, hashMerkleRoot, nTime, nBits and nNonce. The previous block’s hash is what chains blocks together; nBits is the target in compact form; nNonce is the number the miner is free to change.

3. Hash the header, over and over

The miner hashes the header. Bitcoin Core’s hash.h describes the class it uses as “Bitcoin’s 256-bit hash (double SHA-256)”, meaning SHA-256 is run twice. The output looks random, and changing one bit of the input changes the whole output. So the only way to get a hash that meets the target is to try a value, check it, and try again.

4. Change the nonce, and more, when it runs out

nNonce is a 32-bit unsigned field, so it holds about 4.29 billion values (2 to the power of 32). A miner can exhaust that range quickly. When it does, it has to change something else in the header to get a fresh set of guesses: for instance the timestamp, or the coinbase transaction, which changes the Merkle root. That is our reading of the header fields rather than a line of code we quote.

5. Beat the target, broadcast, collect

When a hash comes out numerically low enough, the block is valid. The miner broadcasts it, other nodes check every rule, and if it passes they build on top of it. The coinbase payment is now on the chain, though it is not yet spendable (see the maturity rule below).

What does the hash have to beat?

The target is a 256-bit number. A lower target means fewer valid hashes, which means more guesses on average, which means more work. “Difficulty” is the everyday name for how low the target currently sits.

There is also a floor on how easy it can ever get. Bitcoin Core’s mainnet parameters set powLimit to a value that begins with eight hexadecimal zeros (00000000ffff…). Read as arithmetic, that means even at the easiest permitted target a valid block hash starts with at least 32 zero bits. This desk did not read the live target.

Bitcoin’s mining constants, read from Bitcoin Core

This desk read the following files on Bitcoin Core’s master branch on GitHub on 23 October 2026: chainparams.cpp, consensus/params.h, validation.cpp, pow.cpp and consensus/consensus.h. These are mainnet values. We name no release version, because we read the source as of this writing, not a tagged release.

RuleLine in the codeWhat it means
Halving intervalnSubsidyHalvingInterval = 210000 (chainparams.cpp)The subsidy halves every 210,000 blocks
Target block spacingnPowTargetSpacing = 10 * 60 (chainparams.cpp)600 seconds: one block every ten minutes, on target
Target timespannPowTargetTimespan = 14 * 24 * 60 * 60; // two weeks (chainparams.cpp)1,209,600 seconds per retarget period
Retarget intervalnPowTargetTimespan / nPowTargetSpacing (params.h)1,209,600 / 600 = 2,016 blocks
Retargeting onfPowNoRetargeting = false (chainparams.cpp)Mainnet difficulty does adjust
Retarget clampnPowTargetTimespan/4 and nPowTargetTimespan*4 (pow.cpp)One step can make mining at most 4x harder or 4x easier
Starting subsidynSubsidy = 50 * COIN (validation.cpp)50 BTC per block at the start
Halving methodnSubsidy >>= halvings (validation.cpp)Binary right shift on whole satoshis
Subsidy endif (halvings >= 64) return 0 (validation.cpp)Zero once halvings reach 64
Reward capblockReward = nFees + GetBlockSubsidy(...) (validation.cpp)Coinbase may claim subsidy plus fees, no more
Coinbase maturityCOINBASE_MATURITY = 100 (consensus.h)New coins are spendable only after 100 more blocks

Ten minutes and two weeks are targets, not promises. The code steers toward them; it does not guarantee them.

How does the bitcoin difficulty adjustment work?

Every 2,016 blocks, each node recalculates the target. The pow.cpp comment is blunt: “Only change once per difficulty adjustment interval”. At the boundary, the code goes back to the first block of the window (“what we want to be 14 days worth of blocks”, in its own comment) and measures how long the window actually took using the blocks’ timestamps.

Then it scales. The new target is the old target multiplied by the actual time and divided by the two-week target. If the window took one week, the target halves and mining gets twice as hard. If it took four weeks, the target doubles and mining gets twice as easy.

The clamp stops wild swings. Before scaling, the code forces the measured time to no less than a quarter of two weeks and no more than four times two weeks. So a single retarget can move difficulty by at most a factor of four in either direction, and the result can never be easier than powLimit.

A worked retarget, using the code’s own formula

Take a window of 2,016 blocks that arrived in 12 days instead of 14. The new target is the old one times 12/14, about 0.857 of it, so the network needs roughly 14/12, or about 1.17 times, as many guesses per block: difficulty rises by about 17%. Now take a window that arrived in two days. The clamp replaces two days with three and a half (a quarter of 14), so the target falls to a quarter of its old value and no further, however fast the blocks came. Those are illustrations of the arithmetic, not readings of any real retarget.

This feedback loop is why block times hover near ten minutes whatever happens to total mining power. Add machines and blocks come faster, so the next retarget makes them harder; machines switch off and the reverse happens.

What is a bitcoin halving?

A halving is the block at which the subsidy drops by half. Bitcoin Core does not schedule it by date. validation.cpp divides the block height by 210,000 to count halvings, then shifts 50 BTC right by that count. The code’s own comment says this “will occur approximately every 4 years”, which is 210,000 blocks at ten minutes each, give or take the real block times.

The schedule, as arithmetic on that code (no dates are claimed):

HalvingsBlock heightsSubsidy per block
00 to 209,99950 BTC
1210,000 to 419,99925 BTC
2420,000 to 629,99912.5 BTC
3630,000 to 839,9996.25 BTC
4840,000 to 1,049,9993.125 BTC
51,050,000 to 1,259,9991.5625 BTC

The code alone cannot say which row the chain is on today; that takes the current block height, which this desk did not read for this piece. Amounts are counted in satoshis, so each shift rounds down; our satoshis explainer covers where the 100,000,000-per-coin figure is defined and why the 21 million cap is a ceiling rather than a count.

How does the miner actually get paid?

The winning miner pays itself in the coinbase transaction. It cannot pay itself whatever it likes. validation.cpp adds the block’s fees to the subsidy for that height, and if the coinbase pays out more than that sum the block is rejected with the error “bad-cb-amount” (“coinbase pays too much”). Every other node runs the same check, which is why a miner who cheats wastes the work it spent.

The coins are also locked for a while. consensus.h says coinbase outputs “can only be spent after this number of new blocks”, and the number is 100. If the block is later orphaned by a competing chain, those coins never mature.

What is a mining pool?

The consensus code this desk read has no concept of a pool. It pays whoever the coinbase names. A pool is an arrangement outside the protocol: many miners hash on the same candidate block, the coinbase pays the pool, and the pool shares the reward among participants by its own terms. That smooths out the lottery for each member without changing the odds for the group. Coin Brief names no pools here and makes no claim about any pool’s regulatory status, because none was checked.

Why can’t a miner fake the work?

Because checking is cheap and finding is expensive. A miner may need billions of guesses to find a qualifying hash, but any node can confirm the winner with a single double SHA-256 of the 80-byte header and a comparison against the target in nBits. Change any transaction and the Merkle root changes, the header changes, and the hash no longer qualifies, so the work has to be done again. Each header also carries the previous block’s hash, so rewriting an old block means redoing every block after it. That asymmetry, not any authority, is what makes the ledger hard to rewrite.

How is mined bitcoin taxed in the UK?

HMRC’s Cryptoassets Manual covers mining at CRYPTO21150, which this desk read on 23 October 2026. It says whether mining amounts to a taxable trade “depends on a range of factors”, listing degree of activity, risk and commerciality among them. If it is not a trade, the sterling value of the tokens when received is taxable as miscellaneous income, with appropriate expenses reducing the amount chargeable. Keep the coins, and you “may have to pay Capital Gains Tax” when you later dispose of them.

That is HMRC’s internal guidance, not statute. Our UK mining legality piece goes further into tax, electricity theft and the FCA, and spending mined coins later is a disposal in its own right, as our guide to buying things with bitcoin sets out.

Questions readers ask

How long does it take to mine 1 bitcoin?

There is no fixed answer, because nobody mines a bitcoin on its own. The network targets one block every 600 seconds, and the subsidy per block halves every 210,000 blocks. At a 3.125 BTC subsidy, the network as a whole issues one bitcoin of subsidy every 3.2 minutes on target. A single miner’s share depends on its slice of all hashing.

HMRC’s mining guidance, which this desk read for this piece, deals with how mining is taxed: as trade income or miscellaneous income, with Capital Gains Tax possible on a later disposal. Our separate legality explainer covers lawfulness, electricity theft and the FCA in detail.

Can you mine bitcoin on a normal computer?

The consensus code does not check what hardware produced a hash, so any computer can run the arithmetic. The catch is the retarget: difficulty follows the speed of every miner on the network, and your chance of finding a block is your share of the total. Coin Brief prints no hardware or electricity figures, because none were read for this piece.

What happens when all bitcoins are mined?

The subsidy does not stop with a bang. Bitcoin Core halves 50 BTC by a binary shift every 210,000 blocks, so it falls to one satoshi and then to zero from block 6,930,000 on that arithmetic. After that, the code still lets the winning miner claim the fees in the block, so fees become the whole reward.

Worth saying plainly: understanding how mining works is not a reason to start. Crypto assets are high risk, mining costs real money in hardware and power, and nothing here is advice or a profitability claim. How your own mining is taxed is a question for HMRC or a qualified adviser.