Transaction WeightTransaction 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)
1- Transaction Size1- 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 Weight2- 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
💡 NOTE: For legacy (non-SegWit) transactions, all data is considered base size and witness size is zero.
Why Use Weight? Enter SegWitWhy Use Weight? Enter SegWit
check the answer here -> https://bitcoindevs.xyz/decoding/transaction-weight
why is base size multiplied by 4 in the transaction weight measurement ?
"It seems that the factor of 4 was chosen empirically (based on experience) so that segWit gets a sufficient discount, without damaging the network (which would be the case if the factor were higher)."
https://bitcoin.stackexchange.com/questions/119620/why-is-the-discount-on-segwit-data-exactly-a-factor-of-4-and-not-5-6-or-somethi
I'm amazed this could be done with a soft fork to be honest