Murch ado about nothing

PSA: Wrong fee rates on block explorers

This article originally appeared on my medium page on 2017-12-12.
Update: Blockchair.com, BTC.com and Smartbit.com.au have corrected their fee rates since my article. Thank you!

We’ve been getting support requests from customers inquiring why their transaction’s fee rate is not matching the parameters they set.

The problem is that popular blockchain explorers don’t get the fee rate right. Let’s look at the following transaction with two P2SH-P2WSH multisig inputs and six outputs: c​d​e​e​a​0​d​6​c​3​7​a​0​4​6​d​5​b​7​e​1​3​a​7​5​b​c​0​c​9​8​4​2​4​9​3​f​4​1​d​d​5​a​9​7​d​2​4​8​d​f​4​3​5​5​2​a​d​9​e​1​5​c​8​

The customer set a fee rate of 160.20 sat/B. Naturally, they were surprised when they saw what blockchain explorers are telling us:

Tradeblock.com says the fee rate is 216.81 sat/B.
smartbit.com.au says the fee rate is 90.50 sat/B. — Update: smartbit.com.au has fixed their fee rates since this article. Thank you.

It’s pretty clear that the fee is 78,920 satoshis…

…but what does this transaction “weigh“?

Stripped size: 364 bytes
This is the size of a transaction when ignoring the witness.
Without witness each input is 76 bytes long, each of the five P2PKH outputs has 34 bytes, the P2SH output has 32 bytes, and the transaction header is 10 bytes.
2×76+5×34+32+10 = 364 bytes

Fee rate: 78920 satoshis / 364 bytes = 216.8 sat/B

Raw size: 872 bytes
The raw byte length of the transaction.
Each of the two inputs has a raw byte length of 329 bytes, each of the five P2PKH outputs has 34 bytes, the P2SH output has 32 bytes, and the transaction header is 12 bytes long.
2×329+5×34+32+12 = 872 bytes

Fee rate: 78920 satoshis / 872 bytes = 90.5 sat/B

Where are the 160.2 sat/B we are looking for?

The explorers are showing us “fee / stripped transaction size” and “fee / raw transaction size”. While the calculation with the stripped transaction size overestimates the fee rate by considering the transaction smaller than it is, using the raw transaction size underestimates the fee rate by ignoring the witness discount.

However, since Segregated Witness activated, the relevant fee rate is “fee / virtual transaction size” in [satoshis per virtual byte].

Virtual size: 491 vbytes
The virtual size (vsize) of the transaction respective to the portion of a block it occupies, corresponding to the size of non-segwit transactions.
The vsize is calculated as follows:

(3×non-witness size + raw transaction size) / 4
or
(4×non-witness size + witness size) / 4

For non-segwit transactions the vsize is equal to the size. Each of the two inputs weighs 139 vbytes, each of the five P2PKH outputs weighs 34 vbytes, the P2SH output weighs 32 vbytes, and the transaction has a header of 10.5 vbytes.
2×139+5×34+32+11 = 491 vbytes

Fee rate: 78920 satoshis / 491 vbytes = 160.7 sat/vB

At last, BitFlyer gets it right by using scattershot:

BitFlyer lists all: the fee per raw tx size, the fee per WU and the actual fee rate.

Could we pretty, pretty please have more blockexplorers that show us the relevant fee rate?

Appendix: Additional honorary mentions

Blockchair tells us the “fee per kB” is 0.00216813 BTC. — Update: Blockchair has fixed their fee rates since this article. Thank you.
Blockchain.info shows the fee rate over raw byte length and a correct “Fee per weight unit” of 40.2 sat/WU, which however doesn’t compare to the established fee rates.
btc.com shows virtual size, but calculates the fee with the raw byte length: 90.5 sats/B.— Update: BTC.com has fixed their fee rates since this article. Thank you.
[blocktrail.com shows stripped size of 364 bytes and a fee rate of 216.8 sat/B.](blocktrail.com shows stripped size of 364 bytes and a fee rate of 216.8 sat/B.)
blocktrail.com shows stripped size of 364 bytes and a fee rate of 216.8 sat/B.
Menu