-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
409 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
--- | ||
title: "Transaction Weight" | ||
date: 2024-01-25T15:32:14Z | ||
lastmod: "2024-07-26" | ||
draft: false | ||
category: Transactions | ||
layout: TopicBanner | ||
order: 6 | ||
icon: "FaClipboardList" | ||
images: ["/bitcoin-topics/static/images/topics/thumbnails/musig-thumbnail.webp"] | ||
parent: "fee-calculation" | ||
--- | ||
|
||
When sending Bitcoin transactions, we need to pay fees. But how does the network determine how much we should pay? | ||
|
||
It all comes down to space - specifically, how much space our transaction takes up in a block. | ||
|
||
## Transaction Size (Legacy) | ||
|
||
Originally, measuring transaction size was straightforward: | ||
|
||
<div className="text-center my-4 text-orange-500"> | ||
$$\mathbf{Transaction\ Size = Bytes\ of\ serialized\ transaction}$$ | ||
</div> | ||
|
||
This simple measurement worked because: | ||
- Each transaction was just a series of bytes | ||
- Fees were calculated based on these bytes | ||
|
||
|
||
|
||
## Enter SegWit Transactions | ||
|
||
The legacy system was simple, but it had a problem: transaction signatures. | ||
|
||
Every Bitcoin transaction needs signatures to prove ownership, similar to signing a check. These signatures: | ||
- Take up a lot of space (often 65% of the transaction) | ||
- Were part of the main transaction data | ||
- Could be slightly modified without invalidating them (transaction malleability) | ||
|
||
This is where SegWit (Segregated Witness) comes in. "Segregated" means separated, and "Witness" refers to the signature. | ||
|
||
So SegWit simply means: | ||
"Let's store the signatures separately from the main transaction data!" | ||
|
||
|
||
|
||
<div className="dark:hidden w-full rounded-lg"> | ||
<SvgDisplay | ||
src="/bitcoin-topics/static/images/topics/transactions/fees/fees_5.svg" | ||
width="100%" | ||
height="auto" | ||
/> | ||
</div> | ||
<div className="hidden dark:block w-full rounded-lg"> | ||
<SvgDisplay | ||
src="/bitcoin-topics/static/images/topics/transactions/fees/fees_5.svg" | ||
width="100%" | ||
height="auto" | ||
/> | ||
</div> | ||
|
||
SegWit splits each transaction into two parts: | ||
- **Base data**: The essential information (addresses, amounts) - the "what" | ||
- **Witness data**: The signatures - the "proof" | ||
|
||
|
||
#### Transaction Weight | ||
|
||
But splitting the data created a new challenge: how do we measure transaction size now? | ||
The solution was a new measurement called "transaction weight", calculated as: | ||
|
||
<div className="text-center my-4 text-orange-500"> | ||
$$\mathbf{Transaction\ Weight = (Base\ Size × 4) + Witness\ Size}$$ | ||
</div> | ||
|
||
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 | ||
|
||
This formula means: | ||
- Base data counts heavily (4× weight) | ||
- Witness data counts lightly (1× weight) | ||
|
||
<ExpandableAlert title="NOTE" type="info"> | ||
💡 For legacy (non-SegWit) transactions, the entire transaction is considered base data, | ||
so weight = size × 4 | ||
</ExpandableAlert> | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.