Skip to content

Fix: Improve Transaction Diagram Responsiveness #71

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 23 additions & 12 deletions decoding/transaction-signing-01.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,31 @@ Each input in a Bitcoin transaction must specify:
- ScriptSig: Placeholder for the unlocking script
- Sequence (4 bytes): Usually 0xFFFFFFFF

<div className="w-full rounded-xl overflow-hidden full-width">
<SvgDisplay
src="/decoding-bitcoin/static/images/topics/transactions/signature/signature7.svg"
width="100%"
height="auto"
/>
<div className="w-full rounded-xl overflow-x-auto overflow-y-hidden full-width">
<div className="min-w-[800px]">
<SvgDisplay
src="/decoding-bitcoin/static/images/topics/transactions/signature/signature7.svg"
width="100%"
height="100%"
className="min-h-[400px] md:min-h-[500px] lg:min-h-[600px] object-contain"
style={{
aspectRatio: "16/9",
maxHeight: "800px",
transform: "scale(1.2)",
transformOrigin: "center center"
}}
/>
</div>
</div>

The following table summarizes our UTXOs (Transaction IDs shown in big-endian format):

| Input | Transaction ID (big-endian) | Output Index | Sequence |
| ----- | ---------------------------------------------------------------- | ------------ | -------- |
| #1 | 9f96add4e4db413543df3eea1781c3be62637f1e2dd44069fa99801a88f7f7ff | 0 | eeffffff |
| #2 | 8ac60eb9575db5b2d987e29f301b5b819ea83a5c6579d282d189cc04b8e151ef | 1 | ffffffff |
<div className="w-full rounded-xl overflow-x-auto overflow-y-hidden">
<div className="min-w-[800px]">
| Input | Transaction ID (big-endian) | Output Index | Sequence |
| ----- | -------------------------- | ------------ | -------- |
| #1 | 9f96add4e4db413543df3eea1781c3be62637f1e2dd44069fa99801a88f7f7ff | 0 | eeffffff |
| #2 | 8ac60eb9575db5b2d987e29f301b5b819ea83a5c6579d282d189cc04b8e151ef | 1 | ffffffff |
</div>
</div>

_Note: In the transaction serialization below, these Transaction IDs are converted to little-endian format as required by the Bitcoin protocol._

Expand Down
27 changes: 17 additions & 10 deletions decoding/transaction-signing-02.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,15 @@ Each output in a Bitcoin transaction requires:
- Amount (8 bytes): Value in satoshis
- ScriptPubKey: Locking script that defines spending conditions

<div className="w-full rounded-xl overflow-hidden full-width">
<SvgDisplay
src="/decoding-bitcoin/static/images/topics/transactions/signature/signature8.svg"
width="100%"
height="auto"
/>
<div className="w-full rounded-xl overflow-x-auto overflow-y-hidden full-width">
<div className="min-w-[800px]">
<SvgDisplay
src="/decoding-bitcoin/static/images/topics/transactions/signature/signature8.svg"
width="100%"
height="auto"
className="min-h-[150px] md:min-h-[180px] lg:min-h-[220px] object-contain"
/>
</div>
</div>

---
Expand All @@ -48,10 +51,14 @@ Each output in a Bitcoin transaction requires:

The following table summarizes our outputs from test vector:

| Output | Amount (BTC) | ScriptPubKey |
| ------ | ------------ | ---------------------------------------------------- |
| #1 | 1.2 | 1976a9148280b37df378db99f66f85c95a783a76ac7a6d5988ac |
| #2 | 2.2 | 1976a9143bde42dbee7e4dbe6a21b2d50ce2f0167faa815988ac |
<div className="w-full rounded-xl overflow-x-auto overflow-y-hidden">
<div className="min-w-[800px]">
| Output | Amount (BTC) | ScriptPubKey |
| ------ | ------------ | ---------------------------------------------------- |
| #1 | 1.2 | 1976a9148280b37df378db99f66f85c95a783a76ac7a6d5988ac |
| #2 | 2.2 | 1976a9143bde42dbee7e4dbe6a21b2d50ce2f0167faa815988ac |
</div>
</div>

Our transaction structure at this stage is:

Expand Down
15 changes: 9 additions & 6 deletions decoding/transaction-signing-03.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,15 @@ When signing a P2WPKH (Segregated Witness) input, the signature and public key w

