Skip to content
btx
Open-source transaction intelligence

See exactly what
a transaction is doing.

btx turns raw Bitcoin bytes into inspectable, scriptable facts — from wire format and signatures to PSBT state and secp256k1 behavior.

Pure Python by default · Python 3.12+ · MIT licensed

transaction surface

raw bytes → useful facts

illustrative sample

txid

9f2c…8e44

format

segwit v0

inputs

02

outputs

02

verified

yes

sample wire preview92 bytes
02000000019f2c…8e440000000001
signature typeECDSA / DER
sighashSIGHASH_ALL
Protocol-aware BIP-141 · 143 · 174 · 340 · 341
Runtime boundary Core parsing stays offline-safe
Public surface CLI + Python API + source docs
The toolkit

Move from bytes to confidence.

Use the smallest surface that solves the problem: parse a transaction, inspect its signatures, work with a PSBT, or drop into the curve math.

Transaction parsing

Legacy, SegWit v0 (BIP-143) and Taproot (BIP-341) wire formats — parsed with deterministic, well-tested code paths.

01 public surface →

Signature extraction

ECDSA and Schnorr from every standard script type: P2PK, P2PKH, P2SH-multisig, P2WPKH, P2WSH, nested SegWit and Taproot key & script paths.

02 public surface →

Pluggable curve backends

Pure Python by default. Add libsecp256k1 through coincurve when you need a faster curve backend — the API stays the same.

03 public surface →

Nonce-reuse analysis

Linearised ECDSA (α, β) relations with both same-nonce and related-nonce recovery — the algebra behind real-world key extraction.

04 public surface →

PSBT pipeline

BIP-174 parse, edit, sign and extract. Process batches of PSBTs with ThreadPool or ProcessPool executors and graceful shutdown.

05 public surface →

Air-gap friendly

The core stays usable offline. Network access is isolated behind the optional services layer, so parsing does not require a blockchain connection.

06 public surface →
In your hands

One library,
the entire surface.

From a 60-character CLI to a deeply programmable Python API. Same precision underneath, no half-implemented corners.

  • ✓ Deterministic parsing — no hidden state, no global caches.
  • ✓ Frozen dataclasses with slots — value semantics out of the box.
  • ✓ All-public API — no chasing _foo through submodules.
$ btx extract 0200000001...
txid     = 9f2c…8e44
inputs   = 2
sigs     = 2
verified = true
  [0] P2WPKH  r=c8b3…4a2f  s=1d6e…92bc
  [1] P2TR    taproot key-path  z=7a91…05d3
python · btx
Architecture

Layered like the protocol itself.

Strict dependency rules mean each layer can be reasoned about and tested in isolation. No upward dependencies. No cross-layer leakage.

btx/

btx.cli

Typer-based command-line interface

decode extract linearize broadcast health

btx.services

Blockchain data providers + async batch

Blockstream Mempool.space blockchain.info generic HTTP

btx.signature

Extraction · linearisation · attacks · signing

ECDSA Schnorr nonce reuse verifier plugin registry

btx.descriptor · psbt · sighash · transaction · script

Transaction, script and PSBT machinery

BIP-174 BIP-341 BIP-143 miniscript builder

btx.encoding · field · curve

Byte-level, modular arithmetic & secp256k1 point ops

hex · varint · DER · SEC inverse · sqrt point · dispatch · batch

No upward refs

Higher layers never depend on lower ones — enforced by tests.

No network in core

Only the services layer touches I/O. Core is import-safe offline.

Pluggable backends

Pure-Python by default, libsecp256k1 for production throughput.

Security posture

Cryptography deserves
clear boundaries.

btx is built for environments where correctness matters. Each layer is testable in isolation, network access is explicit, and the public surface is designed to be inspected rather than guessed.

Offline-safe core

Network I/O is isolated behind the services layer. Parsing and cryptographic operations can be imported and exercised without a blockchain connection.

Typed, tested boundaries

The project uses type checking, property-based tests, vectors, coverage checks, and dependency auditing in its development workflow.

Explicit behavior

Public helpers, domain errors, CLI formats, and backend selection are documented so callers can reason about failures and fallbacks.

Curve reference secp256k1
Curve
y² = x³ + 7 (mod p)
Prime
p = 2²⁵⁶ − 2³² − 977
Order
n = 0xFFFFFFFF…FFFFFECD
Generator G
Gx = 0x79BE…02A7F3
Gy = 0x483A…D916CA
Conforms to SEC-2 v2.0 View spec
Reliability contract

Know what runs where.

The project keeps deterministic parsing and cryptographic primitives separate from network services, optional acceleration, and development tooling.

Compatibility

Python 3.12–3.14

The supported interpreter range is declared in the package metadata and exercised in CI.

Runtime boundary

Typer + stdlib core

The CLI uses Typer; parsing and curve code stay free of network clients.

Optional speed

coincurve backend

Install the optional extra when native libsecp256k1 throughput is appropriate.

Standards

BIP-aware

Transaction, sighash, PSBT, Schnorr, and Taproot paths follow documented Bitcoin standards.

Standards represented in the codebase

BIP-141·Segregated WitnessBIP-143·SegWit v0 sighashBIP-174·PSBT formatBIP-340·Schnorr signaturesBIP-341·TaprootRFC-6979·Deterministic ECDSA
Good fit for

One library. Many surfaces.

Use btx when Bitcoin primitives need to be reasoned about, tested, and made visible — not just called.

Security

Forensic analysis

Parse raw transactions, extract signatures, and investigate nonce reuse with a transparent Python workflow.

Wallets

Wallet engineering

Construct, sign, and broadcast transactions with immutable value semantics and a predictable public API.

Research

Research & education

Read the byte-level wire format with code that mirrors the BIPs. Ideal for teaching secp256k1 from the ground up.

Compliance

Compliance tooling

Batch-process PSBTs, classify scripts, and verify signatures deterministically — without touching the network.

Install from source

Start with the
repository.

btx is not published to PyPI yet. Use an isolated environment and install directly from GitHub while the release workflow is being finalized.

Python 3.12+MIT licenseTyper runtime
recommended · editable
git clone https://github.com/sachncs/btx.git && cd btx && python -m venv .venv && .venv/bin/python -m pip install -e .
direct Git install
python -m pip install 'btx @ git+https://github.com/sachncs/btx.git'