Bitcoin network rules
Bitcoin Difficulty Adjustment Calculator
Enter how long the last difficulty period took and the current nBits. This page applies the Bitcoin Core retarget formula exactly: the target scales by measured time over expected time. Bitcoin Core clamps the measured timespan before it scales the target. The result is capped at the proof-of-work limit. Everything is computed in your browser from your inputs; the page does not fetch difficulty, hashrate or price data live.
The rules are for mainnet only. The testnet rules (fPowAllowMinDifficultyBlocks, BIP94) do not apply.
| Measured timespan used (after clamp) | 1,022,578 s |
|---|---|
| Timespan ratio actual / 1,209,600 s | 0.8454 |
| Current target (256-bit, hex) | 0x00000000ffff0000000000000000000000000000000000000000000000000000 |
| Next nBits (compact) | 0x1d00d86a |
| Target after retarget (256-bit, hex) | 0x00000000d86a0000000000000000000000000000000000000000000000000000 |
| Difficulty now | 1 |
| Difficulty after retarget | 1.1829 |
| Difficulty change | +18.29% |
| Expected hashes per block now (GetBitsProof) | 4,295,032,833 |
| Expected hashes per block after retarget (GetBitsProof) | 5,080,592,338 |
| Implied network hashrate at your interval | 7,158,388 H/s |
| Next retarget boundary block | 32,256 |
| Blocks until retarget | 1 |
The default inputs are the get_next_work vector from src/test/pow_tests.cpp: a period of 1,022,578 seconds (15.46% less than two weeks) starting from nBits 0x1d00ffff produces 0x1d00d86a, and block 32255 is the last block of that period.
Difficulty of 1 means the maximum target (powLimit, nBits 0x1d00ffff). GetBitsProof gives 4,295,032,833 expected hashes per block for it, which is close to but not equal to 232. The page computes 2256 / (target + 1) with integers for every valid nBits.
How this page calculates
Every 2,016 blocks Bitcoin Core retargets. The measured timespan is actual = time(block N+2015) − time(block N), with N = pindexLast->nHeight − 2015: 2016 blocks, 2015 intervals; clamped to [302,400 s, 4,838,400 s]. The new target is the old target times that clamped ratio, capped at the powLimit target 0x00000000ffff...ffffffff, and re-encoded through GetCompact. That is the whole retarget rule. A separate quantity is used for the hashrate: expected hashes per block (GetBitsProof) = 2²⁵⁶ / (target + 1), integer division. At nBits 0x1d00ffff that is 4,295,032,833, not exactly 2³². This page keeps the 256-bit target in big-integer form so the scaling is exact, and shows the floating-point difficulty readout separately because that is what the getdifficulty RPC prints. To turn an implied hashrate into revenue per machine, use the Bitcoin mining profitability calculator.
At a retarget boundary the new target must lie between old target / 4 and old target × 4, each capped at powLimit and rounded through GetCompact. Bitcoin Core uses this check in headers presync (src/headerssync.cpp). Consensus itself requires nBits to equal GetNextWorkRequired exactly (bad-diffbits in src/validation.cpp).
- target = (nBits & 0x007fffff) × 256^(size − 3), rounded down when size < 3, size = nBits >> 24. Not valid: sign bit 0x00800000, zero, overflow, or above powLimit (arith_uint256.cpp SetCompact, pow.cpp DeriveTarget).
- nBits = size × 2^24 + the top 3 bytes of the target, size = the byte length of the target. If those 3 bytes have bit 0x00800000 set, they move 1 byte right and size grows by 1 (arith_uint256.cpp GetCompact).
- difficulty = 0xffff / (nBits & 0x00ffffff) × 256^(29 − size) (rpc/blockchain.cpp GetDifficulty).
- new target = floor(old target × clamp(actual, 302,400, 4,838,400) / 1,209,600), capped at powLimit (pow.cpp CalculateNextWorkRequired, kernel/chainparams.cpp).
- projected actual = elapsed seconds × 2015 / (blocks mined − 1), rounded to whole seconds. This is a projection from your inputs, not a Bitcoin Core rule.
- expected hashes per block = floor(2²⁵⁶ / (target + 1)) (chain.cpp GetBitsProof).
- implied hashrate = floor(expected hashes per block / your block interval in seconds).
Sources, all from the Bitcoin Core v32.1 tag, fetched on 2026-10-30 (UTC):
- src/pow.cpp: GetNextWorkRequired, CalculateNextWorkRequired, PermittedDifficultyTransition, DeriveTarget.
- src/kernel/chainparams.cpp: mainnet powLimit, nPowTargetTimespan = 14 × 24 × 60 × 60, nPowTargetSpacing = 10 × 60.
- src/consensus/params.h: DifficultyAdjustmentInterval() = nPowTargetTimespan / nPowTargetSpacing.
- src/arith_uint256.cpp: SetCompact and GetCompact.
- src/chain.cpp: GetBitsProof.
- src/rpc/blockchain.cpp: GetDifficulty and the getdifficulty RPC.
- src/test/pow_tests.cpp: the four retarget test vectors.
- src/headerssync.cpp and src/validation.cpp: where the checks are used.
- Bitcoin Core download page: shows Latest version: 32.1.
The download page is not part of the v32.1 tag. It is listed to show that 32.1 is the latest release.
Worked example from the Core test suite
The period from block 30240 (2009-12-18 UTC) to block 32255 (2009-12-30 UTC) ran at the minimum difficulty, nBits 0x1d00ffff, and took 1,022,578 seconds, 15.46% less than two weeks. The retarget multiplied the target by 1,022,578 / 1,209,600 (about 0.8454) and re-encoded it as 0x1d00d86a, difficulty about 1.18. Enter those numbers above and the table reproduces the test vector.
- get_next_work: 0x1d00ffff, 1,022,578 s, new nBits 0x1d00d86a (no clamp, no cap).
- get_next_work_pow_limit: 0x1d00ffff, 2,055,491 s, new nBits 0x1d00ffff (capped at powLimit).
- get_next_work_lower_limit_actual: 0x1c05a3f4, 289,434 s clamped to 302,400 s, new nBits 0x1c0168fd.
- get_next_work_upper_limit_actual: 0x1c387f6f, 6,048,000 s clamped to 4,838,400 s, new nBits 0x1d00e1fd.
The first period (blocks 0 to 2015) took 2,055,491 seconds, but the target stayed at 0x1d00ffff because the powLimit cap applies, not the clamp.
Research disclosure
Written by Michael Lip.
The formula, constants and clamps on this page come from the Bitcoin Core v32.1 sources listed in How this page calculates, fetched on 2026-10-30 (UTC), and the four expected nBits vectors in src/test/pow_tests.cpp. The calculator reproduces all four vectors exactly.
A next difficulty on this page is a projection from your inputs. It is a model of the retarget formula, not a forecast of the market, and it assumes the block pace you enter holds for the rest of the period.