Fee math reference

Bitcoin Transaction Fee Calculator (sat/vB, vsize, USD)

At a fee rate in satoshis per virtual byte, Bitcoin Core computes the fee as that rate times the transaction's vsize, rounded up to the next whole satoshi. This page counts the inputs and outputs of a transaction by script type to get its weight and vsize, then converts your fee rate to satoshis, BTC and dollars. It also gives the dust limit of each output type. The rules come from Bitcoin Core v32.1 and BIPs 141, 144 and 341.

You enter the fee rate. This page does not give a current or recommended fee rate. BTC/USD = $80,154 from the mempool.space price API, price time 2026-10-29 05:00 UTC. The page does not fetch price or fee data live. Sources fetched 2026-10-29.

Calculate the fee

Inputs

P2PKH, P2SH-P2WPKH and P2WPKH input sizes depend on the ECDSA signature length. This page uses 107 bytes of signature and key data, the size that GetDustThreshold uses: a 72-byte signature with its sighash byte, a 33-byte compressed key and 2 length bytes. A 71-byte signature makes a P2PKH input 1 byte smaller and a P2SH-P2WPKH or P2WPKH input 1 witness byte smaller. A P2TR key path input uses a 64-byte signature (SIGHASH_DEFAULT). When an input has witness data, the transaction adds 2 bytes for the marker and the flag, and each P2PKH input adds 1 empty witness byte.

Outputs

562 weight units, 141 vB (base size 113 bytes, total size 223 bytes)

2,820 sats = 0.00002820 BTC ≈ $2.2603 at $80,154/BTC (price time 2026-10-29 05:00 UTC)

A $1.00 budget fits a fee rate of up to 8.843 sat/vB for a 141 vB transaction (rounded down to 0.001 sat/vB).

Common spend sizes

  • Legacy P2PKH spend, 226 vB. 1 P2PKH input, 2 P2PKH outputs. The input size depends on the signature length. This page uses a 107-byte scriptSig (2 push bytes, a 72-byte signature and a 33-byte key), the size in GetDustThreshold. A 71-byte signature gives 225 vB.
  • Segwit P2WPKH spend, 141 vB. 1 P2WPKH input (72-byte signature), 2 P2WPKH outputs. Weight 562 WU, 140.5 vB rounded up.
  • Taproot P2TR spend, 154 vB. 1 P2TR key-path input (64-byte signature), 2 P2TR outputs. Weight 616 WU.

How this page calculates

base_size = 4 (version) + 4 (locktime) + CompactSize(input count) + CompactSize(output count) + input base bytes + output bytes
total_size = base_size + 2 (marker, flag) + witness bytes + 1 per P2PKH input, only when an input has witness data. Else total_size = base_size
weight = base_size × 3 + total_size, vsize = weight / 4 rounded up one time for the whole transaction. Standard limit 400,000 weight units, block limit 4,000,000
fee_sats = ceil(sat/kvB × vsize / 1,000), sat/kvB = sat/vB × 1,000
dust if value < ceil(3,000 sat/kvB × (output_size + spend_size) / 1,000), spend_size = 148, or 67 for a witness program (P2WPKH, P2TR)

BIP 141 defines transaction weight as the base transaction size times 3 plus the total transaction size. It defines virtual size as the weight divided by 4, rounded up to the next integer. So a witness byte adds 1 weight unit and a base byte adds 4. Example: a transaction with 1 P2WPKH input and 2 P2WPKH outputs has 113 base bytes and 223 total bytes, so its weight is 562 and its vsize is 141. The same counts with P2PKH have 226 bytes and no witness, so the weight is 904 and the vsize is 226.

A CompactSize count is 1 byte for fewer than 253 items and 3 bytes up to 65,535 (serialize.h). The calculator accepts at most 10,000 of each type, so a count uses 1 or 3 bytes.

CFeeRate::GetFee returns EvaluateFeeUp(virtual_bytes). For a rate set in sat/kvB, the fee is the rate times the size in vbytes, divided by 1,000 and rounded up to the next whole satoshi. Bitcoin Core prints a rate in sat/vB with 3 decimals (FeeRateFormat::SAT_VB), so the calculator accepts at most 3 decimals. One sat/vB equals 1,000 sat/kvB.

GetDustThreshold in src/policy/policy.cpp prices an output at the dust relay fee, 3,000 sat/kvB by default, over the output size plus the size of an input that spends it. An output with a value below that fee is dust. An unspendable output, such as OP_RETURN, has a threshold of 0.

Worked examples at three fee rates

Each row is a transaction with 1 input and 2 outputs of the same type. Fee = sat/vB × vsize, rounded up to the next whole satoshi, priced at $80,154/BTC (price time 2026-10-29 05:00 UTC).

Fee in satoshis and USD for three transaction types at 5, 20 and 100 sat/vB
Fee rateTransaction typevsize (vB)Fee (sats)Fee (USD)
5 sat/vBLegacy, P2PKH2261,130$0.91
5 sat/vBSegwit, P2WPKH141705$0.57
5 sat/vBTaproot, P2TR key path154770$0.62
20 sat/vBLegacy, P2PKH2264,520$3.62
20 sat/vBSegwit, P2WPKH1412,820$2.26
20 sat/vBTaproot, P2TR key path1543,080$2.47
100 sat/vBLegacy, P2PKH22622,600$18.11
100 sat/vBSegwit, P2WPKH14114,100$11.30
100 sat/vBTaproot, P2TR key path15415,400$12.34

