Fee estimation requires knowing a transaction's virtual size (vsize) before broadcasting. This appendix provides closed-form formulas for every transaction type covered in this book. All formulas assume compressed public keys (33 bytes) and standard DER-encoded ECDSA signatures (72 bytes average, 73 bytes worst case) or 64-byte Schnorr signatures where applicable.
For any transaction with stripped size \(S\) (serialization without witness data) and total size \(T\) (full serialization including witness):
\[ \text{Weight} = S \times 3 + T \]
\[ \text{vsize} = \left\lceil \frac{\text{Weight}}{4} \right\rceil \]
For legacy transactions (no witness), \(S = T\) and \(Weight = 4T\), so \(vsize = T\).
| Component | Formula | Typical (1-in, 2-out) |
|---|---|---|
| Overhead | \(10\) bytes | 10 |
| Per input | \(148\) bytes | 148 |
| Per output | \(34\) bytes | 68 |
| Total | \(10 + 148n + 34m\) | 226 bytes = 226 vB |
| Component | Formula | Typical (1-in, 2-out) |
|---|---|---|
| Overhead | \(10\) bytes | 10 |
| Per input | \(297\) bytes | 297 |
| Per output | \(34\) bytes | 68 |
| Total | \(10 + 297n + 34m\) | 375 bytes = 375 vB |
| Component | Formula | Typical (1-in, 2-out) |
|---|---|---|
| Overhead (non-witness) | \(10\) bytes | 10 |
| Marker + flag | \(2\) bytes | 2 |
| Per input (non-witness) | \(41\) bytes | 41 |
| Per output | \(31\) bytes | 62 |
| Per input (witness) | \(108\) bytes | 108 |
| Stripped size \(S\) | \(10 + 41n + 31m\) | 113 |
| Total size \(T\) | \(S + 2 + 108n\) | 223 |
| Weight | \(S \times 3 + T\) | \(339 + 223 = 562\) |
| vsize | \(W/4\) | \(\lceil 562/4 \rceil = \textbf{141}\) vB |
The witness for a P2WPKH input ranges from 107 to 109 bytes depending on whether the DER-encoded \(r\) and \(s\) values require high-bit padding. The 72-byte average signature gives 108 bytes. The Chapter 9 specimen (block 600,000) has a 71-byte signature (no padding on either \(r\) or \(s\)), yielding a 107-byte witness—but the 1-in-2-out vsize rounds to 141 vB in both cases.
| Component | Formula | Typical (1-in, 2-out) |
|---|---|---|
| Stripped size \(S\) | \(10 + 41n + 43m\) | 137 |
| Total size \(T\) | \(S + 2 + 254n\) | 393 |
| Weight | \(S \times 3 + T\) | \(411 + 393 = 804\) |
| vsize | \(W/4\) | \(\lceil 804/4 \rceil = \textbf{201}\) vB |
| Component | Formula | Typical (1-in, 2-out) |
|---|---|---|
| Stripped size \(S\) | \(10 + 41n + 43m\) | 137 |
| Total size \(T\) | \(S + 2 + 66n\) | 205 |
| Weight | \(S \times 3 + T\) | \(411 + 205 = 616\) |
| vsize | \(W/4\) | \(\lceil 616/4 \rceil = \textbf{154}\) vB |
| Component | Formula | Typical (1-in, 2-out) |
|---|---|---|
| Stripped size \(S\) | \(10 + 64n + 34m\) | 142 |
| Total size \(T\) | \(S + 2 + 108n\) | 252 |
| Weight | \(S \times 3 + T\) | \(426 + 252 = 678\) |
| vsize | \(W/4\) | \(\lceil 678/4 \rceil = \textbf{170}\) vB |
The following table compares the standard 1-input, 2-output transaction across all types:
| Type | Stripped | Total | Weight | vsize | Savings vs. P2PKH |
|---|---|---|---|---|---|
| P2PKH (legacy) | 226 | 226 | 904 | 226 | — |
| P2SH 2-of-3 | 375 | 375 | 1500 | 375 | — |
| P2SH-P2WPKH (wrapped) | 142 | 252 | 678 | 170 | 24.8% |
| P2WPKH (native SegWit) | 113 | 223 | 562 | 141 | 37.6% |
| P2WSH 2-of-3 | 137 | 393 | 804 | 201 | (vs. P2SH: 46.4%) |
| P2TR (key path) | 137 | 205 | 616 | 154 | 31.9% |
For a transaction with \(n\) inputs and \(m\) outputs at feerate \(r\) sat/vB: \[ \text{Fee} = r \times \text{vsize}(n, m) \text{ sats} \] At 10 sat/vB, a P2WPKH 1-in-2-out transaction costs \(10 \times 141 = 1,410\) sats (\(\approx\) $1.41 at $100k/BTC). A P2TR key-path spend costs \(10 \times 154 = 1,540\) sats—about 9% more, the price of Taproot's larger 43-byte outputs (vs. 31 bytes for P2WPKH).