Skip to content

Commit 7ee8295

Browse files
authored
Merge pull request #75 from deadmanoz/content-fixes-and-improvements
Content fixes and improvements for transactions module
2 parents e4ce314 + a8fbf60 commit 7ee8295

10 files changed

+32
-27
lines changed

decoding/endianness.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ Big-endian is considered more "human-readable" because the data is stored in the
7474

7575
## 2. Little-Endian
7676

77-
Little-endian stores the **least significant byte** first. This might feel counterintuitive to humans but is more efficient for modern processors.
77+
Little-endian stores the **least significant byte** first. It might feel counterintuitive to humans but little-endian is widely used in modern processors,
78+
particularly in the x86 architecture family, largely due to historical decisions.
7879

7980
Using the same number **12345678** (`0x00BC614E`), here's how it looks in **little-endian**:
8081

decoding/fee-calculation.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ Without fees, miners would have no reason to include transactions in their block
7070

7171
### How Miners Select Transactions ?
7272

73-
Miners receive two types of rewards for securing the network:
73+
Miners receive two types of payment for securing the network:
7474

75-
1. **Block Reward**
75+
1. **Block Subsidy**
7676
2. **Transaction Fees**
7777

7878
<div className="dark:hidden w-full rounded-lg">
@@ -96,7 +96,7 @@ A miner who mines a block will have revenue as:
9696
$$Revenue = Tx\ Fees + Block\ Subsidy$$
9797
</div>
9898

99-
To maximize their revenue, miners prioritize transactions that pay higher fees. The way they determine which transactions pay more will be covered in the next topic when we discuss fee rates.
99+
To maximize their revenue, miners prioritize transactions that pay higher fees. The way they determine which transactions pay more will be covered in the [Fee Rate](/decoding/fee-rate) topic.
100100

101101
For now, understand that:
102102

@@ -127,7 +127,7 @@ While miners can choose which transactions to include based on fees, there's act
127127
This is called the **minimum relay fee**.
128128

