diff --git a/.github/workflows/repository-dispatch-to-dependent-repos.yml b/.github/workflows/repository-dispatch-to-dependent-repos.yml index db46f6b..3de83ab 100644 --- a/.github/workflows/repository-dispatch-to-dependent-repos.yml +++ b/.github/workflows/repository-dispatch-to-dependent-repos.yml @@ -1,22 +1,22 @@ name: Send dispatch to dependent repos on: - # Runs on pushes targeting the default branch - push: - branches: ["main"] + # Runs on pushes targeting the default branch + push: + branches: ["main"] - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: jobs: - # Build job - dispatch: - runs-on: ubuntu-latest - steps: - - name: Dispatch to bitcoin-dev-project - run: | - curl -X POST \ - -H "Authorization: token ${{ secrets.DISPATCH_UPDATE_BDP }}" \ - -H "Accept: application/vnd.github+json" \ - https://api.github.com/repos/bitcoin-dev-project/bitcoin-dev-project/dispatches \ - -d '{"event_type": "update_submodules"}' + # Build job + dispatch: + runs-on: ubuntu-latest + steps: + - name: Dispatch to bitcoin-dev-project + run: | + curl -X POST \ + -H "Authorization: token ${{ secrets.DISPATCH_UPDATE_BDP }}" \ + -H "Accept: application/vnd.github+json" \ + https://api.github.com/repos/bitcoin-dev-project/bitcoin-dev-project/dispatches \ + -d '{"event_type": "update_submodules"}' diff --git a/decoding/bitcoin-history.mdx b/decoding/bitcoin-history.mdx index d65cb6f..36e08ee 100644 --- a/decoding/bitcoin-history.mdx +++ b/decoding/bitcoin-history.mdx @@ -3,7 +3,7 @@ title: "Bitcoin History" date: 2024-07-05T15:32:14Z lastmod: "2024-07-06" draft: false -category: History +category: Introduction layout: TopicLayout icon: "FaHistory" order: 2 diff --git a/decoding/fee-calculation.mdx b/decoding/fee-calculation.mdx new file mode 100644 index 0000000..dbd4961 --- /dev/null +++ b/decoding/fee-calculation.mdx @@ -0,0 +1,14 @@ +--- +title: "Fee Calculation" +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"] +children: ["weight-vsize", "fee-rate", "rbf"] +--- + +(coming soon) diff --git a/decoding/fee-rate.mdx b/decoding/fee-rate.mdx new file mode 100644 index 0000000..e934e46 --- /dev/null +++ b/decoding/fee-rate.mdx @@ -0,0 +1,14 @@ +--- +title: "Fee Rate" +date: 2024-01-25T15:32:14Z +lastmod: "2024-07-26" +draft: false +category: Transactions +layout: TopicBanner +order: 2 +icon: "FaClipboardList" +images: ["/bitcoin-topics/static/images/topics/thumbnails/musig-thumbnail.webp"] +parent: "fee-calculation" +--- + +(coming soon) diff --git a/decoding/implement-OP_ADD-OP_HASH160.mdx b/decoding/implement-OP_ADD-OP_HASH160.mdx index 439cfc3..3ecb9bf 100644 --- a/decoding/implement-OP_ADD-OP_HASH160.mdx +++ b/decoding/implement-OP_ADD-OP_HASH160.mdx @@ -11,7 +11,6 @@ images: [ "/bitcoin-topics/static/images/topics/thumbnails/project-stack-thumbnail.webp" ] -topicType: exercise parent: project --- diff --git a/decoding/implement-OP_CHECKSIG.mdx b/decoding/implement-OP_CHECKSIG.mdx index 56ab84d..f518bdf 100644 --- a/decoding/implement-OP_CHECKSIG.mdx +++ b/decoding/implement-OP_CHECKSIG.mdx @@ -11,7 +11,6 @@ images: [ "/bitcoin-topics/static/images/topics/thumbnails/project-stack-thumbnail.webp" ] -topicType: exercise parent: project --- diff --git a/decoding/implement-basic-stack.mdx b/decoding/implement-basic-stack.mdx index 3ef80ea..e094351 100644 --- a/decoding/implement-basic-stack.mdx +++ b/decoding/implement-basic-stack.mdx @@ -11,7 +11,6 @@ images: [ "/bitcoin-topics/static/images/topics/thumbnails/project-stack-thumbnail.webp" ] -topicType: exercise parent: project --- diff --git a/decoding/inputs.mdx b/decoding/inputs.mdx new file mode 100644 index 0000000..1b25e1e --- /dev/null +++ b/decoding/inputs.mdx @@ -0,0 +1,14 @@ +--- +title: "Inputs" +date: 2024-01-25T15:32:14Z +lastmod: "2024-07-26" +draft: false +category: Transactions +layout: TopicBanner +order: 3.3 +icon: "FaClipboardList" +images: ["/bitcoin-topics/static/images/topics/thumbnails/musig-thumbnail.webp"] +parent: "transaction-structure" +--- + +(coming soon) diff --git a/decoding/locktime.mdx b/decoding/locktime.mdx new file mode 100644 index 0000000..9524708 --- /dev/null +++ b/decoding/locktime.mdx @@ -0,0 +1,14 @@ +--- +title: "Locktime" +date: 2024-01-25T15:32:14Z +lastmod: "2024-07-26" +draft: false +category: Transactions +layout: TopicBanner +order: 3.5 +icon: "FaClipboardList" +images: ["/bitcoin-topics/static/images/topics/thumbnails/musig-thumbnail.webp"] +parent: "transaction-structure" +--- + +(coming soon) diff --git a/decoding/marker-flag.mdx b/decoding/marker-flag.mdx new file mode 100644 index 0000000..e03fb3f --- /dev/null +++ b/decoding/marker-flag.mdx @@ -0,0 +1,54 @@ +--- +title: "Marker and Flag" +date: 2024-01-25T15:32:14Z +lastmod: "2024-07-26" +draft: false +category: Transactions +layout: TopicBanner +order: 3.2 +icon: "FaClipboardList" +images: + [ + "/bitcoin-topics/static/images/topics/thumbnails/transaction-module/tx-marker-flag.webp" + ] +parent: "transaction-structure" +--- + + + +The marker and flag are optional fields introduced with **SegWit**. + +They indicate that a transaction uses the segregated witness structure defined in **BIP144**. +Witness data is required for inputs locked by **P2WPKH**, **P2WSH**, or **P2TR**. + +## Marker + +Marker indicates that the transaction uses the extended format. + +- Marker is **1 byte**. +- Must always be `0x00` to signal a SegWit transaction. + +## Flag + +- The flag is **1 byte**. +- It is currently set to `0x01` in all SegWit transactions. +- Future upgrades may use different flags. + + + If a transaction doesn’t include witness data, marker and flag are omitted. + + +### Question + +How do old nodes treat marker and flag for SegWit transactions? + + + Answer here + diff --git a/decoding/musig.mdx b/decoding/musig.mdx index 7d09765..6d8f724 100644 --- a/decoding/musig.mdx +++ b/decoding/musig.mdx @@ -438,7 +438,11 @@ Where: ### Final Signature The final aggregate signature is: -(Ragg, sagg) + + + (Ragg, s + agg) + This pair can be verified using Pagg and the message `m`. diff --git a/decoding/network-propagation.mdx b/decoding/network-propagation.mdx new file mode 100644 index 0000000..fd8700a --- /dev/null +++ b/decoding/network-propagation.mdx @@ -0,0 +1,11 @@ +--- +title: "Network Propagation" +date: 2024-01-25T15:32:14Z +lastmod: "2024-07-26" +draft: false +category: Transactions +layout: TopicBanner +order: 8 +icon: "FaClipboardList" +images: ["/bitcoin-topics/static/images/topics/thumbnails/musig-thumbnail.webp"] +--- diff --git a/decoding/number-decoding-encoding.mdx b/decoding/number-decoding-encoding.mdx index 2c69b52..8111646 100644 --- a/decoding/number-decoding-encoding.mdx +++ b/decoding/number-decoding-encoding.mdx @@ -11,7 +11,6 @@ images: [ "/bitcoin-topics/static/images/topics/thumbnails/project-stack-thumbnail.webp" ] -topicType: exercise parent: project --- diff --git a/decoding/outputs.mdx b/decoding/outputs.mdx new file mode 100644 index 0000000..c230c3b --- /dev/null +++ b/decoding/outputs.mdx @@ -0,0 +1,14 @@ +--- +title: "Outputs" +date: 2024-01-25T15:32:14Z +lastmod: "2024-07-26" +draft: false +category: Transactions +layout: TopicBanner +order: 3.4 +icon: "FaClipboardList" +images: ["/bitcoin-topics/static/images/topics/thumbnails/musig-thumbnail.webp"] +parent: "transaction-structure" +--- + +(coming soon) diff --git a/decoding/p2ms-exercise-1.mdx b/decoding/p2ms-exercise-1.mdx index a0e02ca..9fbd66b 100644 --- a/decoding/p2ms-exercise-1.mdx +++ b/decoding/p2ms-exercise-1.mdx @@ -7,7 +7,6 @@ category: Scripts layout: TopicBanner order: 1 images: ["/bitcoin-topics/static/images/topics/thumbnails/p2ms-thumbnail.webp"] -topicType: exercise parent: p2ms --- diff --git a/decoding/p2ms-exercise-2.mdx b/decoding/p2ms-exercise-2.mdx index b62c639..0858f23 100644 --- a/decoding/p2ms-exercise-2.mdx +++ b/decoding/p2ms-exercise-2.mdx @@ -7,7 +7,6 @@ category: Scripts layout: TopicBanner order: 2 images: ["/bitcoin-topics/static/images/topics/thumbnails/p2ms-thumbnail.webp"] -topicType: exercise parent: p2ms --- diff --git a/decoding/p2pk-exercise1.mdx b/decoding/p2pk-exercise1.mdx index a81d4a7..52dd84a 100644 --- a/decoding/p2pk-exercise1.mdx +++ b/decoding/p2pk-exercise1.mdx @@ -7,7 +7,6 @@ category: Scripts layout: TopicBanner order: 2 images: ["/bitcoin-topics/static/images/topics/thumbnails/p2pk-thumbnail.webp"] -topicType: exercise parent: p2pk --- diff --git a/decoding/p2pk-exercise2.mdx b/decoding/p2pk-exercise2.mdx index d09441c..5e16e0d 100644 --- a/decoding/p2pk-exercise2.mdx +++ b/decoding/p2pk-exercise2.mdx @@ -7,7 +7,6 @@ category: Scripts layout: TopicBanner order: 3 images: ["/bitcoin-topics/static/images/topics/thumbnails/p2pk-thumbnail.webp"] -topicType: exercise parent: p2pk --- diff --git a/decoding/p2pk-exercise3.mdx b/decoding/p2pk-exercise3.mdx index 18cda1a..bc672fe 100644 --- a/decoding/p2pk-exercise3.mdx +++ b/decoding/p2pk-exercise3.mdx @@ -7,7 +7,6 @@ category: Scripts layout: TopicBanner order: 4 images: ["/bitcoin-topics/static/images/topics/thumbnails/p2pk-thumbnail.webp"] -topicType: exercise parent: p2pk --- diff --git a/decoding/p2pkh-exercise1.mdx b/decoding/p2pkh-exercise1.mdx index b1ee5bd..9cc541d 100644 --- a/decoding/p2pkh-exercise1.mdx +++ b/decoding/p2pkh-exercise1.mdx @@ -7,7 +7,6 @@ category: Scripts layout: TopicBanner order: 1 images: ["/bitcoin-topics/static/images/topics/thumbnails/p2pkh-thumbnail.webp"] -topicType: exercise parent: p2pkh --- diff --git a/decoding/p2pkh-exercise2.mdx b/decoding/p2pkh-exercise2.mdx index 0c9eb32..7d879d5 100644 --- a/decoding/p2pkh-exercise2.mdx +++ b/decoding/p2pkh-exercise2.mdx @@ -7,7 +7,6 @@ category: Scripts layout: TopicBanner order: 2 images: ["/bitcoin-topics/static/images/topics/thumbnails/p2pkh-thumbnail.webp"] -topicType: exercise parent: p2pkh --- diff --git a/decoding/p2sh-exercise-1.mdx b/decoding/p2sh-exercise-1.mdx index c3ad100..e53af78 100644 --- a/decoding/p2sh-exercise-1.mdx +++ b/decoding/p2sh-exercise-1.mdx @@ -7,7 +7,6 @@ category: Scripts layout: TopicBanner order: 1 images: ["/bitcoin-topics/static/images/topics/thumbnails/p2sh-thumbnail.webp"] -topicType: exercise parent: p2sh --- diff --git a/decoding/p2sh-exercise-2.mdx b/decoding/p2sh-exercise-2.mdx index 17f36b6..520a25f 100644 --- a/decoding/p2sh-exercise-2.mdx +++ b/decoding/p2sh-exercise-2.mdx @@ -7,7 +7,6 @@ category: Scripts layout: TopicBanner order: 2 images: ["/bitcoin-topics/static/images/topics/thumbnails/p2sh-thumbnail.webp"] -topicType: exercise parent: p2sh --- diff --git a/decoding/pushdata-opcodes.mdx b/decoding/pushdata-opcodes.mdx index ce65674..3c043a2 100644 --- a/decoding/pushdata-opcodes.mdx +++ b/decoding/pushdata-opcodes.mdx @@ -23,8 +23,10 @@ In bitcoin's scripting language, several opcodes are used to push data onto the 4. **OP_1NEGATE**: Pushes the number -1 onto the stack. - Due to practical limitations and security considerations, the maximum amount of data that can be pushed in a single operation is **520 - bytes**. As such, the **OP_PUSHDATA4** opcode is never used in practice (it allows for pushing 65536-4294967295 bytes). + Due to practical limitations and security considerations, the maximum amount + of data that can be pushed in a single operation is **520 bytes**. As such, + the **OP_PUSHDATA4** opcode is never used in practice (it allows for pushing + 65536-4294967295 bytes). +
+
+ +
+
+ +
+
+ diff --git a/decoding/script-parser.mdx b/decoding/script-parser.mdx index 9685544..3dd0876 100644 --- a/decoding/script-parser.mdx +++ b/decoding/script-parser.mdx @@ -11,7 +11,6 @@ images: [ "/bitcoin-topics/static/images/topics/thumbnails/project-stack-thumbnail.webp" ] -topicType: exercise parent: project --- diff --git a/decoding/transaction-creation.mdx b/decoding/transaction-creation.mdx new file mode 100644 index 0000000..938d622 --- /dev/null +++ b/decoding/transaction-creation.mdx @@ -0,0 +1,147 @@ +--- +title: "Creating a Transaction" +date: 2024-01-25T15:32:14Z +lastmod: "2024-07-26" +draft: false +category: Transactions +layout: TopicBanner +order: 5 +icon: "FaClipboardList" +images: + [ + "/bitcoin-topics/static/images/topics/thumbnails/transaction-module/creating-tx.webp" + ] +--- + +Alice wants to pay 5 BTC to Bob for a digital item. +To make this payment, she needs to create a Bitcoin transaction using the unspent outputs (UTXOs) in her wallet. + +
+ +
+
+ +
+ + +UTXOs are unspent transaction outputs that can be used as inputs for new transactions. +Think of UTXOs as the "coins" sitting in Alice's wallet, waiting to be spent. + +Alice checks her wallet and finds two UTXOs: + +- **UTXO #1**: 4 BTC +- **UTXO #2**: 2 BTC + +Together, these provide enough funds (6 BTC total) to pay Bob 5 BTC. + + + +### 1. Inputs: Where the Money Comes From + +To create a transaction, Alice needs to specify which UTXOs she wants to use as inputs. + +
+ +
+
+ +
+ +Alice's wallet shows these available UTXOs: + +- **UTXO #1**: 4 BTC (from Transaction 1, Output Index 1) +- **UTXO #2**: 2 BTC (from Transaction 2, Output Index 0) + +Together, these UTXOs provide enough funds (4 BTC + 2 BTC = 6 BTC) for the payment and any transaction fees. + +#### Creating Transaction Inputs + +Each input in a Bitcoin transaction must include: + +1. The Transaction ID (Where the UTXO came from) +2. The Output Index (Which output from that transaction) +3. A placeholder for the Signature (which will be added when Alice signs the transaction) + +
+ +
+
+ +
+ +### 2. Outputs: Where the Money Goes + +For this transaction, Alice needs to create two outputs: + +- **5 BTC to Bob** (the payment amount) +- **0.99 BTC back to Alice** (as change, assuming 0.01 BTC transaction fee) + +
+ +
+
+ +
+ + +In Bitcoin, UTXOs must be spent in their entirety. You cannot partially spend a UTXO. +Instead, you create a new output that sends the excess amount back to yourself as change. + +For example: If you have a 6 BTC UTXO and want to send 5 BTC, you must: + +1. Spend the entire 6 BTC UTXO +2. Create one output of 5 BTC to the recipient +3. Create another output sending the remaining 1 BTC back to yourself + + + +### Transaction Fees + +A transaction fee incentivizes miners to include your transaction in a block. The fee is the difference between inputs and outputs: + +``` +Fee = Total Input Amount - Total Output Amount +``` + +In this example: + +- Inputs: 6 BTC +- Outputs: 5 BTC (to Bob) + 0.99 BTC (change) +- Fee: 0.01 BTC + +### Final Step: Signing the Transaction + +The transaction structure is now complete but not yet valid. Alice must sign it to prove she owns the inputs. +The signing process will be covered in detail in the next topic. diff --git a/decoding/transaction-lifecycle.mdx b/decoding/transaction-lifecycle.mdx new file mode 100644 index 0000000..05d1300 --- /dev/null +++ b/decoding/transaction-lifecycle.mdx @@ -0,0 +1,54 @@ +--- +title: "Transaction Lifecycle" +date: 2024-01-25T15:32:14Z +lastmod: "2024-07-26" +draft: false +category: Transactions +layout: TopicBanner +order: 1 +icon: "FaClipboardList" +images: + [ + "/bitcoin-topics/static/images/topics/thumbnails/transaction-module/tx-lifecycle.webp" + ] +--- + +Watch how a Bitcoin transaction moves through the network, from creation to confirmation: + +
+ +
+ +## The Journey of a Bitcoin Transaction + +1. [**Creation**](./transaction-creation): A new transaction is built using unspent outputs (UTXOs) + +2. [**Signing**](./transaction-signing): The transaction is signed with the sender's private key + +3. [**Broadcasting**](./transaction-broadcasting): The signed transaction propagates through the network + +4. [**Validation by Nodes**](./transaction-validation): Network nodes verify the transaction's validity + +5. [**Mining**](./transaction-mining): Miners include the valid transaction in a block + +Each step has its own dedicated topic where you can learn more about the technical details and processes involved. diff --git a/decoding/transaction-signing.mdx b/decoding/transaction-signing.mdx new file mode 100644 index 0000000..912e009 --- /dev/null +++ b/decoding/transaction-signing.mdx @@ -0,0 +1,82 @@ +--- +title: "Signing Transactions" +date: 2024-01-25T15:32:14Z +lastmod: "2024-07-26" +draft: false +category: Transactions +layout: TopicBanner +order: 7 +icon: "FaClipboardList" +images: + [ + "/bitcoin-topics/static/images/topics/thumbnails/transaction-module/signing-tx.webp" + ] +--- + +After creating her transaction, Alice has all the essential parts in place: + +- **Inputs** referencing her UTXOs. +- **Outputs** specifying where the bitcoin should go. + +However, the network will only accept her transaction if it’s **validly signed**. Let’s see how that works. + +
+ +
+
+ +
+ +## 1. Why Sign the Transaction? + +Signing a transaction proves to the Bitcoin network that **you own the private keys** for the UTXOs you’re spending. + +Each input in a transaction references a specific previous output, which is “locked” to a Bitcoin script (Public-Key-Hash in this case). + +
+ +
+
+ +
+ +By signing, Alice demonstrates ownership of the private key required to satisfy the conditions of that script. + +## 2. The Signing Process + +Let's look at a transaction with two inputs. Input 0 is locked to PKH1, and Input 1 is locked to PKH2. + +Each input requires its own signature. For Input 0, Alice must use the private key that matches PKH1. For Input 1, she needs the private key that matches PKH2. + +Before signing, the wallet creates a "cleaned" version of the transaction. This means all signature fields are temporarily empty. + +Why use a cleaned version? Because: + +- Each signature needs to commit to the exact same transaction data +- The order of signing doesn't matter +- Verification becomes simpler and more reliable + +The signing happens in steps: + +1. The wallet takes the cleaned transaction +2. It hashes the entire transaction data +3. It signs this hash with the appropriate private key +4. It repeats for each input + +(...) diff --git a/decoding/transaction-structure.mdx b/decoding/transaction-structure.mdx new file mode 100644 index 0000000..3bdf67e --- /dev/null +++ b/decoding/transaction-structure.mdx @@ -0,0 +1,53 @@ +--- +title: "Transaction Structure" +date: 2024-01-25T15:32:14Z +lastmod: "2024-07-26" +draft: false +category: Transactions +layout: TopicBanner +order: 2 +icon: "FaClipboardList" +images: + [ + "/bitcoin-topics/static/images/topics/thumbnails/transaction-module/tx-component.webp" + ] +children: + - version + - marker-flag + - inputs + - outputs + - locktime +--- + +At a high level, a Bitcoin transaction has five main components: + +- **Version** +- **Marker & Flag** +- **Inputs** +- **Outputs** +- **Locktime** + +Let's analyze a real transaction from the Bitcoin blockchain to understand these components better. + +We'll use transaction ID [89699cce128...c5a497fbae881](https://mempool.space/tx/89699cce128a694b4fb3be0e07ae0a9b63f0da1bc62fb3a4eb3c5a497fbae881) from block `877417` as an example. + +To get the raw transaction data, run: + + + +The output will be the serialized transaction format (A long hexadecimal string representing all transaction data). + + + Serialization is the process of converting structured data into a compact + format (in this case, a hex string) that can be easily stored and + transmitted across the Bitcoin network. + + +You can explore this transaction's structure using the interactive tool below: + + + +In the following sections, we'll break down each component of the transaction structure in detail. diff --git a/decoding/utxo.mdx b/decoding/utxo.mdx new file mode 100644 index 0000000..3202e8f --- /dev/null +++ b/decoding/utxo.mdx @@ -0,0 +1,87 @@ +--- +title: "UTXO vs Account Models" +date: 2024-01-25T15:32:14Z +lastmod: "2024-07-26" +draft: false +category: Transactions +layout: TopicBanner +order: 3 +icon: "FaClipboardList" +images: + [ + "/bitcoin-topics/static/images/topics/thumbnails/transaction-module/utxo-accountmodel.webp" + ] +--- + +
+ +
+
+ +
+ +Tracking user balances in decentralized blockchains like Bitcoin and Ethereum relies on two models: + +1. **Account Model** (Ethereum): Tracks balances like a bank ledger (simple and intuitive). +2. **UTXO Model** (Bitcoin): Tracks specific unspent outputs from transactions—complex but powerful. + +--- + +### How Transactions Work ? + +Every blockchain transaction includes: + +- **Amount**: Value transferred. +- **Payer & Payee**: Sender and recipient. +- **Authorization**: Digital signature ensuring security. + +Transactions update balances by changing the system’s state. +**Example**: Alice sends Bob 5 BTC, decreasing her balance by 5 BTC and increasing Bob's by 5 BTC. + +## 1- Account Model (Simple and Familiar) + +The account model is like a bank ledger, recording total balances without detailing individual inputs or outputs. + +**Example**: +Alice: 60 ETH → Bob sends 5 ETH → Alice: 65 ETH, Bob: 15 ETH. + +| **Pros** | **Cons** | +| ---------------------------- | ---------------------------- | +| Easy to understand | Vulnerable to replay attacks | +| Flexible for smart contracts | Limited privacy | + +| + +## 2- UTXO Model (Detailed and Secure) + +The UTXO model tracks specific outputs from past transactions. + +**Example**: + +- Bob receives UTXOs worth 2 BTC, 3 BTC, and 5 BTC. +- Spending 6 BTC uses the 5 BTC UTXO and part of the 3 BTC UTXO, creating a new "change" UTXO. + +| **Pros** | **Cons** | +| ----------------------------------- | ------------------------------------ | +| High privacy (new addresses per tx) | More complex and less intuitive | +| Prevents double-spending | Harder to design for state-heavy use | +| | Requires management of UTXOs | + +| + +## Comparing Models + +| **Feature** | **Account Model** | **UTXO Model** | +| --------------- | ---------------------------- | --------------------------------------- | +| **Balances** | Total balance (e.g., 10 ETH) | Collection of UTXOs (e.g., 2, 3, 5 BTC) | +| **Ease of Use** | Intuitive | Complex | +| **Privacy** | Limited | High if new addresses used | +| **Design** | Flexible for smart contracts | Stateless, simple transfers | diff --git a/decoding/version.mdx b/decoding/version.mdx new file mode 100644 index 0000000..3f5b92d --- /dev/null +++ b/decoding/version.mdx @@ -0,0 +1,45 @@ +--- +title: "Version" +date: 2024-01-25T15:32:14Z +lastmod: "2024-07-26" +draft: false +category: Transactions +layout: TopicBanner +order: 3.1 +icon: "FaClipboardList" +images: + [ + "/bitcoin-topics/static/images/topics/thumbnails/transaction-module/tx-version.webp" + ] +parent: "transaction-structure" +--- + +Just like software updates labeled as v1.0, v2.0, v3.0, Bitcoin transactions use version numbers to indicate which features they support. + + + +Bitcoin transaction versions and their features: + +1. **Version 1:** The original transaction format that follows basic Bitcoin transaction rules. + +2. **Version 2:** Introduced in BIP68, BIP112, and BIP113, enabling: + + - **OP_CHECKSEQUENCEVERIFY (CSV)**: Allows relative timelock constraints + - **Relative lock-time**: Prevents spending until a certain number of blocks have passed + - **Median-time-past**: Uses median timestamp of previous 11 blocks for time-based locks + +3. **Version 3:** Introduced to prevent transaction pinning attacks + + + Don't worry if these new terms seem complex - we'll cover timelocks, CSV + operations, and more in detail in later sections! + + +## Encoding + +The version is stored as a 4-byte integer in **little-endian** format. For example: + +- Hex: `01000000` → Version: `1` +- Hex: `02000000` → Version: `2` + +Most transactions today use version 1 or 2, with version 2 being necessary when using relative timelocks or CSV operations. diff --git a/static/images/topics/thumbnails/transaction-module/creating-tx.webp b/static/images/topics/thumbnails/transaction-module/creating-tx.webp new file mode 100644 index 0000000..7343ec5 Binary files /dev/null and b/static/images/topics/thumbnails/transaction-module/creating-tx.webp differ diff --git a/static/images/topics/thumbnails/transaction-module/signing-tx.webp b/static/images/topics/thumbnails/transaction-module/signing-tx.webp new file mode 100644 index 0000000..02394c3 Binary files /dev/null and b/static/images/topics/thumbnails/transaction-module/signing-tx.webp differ diff --git a/static/images/topics/thumbnails/transaction-module/tx-component.webp b/static/images/topics/thumbnails/transaction-module/tx-component.webp new file mode 100644 index 0000000..9e66854 Binary files /dev/null and b/static/images/topics/thumbnails/transaction-module/tx-component.webp differ diff --git a/static/images/topics/thumbnails/transaction-module/tx-lifecycle.webp b/static/images/topics/thumbnails/transaction-module/tx-lifecycle.webp new file mode 100644 index 0000000..e96b65a Binary files /dev/null and b/static/images/topics/thumbnails/transaction-module/tx-lifecycle.webp differ diff --git a/static/images/topics/thumbnails/transaction-module/tx-marker-flag.webp b/static/images/topics/thumbnails/transaction-module/tx-marker-flag.webp new file mode 100644 index 0000000..5d49a79 Binary files /dev/null and b/static/images/topics/thumbnails/transaction-module/tx-marker-flag.webp differ diff --git a/static/images/topics/thumbnails/transaction-module/tx-roadmap.webp b/static/images/topics/thumbnails/transaction-module/tx-roadmap.webp new file mode 100644 index 0000000..2654635 Binary files /dev/null and b/static/images/topics/thumbnails/transaction-module/tx-roadmap.webp differ diff --git a/static/images/topics/thumbnails/transaction-module/tx-version.webp b/static/images/topics/thumbnails/transaction-module/tx-version.webp new file mode 100644 index 0000000..73192c2 Binary files /dev/null and b/static/images/topics/thumbnails/transaction-module/tx-version.webp differ diff --git a/static/images/topics/thumbnails/transaction-module/utxo-accountmodel.webp b/static/images/topics/thumbnails/transaction-module/utxo-accountmodel.webp new file mode 100644 index 0000000..b3a196e Binary files /dev/null and b/static/images/topics/thumbnails/transaction-module/utxo-accountmodel.webp differ diff --git a/static/images/topics/transactions/lifecycle/0.svg b/static/images/topics/transactions/lifecycle/0.svg new file mode 100644 index 0000000..a3f18dd --- /dev/null +++ b/static/images/topics/transactions/lifecycle/0.svg @@ -0,0 +1,4 @@ + + + + diff --git a/static/images/topics/transactions/lifecycle/00.svg b/static/images/topics/transactions/lifecycle/00.svg new file mode 100644 index 0000000..741ad8b --- /dev/null +++ b/static/images/topics/transactions/lifecycle/00.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/static/images/topics/transactions/lifecycle/000.svg b/static/images/topics/transactions/lifecycle/000.svg new file mode 100644 index 0000000..a9feb90 --- /dev/null +++ b/static/images/topics/transactions/lifecycle/000.svg @@ -0,0 +1,4 @@ + + + + diff --git a/static/images/topics/transactions/lifecycle/1.svg b/static/images/topics/transactions/lifecycle/1.svg new file mode 100644 index 0000000..080258b --- /dev/null +++ b/static/images/topics/transactions/lifecycle/1.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/static/images/topics/transactions/lifecycle/10.svg b/static/images/topics/transactions/lifecycle/10.svg new file mode 100644 index 0000000..0885015 --- /dev/null +++ b/static/images/topics/transactions/lifecycle/10.svg @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/static/images/topics/transactions/lifecycle/11.svg b/static/images/topics/transactions/lifecycle/11.svg new file mode 100644 index 0000000..9b2a77c --- /dev/null +++ b/static/images/topics/transactions/lifecycle/11.svg @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/static/images/topics/transactions/lifecycle/12.svg b/static/images/topics/transactions/lifecycle/12.svg new file mode 100644 index 0000000..25c7f47 --- /dev/null +++ b/static/images/topics/transactions/lifecycle/12.svg @@ -0,0 +1,4 @@ + + + + diff --git a/static/images/topics/transactions/lifecycle/13.svg b/static/images/topics/transactions/lifecycle/13.svg new file mode 100644 index 0000000..fa2e025 --- /dev/null +++ b/static/images/topics/transactions/lifecycle/13.svg @@ -0,0 +1,4 @@ + + + + diff --git a/static/images/topics/transactions/lifecycle/2.svg b/static/images/topics/transactions/lifecycle/2.svg new file mode 100644 index 0000000..1554e3a --- /dev/null +++ b/static/images/topics/transactions/lifecycle/2.svg @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/static/images/topics/transactions/lifecycle/3.svg b/static/images/topics/transactions/lifecycle/3.svg new file mode 100644 index 0000000..ca4e8ca --- /dev/null +++ b/static/images/topics/transactions/lifecycle/3.svg @@ -0,0 +1,4 @@ + + + + diff --git a/static/images/topics/transactions/lifecycle/4.svg b/static/images/topics/transactions/lifecycle/4.svg new file mode 100644 index 0000000..4ed111e --- /dev/null +++ b/static/images/topics/transactions/lifecycle/4.svg @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/static/images/topics/transactions/lifecycle/5.svg b/static/images/topics/transactions/lifecycle/5.svg new file mode 100644 index 0000000..dc51db5 --- /dev/null +++ b/static/images/topics/transactions/lifecycle/5.svg @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/static/images/topics/transactions/lifecycle/6.svg b/static/images/topics/transactions/lifecycle/6.svg new file mode 100644 index 0000000..f99b906 --- /dev/null +++ b/static/images/topics/transactions/lifecycle/6.svg @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/static/images/topics/transactions/lifecycle/7.svg b/static/images/topics/transactions/lifecycle/7.svg new file mode 100644 index 0000000..8f410d4 --- /dev/null +++ b/static/images/topics/transactions/lifecycle/7.svg @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/static/images/topics/transactions/lifecycle/8.svg b/static/images/topics/transactions/lifecycle/8.svg new file mode 100644 index 0000000..c1563fd --- /dev/null +++ b/static/images/topics/transactions/lifecycle/8.svg @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/static/images/topics/transactions/lifecycle/9.svg b/static/images/topics/transactions/lifecycle/9.svg new file mode 100644 index 0000000..a0390f3 --- /dev/null +++ b/static/images/topics/transactions/lifecycle/9.svg @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/static/images/topics/transactions/roadmap.svg b/static/images/topics/transactions/roadmap.svg new file mode 100644 index 0000000..2d2fa9c --- /dev/null +++ b/static/images/topics/transactions/roadmap.svg @@ -0,0 +1,185 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/static/images/topics/transactions/signature1.svg b/static/images/topics/transactions/signature1.svg new file mode 100644 index 0000000..76f7a16 --- /dev/null +++ b/static/images/topics/transactions/signature1.svg @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/static/images/topics/transactions/signature2.svg b/static/images/topics/transactions/signature2.svg new file mode 100644 index 0000000..fd4ee82 --- /dev/null +++ b/static/images/topics/transactions/signature2.svg @@ -0,0 +1,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/static/images/topics/transactions/transaction1.svg b/static/images/topics/transactions/transaction1.svg new file mode 100644 index 0000000..7b78e8b --- /dev/null +++ b/static/images/topics/transactions/transaction1.svg @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + diff --git a/static/images/topics/transactions/transaction2.svg b/static/images/topics/transactions/transaction2.svg new file mode 100644 index 0000000..a6d5c01 --- /dev/null +++ b/static/images/topics/transactions/transaction2.svg @@ -0,0 +1,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/static/images/topics/transactions/transaction3.svg b/static/images/topics/transactions/transaction3.svg new file mode 100644 index 0000000..590663f --- /dev/null +++ b/static/images/topics/transactions/transaction3.svg @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/static/images/topics/transactions/transaction4.svg b/static/images/topics/transactions/transaction4.svg new file mode 100644 index 0000000..d7e529e --- /dev/null +++ b/static/images/topics/transactions/transaction4.svg @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/static/images/topics/transactions/utxo-accountModel.svg b/static/images/topics/transactions/utxo-accountModel.svg new file mode 100644 index 0000000..9761220 --- /dev/null +++ b/static/images/topics/transactions/utxo-accountModel.svg @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +