Transaction Weight

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)

Transaction Size

The most straightforward measurement is the raw byte count of a transaction:

Transaction Size=Bytes of serialized transaction\mathbf{Transaction\ Size = Bytes\ of\ serialized\ transaction}

For example, here's a raw transaction in hexadecimal:

SVG Image

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).

Transaction Weight

With the introduction of SegWit, a new measurement called "transaction weight" was created:

Transaction Weight=(Base Size×4)+Witness Size\mathbf{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
SVG Image

NOTE

💡 For legacy (non-SegWit) transactions, all data is considered base size and witness size is zero.

Why Use Weight? Enter SegWit

Transaction weight was introduced alongside Segregated Witness (SegWit) to solve several problems:

  1. Transaction Malleability: A security issue where anyone could modify a transaction's signature (and thus its ID) before confirmation, without invalidating the transaction (more on this later).
  2. Block Space Efficiency: Signatures take up ~65% of transaction data
  3. Backward Compatibility: Needed a way to increase block capacity without a hard fork

SegWit achieves this by separating transaction data into two parts:

  • Base data: Transaction structure including inputs, outputs, version, and locktime (everything except signatures)
  • Witness data: Signatures and other data needed to validate the transaction, stored separately in the "witness" section
SVG Image

Suggest Edits
View our public visitor count
Built with 🧡 by the Bitcoin Dev Project
We'd love to hear your feedback on this project?Give Feedback