129129
- It's the minimum fee required for nodes to relay and accept a transaction
130-
- Default is typically 1 sat/vbyte (we'll explain this unit sat/vbyte in the next topic)
130+
- Default is typically 1 sat/vbyte (we'll explain this unit sat/vbyte in the [Transaction Weight](/decoding/transaction-weight) topic)
131131
- Transactions below this threshold will be rejected by nodes
132132
- Helps prevent spam and DoS attacks on the network
133133

decoding/inputs-prev-txid.mdx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ The txid uses Bitcoin's internal byte order (little-endian). Let's examine this
4545
display_txid = "5e6e1a9b4ce3f9f39467d7129e3ecfbe6c81c08dd377aac666fedc9a758fe614"
4646
4747
# Internal order (how it appears in raw transaction)
48-
4948
internal_txid = "14e68f759adcfe66c6aa77d38dc0816cbecf3e9e12d76794f3f9e34c9b1a6e5e"`}
5049
language="python"
5150
/>
@@ -138,7 +137,12 @@ The TXID is created differently depending on the transaction type:
138137
This difference in segwit transactions was intentionally designed to prevent transaction malleability, as signatures are no longer part of the TXID calculation.
139138

140139
<ExpandableAlert title="Historical Note" type="info">
141-
There was a unique situation in Bitcoin's history where duplicate TXIDs occurred in blocks 91,722 and 91,880. As a result, BIP 30 was implemented to prevent blocks from containing duplicate TXIDs, and BIP 34 was introduced to require coinbase transactions to include block height in their data.
140+
Duplicate TXID: `e3bf3d07d4b0375638d5f1db5255fe07ba2c4cb067cd81b84ee974b6585fb468`
141+
142+
There was a unique situation in Bitcoin's history where the same TXID (above) occurred in multiple blocks:
143+
<a href="https://mempool.space/block/00000000000271a2dc26e7667f8419f2e15416dc6955e5a6c6cdf3f2574dd08e" target="_blank" rel="noopener noreferrer">91,722</a> and
144+
<a href="https://mempool.space/block/00000000000743f190a18c5577a3c2d2a1f610ae9601ac046a38084ccb7cd721" target="_blank" rel="noopener noreferrer">91,880</a>.
145+
As a result, BIP 30 was implemented to prevent blocks from containing duplicate TXIDs, and BIP 34 was introduced to require coinbase transactions to include block height in their data.
142146
</ExpandableAlert>
143147

144148
## Implementation Details

decoding/inputs-scriptsig.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ Let's break down the highlighted hex string from our transaction:
5959
</td>
6060
<td className="px-6 py-4">1 byte</td>
6161
<td className="px-6 py-4">
62-
Script length in hex (72 bytes in decimal)
62+
Signature length in hex (72 bytes in decimal)
6363
</td>
6464
</tr>
6565
<tr className="hover:bg-gray-100 dark:hover:bg-gray-800">

decoding/inputs-scriptsigsize.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ Like the input count, the ScriptSig size uses varint encoding:
4949
| 2³² to 2⁶⁴-1 | 0x100000000 to 0xffffffffffffffff | 9 | `0xff` followed by uint64_t |
5050

5151
<ExpandableAlert title="Note" type="info">
52-
Most ScriptSig sizes are small enough to fit in a single byte, as they
53-
typically contain just a signature and public key.
52+
Most ScriptSig sizes are small enough to fit in a single byte, as the ScriptSig
53+
typically contains just a signature and public key that combined are less than 253 bytes in size.
5454
</ExpandableAlert>
5555

5656
## Implementation Example

decoding/inputs-sequence.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ Here's how you might parse a transaction input's sequence number:
131131
## 3- Historical Context
132132

133133
<ExpandableAlert title="Original Design" type="info">
134-
Satoshi originally designed the sequence number for "high-frequency trades"
135-
- a way to update transactions before they were mined. The idea was to
134+
Satoshi originally designed the sequence number for "high-frequency trades" -
135+
a way to update transactions before they were mined. The idea was to
136136
create payment channels between parties, where each new payment would
137137
increment the sequence number. However, this design was vulnerable to miner
138138
manipulation and was later replaced by better payment channel designs like
@@ -155,8 +155,8 @@ BIP 68 introduced relative timelocks using sequence numbers below 0x80000000. Th
155155
return sequence < 0xf0000000
156156
157157
def is_relative_timelock(sequence: int) -> bool:
158-
"""Check if relative timelock is enabled"""
159-
return sequence < 0x80000000`}
158+
"""Check if relative timelock is enabled"""
159+
return sequence < 0x80000000`}
160160
language="python"
161161
/>
162162

decoding/outputs-amount.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,8 @@ Here's a helpful function for converting between BTC and satoshis:
9898
return int(btc * 100_000_000)
9999
100100
def satoshis_to_btc(sats: int) -> float:
101-
"""Convert satoshi amount to BTC"""
102-
return sats / 100_000_000`}
101+
"""Convert satoshi amount to BTC"""
102+
return sats / 100_000_000`}
103103
language="python"
104104
/>
105105

decoding/transaction-creation.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,4 +144,4 @@ In this example:
144144
### Final Step: Signing the Transaction
145145

146146
The transaction structure is now complete but not yet valid. Alice must sign it to prove she owns the inputs.
147-
The signing process will be covered in detail in the next topic.
147+
The signing process will be covered in detail in the [Signing Transactions](/decoding/transaction-signing) topic.

decoding/transaction-signing-01.mdx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -130,15 +130,15 @@ Two essential encoding functions:
130130
return value.to_bytes(length, 'little')
131131
132132
def varint(n: int) -> bytes:
133-
"""Encode an integer as a variable length integer"""
134-
if n < 0xfd:
135-
return bytes([n])
136-
elif n <= 0xffff:
137-
return b'\\xfd' + n.to_bytes(2, 'little')
138-
elif n <= 0xffffffff:
139-
return b'\\xfe' + n.to_bytes(4, 'little')
140-
else:
141-
return b'\\xff' + n.to_bytes(8, 'little')`}
133+
"""Encode an integer as a variable length integer"""
134+
if n < 0xfd:
135+
return bytes([n])
136+
elif n <= 0xffff:
137+
return b'\\xfd' + n.to_bytes(2, 'little')
138+
elif n <= 0xffffffff:
139+
return b'\\xfe' + n.to_bytes(4, 'little')
140+
else:
141+
return b'\\xff' + n.to_bytes(8, 'little')`}
142142
language="python"
143143
/>
144144

decoding/transaction-signing-03.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ For our test vector:
7474
- `76`: OP_DUP
7575
- `a9`: OP_HASH160
7676
- `14`: Push 20 bytes
77-
- `1d0f172a0ecb48aee1be1f2687d2963ae33f71a1`: Public key hash from witness program
77+
- `1d0f172a0ecb48aee1be1f2687d2963ae33f71a1`: 20-byte public key hash from witness program
7878
- `88`: OP_EQUALVERIFY
7979
- `ac`: OP_CHECKSIG
8080
</ExpandableAlert>

0 commit comments

Comments
 (0)