Transaction Weight
Upcoming Topics:
- Fee Rate
- Fee Bumping (RBF, CPFP)
- Security Budget Problem.
When sending Bitcoin transactions, we need to pay fees based on how much block space our transaction occupies. There are three main ways to measure a transaction's size:
- Transaction Size: The raw byte count of the transaction
- Transaction Weight: A weighted measure that counts witness data differently
- Virtual Bytes (vBytes): Used for fee calculations (covered in the next topic on fee rates)
1- Transaction Size
The most straightforward measurement is the raw byte count of a transaction:
Transaction Size = Bytes of serialized transaction
For example, here's a raw transaction in hexadecimal:
This transaction is 225 bytes long - we simply count the number of characters and divide by 2 (since each byte is represented by 2 hex characters).
2- Transaction Weight
With the introduction of SegWit, a new measurement called "transaction weight" was created:
Transaction Weight = (Base Size × 4) + Witness Size
Where:
- Base Size = Size of transaction data without witness data (signatures)
- Witness Size = Size of witness data (signatures) only
💡 For legacy (non-SegWit) transactions, all data is considered base size and witness size is zero.
Read more about fee calculation →]https://bitcoindevs.xyz/decoding/fee-calculation)