A Rust-based command-line tool that decodes a raw Bitcoin transaction hex and outputs a structured JSON view of the transaction.
This tool is intentionally offline-friendly and index-free: it decodes Bitcoin transactions directly from their serialized bytes, following consensus rules—no RPC calls, no explorers, no lookup tables.
Bitcoin transactions are not opaque objects that require external services to understand. They are deterministic binary messages.
This tool exists to make that reality obvious.
-
Raw Transaction Decoding Decodes a full serialized Bitcoin transaction directly from raw hex bytes.
-
Consensus-Accurate Parsing Implements Bitcoin’s consensus encoding rules:
- little-endian integers
- CompactSize (varint) encoding
- legacy and SegWit transaction formats
-
TxID & wTxID Calculation
- Computes the legacy txid (double SHA-256, no witness)
- Computes wtxid for SegWit transactions (includes witness data)
-
Structured JSON Output Outputs a clean, human-readable JSON view:
- inputs / outputs
- scripts (hex)
- values (sats + BTC string, no floats)
- witness data (when present)
-
Clear Error Reporting Explicit errors for:
- invalid hex
- truncated or malformed transactions
- invalid SegWit flags
- trailing bytes after decode
-
TxID Detection Guardrail If a 64-hex-character string is provided, the tool warns that it appears to be a txid, not raw transaction data.
This tool deliberately does not:
- fetch transactions by txid
- query Bitcoin Core or any external service
- depend on indexes, explorers, or databases
It decodes only what you already have.
- Rust (stable, current)
Clone the repository and build:
git clone https://github.com/th3bat/transaction-decoder.git
cd transaction-decoder
cargo build --releaseProvide a raw Bitcoin transaction hex (optionally 0x-prefixed):
./target/release/transaction-decoder "<raw_transaction_hex>"Example:
./target/release/transaction-decoder \
"02000000000101e1b5...00000000"If you pass a txid (32 bytes / 64 hex characters), the program will respond with:
That looks like a txid.
This decoder expects raw transaction hex.
You must supply the full serialized transaction, not its hash.
The program prints a pretty-formatted JSON representation including:
txidwtxid(when applicable)- transaction version and locktime
- inputs (prevout, scriptSig, sequence, witness)
- outputs (value in sats and BTC, scriptPubKey)
Bitcoin’s protocol does not rely on:
- databases
- indexes
- REST APIs
It relies on:
- bytes
- ordering
- hashing
- rules that never change
This tool is a small reminder of that.