Skip to content

Commit 2fb349e

Browse files
committed
update tx weight topic
1 parent 79209bf commit 2fb349e

File tree

4 files changed

+75
-48
lines changed

4 files changed

+75
-48
lines changed

decoding/transaction-weight.mdx

Lines changed: 32 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -9,79 +9,63 @@ order: 6
99
icon: "FaClipboardList"
1010
images: ["/bitcoin-topics/static/images/topics/thumbnails/musig-thumbnail.webp"]
1111
parent: "fee-calculation"
12-
---
1312

14-
When sending Bitcoin transactions, we need to pay fees. But how does the network determine how much we should pay?
13+
---
14+
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:
1515

16-
It all comes down to space - specifically, how much space our transaction takes up in a block.
16+
- **Transaction Size**: The raw byte count of the transaction
17+
- **Transaction Weight**: A weighted measure that counts witness data differently
18+
- **Virtual Bytes (vBytes)**: Used for fee calculations (covered in the next topic on fee rates)
1719

18-
## Transaction Size (Legacy)
20+
## Transaction Size
1921

20-
Originally, measuring transaction size was straightforward:
22+
The most straightforward measurement is the raw byte count of a transaction:
2123

2224
<div className="text-center my-4 text-orange-500">
2325
$$\mathbf{Transaction\ Size = Bytes\ of\ serialized\ transaction}$$
2426
</div>
2527

26-
This simple measurement worked because:
27-
- Each transaction was just a series of bytes
28-
- Fees were calculated based on these bytes
29-
30-
31-
32-
## Enter SegWit Transactions
33-
34-
The legacy system was simple, but it had a problem: transaction signatures.
28+
For example, here's a raw transaction in hexadecimal:
3529

36-
Every Bitcoin transaction needs signatures to prove ownership, similar to signing a check. These signatures:
37-
- Take up a lot of space (often 65% of the transaction)
38-
- Were part of the main transaction data
39-
- Could be slightly modified without invalidating them (transaction malleability)
40-
41-
This is where SegWit (Segregated Witness) comes in. "Segregated" means separated, and "Witness" refers to the signature.
42-
43-
So SegWit simply means:
44-
"Let's store the signatures separately from the main transaction data!"
45-
46-
47-
48-
<div className="dark:hidden w-full rounded-lg">
30+
<div className="dark:hidden">
4931
<SvgDisplay
50-
src="/bitcoin-topics/static/images/topics/transactions/fees/fees_5.svg"
51-
width="100%"
32+
src="/bitcoin-topics/static/images/topics/transactions/fees/fees_8.svg"
5233
height="auto"
5334
/>
5435
</div>
55-
<div className="hidden dark:block w-full rounded-lg">
36+
<div className="hidden dark:block">
5637
<SvgDisplay
57-
src="/bitcoin-topics/static/images/topics/transactions/fees/fees_5.svg"
58-
width="100%"
38+
src="/bitcoin-topics/static/images/topics/transactions/fees/fees_8.svg"
5939
height="auto"
6040
/>
6141
</div>
42+
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).
6243

63-
SegWit splits each transaction into two parts:
64-
- **Base data**: The essential information (addresses, amounts) - the "what"
65-
- **Witness data**: The signatures - the "proof"
66-
44+
## Transaction Weight
6745

68-
#### Transaction Weight
69-
70-
But splitting the data created a new challenge: how do we measure transaction size now?
71-
The solution was a new measurement called "transaction weight", calculated as:
46+
With the introduction of SegWit, a new measurement called "transaction weight" was created:
7247

7348
<div className="text-center my-4 text-orange-500">
7449
$$\mathbf{Transaction\ Weight = (Base\ Size × 4) + Witness\ Size}$$
7550
</div>
7651

77-
For example, if you have a transaction with base data of 200 bytes and witness data of 100 bytes, the weight would be: (200 × 4) + 100 = 900 weight units
78-
79-
This formula means:
80-
- Base data counts heavily (4× weight)
81-
- Witness data counts lightly (1× weight)
52+
Where:
53+
- **Base Size** = Size of transaction data without witness data (signatures)
54+
- **Witness Size** = Size of witness data (signatures) only
8255

56+
<div className="dark:hidden">
57+
<SvgDisplay
58+
src="/bitcoin-topics/static/images/topics/transactions/fees/fees_7.svg"
59+
height="auto"
60+
/>
61+
</div>
62+
<div className="hidden dark:block">
63+
<SvgDisplay
64+
src="/bitcoin-topics/static/images/topics/transactions/fees/fees_7.svg"
65+
height="auto"
66+
/>
67+
</div>
8368
<ExpandableAlert title="NOTE" type="info">
84-
💡 For legacy (non-SegWit) transactions, the entire transaction is considered base data,
85-
so weight = size × 4
69+
💡 For legacy (non-SegWit) transactions, all data is considered base size
70+
and witness size is zero.
8671
</ExpandableAlert>
87-
Loading

0 commit comments

Comments
 (0)