This is different from legacy transactions where signatures are placed directly in the `scriptSig`. The witness field starts empty and gets populated during the signing process.

<div className="w-full rounded-xl overflow-hidden full-width">
<SvgDisplay
src="/decoding-bitcoin/static/images/topics/transactions/signature/signature9.svg"
width="100%"
height="auto"
/>
<div className="w-full rounded-xl overflow-x-auto overflow-y-hidden full-width">
<div className="min-w-[800px]">
<SvgDisplay
src="/decoding-bitcoin/static/images/topics/transactions/signature/signature9.svg"
width="100%"
height="auto"
className="min-h-[150px] md:min-h-[180px] lg:min-h-[220px] object-contain"
/>
</div>
</div>

For signing a P2WPKH input, we need to generate the `scriptCode`
Expand Down
15 changes: 9 additions & 6 deletions decoding/transaction-signing-04.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,15 @@ images:
parent: "transaction-signing"
---

<div className="w-full rounded-xl overflow-hidden full-width">
<SvgDisplay
src="/decoding-bitcoin/static/images/topics/transactions/signature/signature9.svg"
width="100%"
height="auto"
/>
<div className="w-full rounded-xl overflow-x-auto overflow-y-hidden full-width">
<div className="min-w-[800px]">
<SvgDisplay
src="/decoding-bitcoin/static/images/topics/transactions/signature/signature9.svg"
width="100%"
height="auto"
className="min-h-[150px] md:min-h-[180px] lg:min-h-[220px] object-contain"
/>
</div>
</div>

After creating the basic transaction and scriptCode, we need to calculate three important hashes:
Expand Down
14 changes: 9 additions & 5 deletions decoding/transaction-signing-06.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,15 @@ When signing a transaction input, we follow these steps:

Let's use these values from our test vector:

| Value | Hex |
|-------|-----|
| Private Key | 619c335025c7f4012e556c2a58b2506e30b8511b53ade95ea316fd8c3286feb9 |
| Public Key | 025476c2e83188368da1ff3e292e7acafcdb3566bb0ad253f62fc70f07aeee6357 |
| Commitment Hash | c37af31116d1b27caf68aae9e3ac82f1477929014d5b917657d0eb49478cb670 |
<div className="w-full rounded-xl overflow-x-auto overflow-y-hidden">
<div className="min-w-[800px]">
| Value | Hex |
|-------|-----|
| Private Key | 619c335025c7f4012e556c2a58b2506e30b8511b53ade95ea316fd8c3286feb9 |
| Public Key | 025476c2e83188368da1ff3e292e7acafcdb3566bb0ad253f62fc70f07aeee6357 |
| Commitment Hash | c37af31116d1b27caf68aae9e3ac82f1477929014d5b917657d0eb49478cb670 |
</div>
</div>

## Step 1: ECDSA Signature Generation

Expand Down
15 changes: 9 additions & 6 deletions decoding/transaction-signing-07.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@ parent: "transaction-signing"

Our transaction now has all its fields populated except for the witness data.

<div className="w-full rounded-xl overflow-hidden full-width">
<SvgDisplay
src="/decoding-bitcoin/static/images/topics/transactions/signature/signature9.svg"
width="100%"
height="auto"
/>
<div className="w-full rounded-xl overflow-x-auto overflow-y-hidden full-width">
<div className="min-w-[800px]">
<SvgDisplay
src="/decoding-bitcoin/static/images/topics/transactions/signature/signature9.svg"
width="100%"
height="auto"
className="min-h-[150px] md:min-h-[180px] lg:min-h-[220px] object-contain"
/>
</div>
</div>

For a P2WPKH input, the witness structure is:
Expand Down
15 changes: 9 additions & 6 deletions decoding/transaction-signing-08.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,15 @@ images:
parent: "transaction-signing"
---

<div className="w-full rounded-xl overflow-hidden full-width">
<SvgDisplay
src="/decoding-bitcoin/static/images/topics/transactions/signature/signature10.svg"
width="100%"
height="auto"
/>
<div className="w-full rounded-xl overflow-x-auto overflow-y-hidden full-width">
<div className="min-w-[800px]">
<SvgDisplay
src="/decoding-bitcoin/static/images/topics/transactions/signature/signature10.svg"
width="100%"
height="auto"
className="min-h-[150px] md:min-h-[180px] lg:min-h-[220px] object-contain"
/>
</div>
</div>

Our final signed transaction hex:
Expand Down