At each rate in the table, the taproot transaction (154 vB) pays about 68% of the fee of the legacy transaction (226 vB).

Dust limits at the default relay policy

Bitcoin Core v32.1 sets DUST_RELAY_TX_FEE to 3,000 sat/kvB (3 sat/vB) in policy.h. GetDustThreshold adds the output size to the size of an input that spends it. For a P2PKH or P2SH output that input is 32 + 4 + 1 + 107 + 4 = 148 bytes. For a witness program (P2WPKH, P2TR) the code divides the 107 bytes of signature and key data by 4 with integer division, so the input is 32 + 4 + 1 + 26 + 4 = 67 vbytes. A comment in policy.cpp says that a P2TR key path spend is smaller, but the code keeps this size so that the dust level does not go down further.

  • P2PKH output 34 + spend 148 = 182 bytes, dust below 546 sats
  • P2SH output 32 + spend 148 = 180 bytes, dust below 540 sats
  • P2WPKH output 31 + spend 67 = 98 bytes, dust below 294 sats
  • P2TR output 43 + spend 67 = 110 bytes, dust below 330 sats
Worked example

A 141 vB segwit payment at 20 sat/vB

fee = 20 × 141 = 2,820 satoshis. At $80,154/BTC that is $2.26. With a $1.00 budget, 1.00 ÷ 80,154 × 100,000,000 gives 1,247 whole satoshis. 1,247 ÷ 141 vB, rounded down to 0.001, is 8.843 sat/vB, and at that rate the fee is 1,247 satoshis. The calculator above does both directions.

Primary references

Where these numbers come from

The constants below are stored in the page source. The calculator does not fetch data from an outside service at run time.

  1. BIP 141 (Segregated Witness)

    Defines transaction weight as base transaction size × 3 + total transaction size, virtual transaction size as weight / 4 rounded up to the next integer, and the block rule block weight ≤ 4,000,000. Sets the marker byte 0x00 and the flag byte 0x01. Fetched 2026-10-29.

  2. BIP 144 (Segwit serialization)

    Defines the witness serialization: a marker byte, a flag byte, and for each input a var_int item count followed by each item with a var_int length. An empty witness is one zero byte. Fetched 2026-10-29.

  3. BIP 341 (Taproot)

    A P2TR output has a 32-byte witness program. A key path spend has one witness element, a 64-byte Schnorr signature with SIGHASH_DEFAULT, or 65 bytes with a sighash byte. Fetched 2026-10-29.

  4. BIP 66 (Strict DER signatures)

    An ECDSA signature has the format 0x30 [total-length] 0x02 [R-length] [R] 0x02 [S-length] [S] [sighash], so its length changes with R and S. The check rejects a signature above 73 bytes with the sighash byte. Fetched 2026-10-29.

  5. Bitcoin Core v32.1 src/policy/feerate.cpp

    CFeeRate::GetFee(virtual_bytes) returns EvaluateFeeUp(virtual_bytes). FeeRateFormat::SAT_VB prints a rate in sat/vB with 3 decimals. Fetched 2026-10-29.

  6. Bitcoin Core v32.1 src/util/feefrac.h

    EvaluateFeeUp multiplies the fee rate by the size and divides with CeilDiv, so the fee rounds up to the next whole satoshi. Fetched 2026-10-29.

  7. Bitcoin Core v32.1 src/policy/policy.h

    DUST_RELAY_TX_FEE is 3000 (sat/kvB), DEFAULT_MIN_RELAY_TX_FEE is 100 (sat/kvB) and MAX_STANDARD_TX_WEIGHT is 400,000. Fetched 2026-10-29.

  8. Bitcoin Core v32.1 src/policy/policy.cpp

    GetDustThreshold returns dustRelayFee.GetFee(output size + spend size), with a spend size of 32 + 4 + 1 + 107 + 4 = 148 bytes, or 32 + 4 + 1 + 107 / 4 + 4 = 67 bytes for a witness program (107 / 4 is 26 in integer division). IsStandardTx rejects a transaction above MAX_STANDARD_TX_WEIGHT (reason tx-size). Fetched 2026-10-29.

  9. Bitcoin Core v32.1 src/consensus/tx_check.cpp

    CheckTransaction rejects a transaction with no inputs (bad-txns-vin-empty) or no outputs (bad-txns-vout-empty). Fetched 2026-10-29.

  10. Bitcoin Core v32.1 src/serialize.h

    A CompactSize count is 1 byte below 253 and 3 bytes up to 65,535. Fetched 2026-10-29.

  11. Bitcoin Core download page

    Shows Latest version: 32.1. Fetched 2026-10-29.

  12. mempool.space price API

    Response with time 2026-10-29 05:00 UTC and USD 80,154. Fetched 2026-10-29. The calculator uses this stored value and does not fetch it live.

Related pages

Research disclosure

This page describes fee arithmetic and relay policy defaults. It is not investment advice, and it does not give a current or recommended fee rate. Check a live fee estimator before you broadcast a transaction.

Written by Michael Lip.