Rust bitcoin

From claude-dev-suite/claude-dev-suite · View interactive version

Rust bitcoin is an AI agent skill from the GitHub repository claude-dev-suite/claude-dev-suite. rust-bitcoin: Rust crate for Bitcoin primitives. Tx, Block, Script, Address, Network, key types, PSBT, BIP32. Foundation for BDK, LDK, miniscript-rs. USE WHEN: building Bitcoin apps in Rust, parsing/constructing txs, working with addresses + scripts.

How to use this skill

Skill file

rust-bitcoin

The foundation Rust crate for Bitcoin. Used by BDK, LDK, miniscript-rs,

electrs, etc. Stable, comprehensive.

Repo: github.com/rust-bitcoin/rust-bitcoin.

Install

[dependencies]
bitcoin = "0.32"   # resolves to 0.32.102 (July 2026)

Two 0.32 lines ship in parallel as of September 2026: 0.32.11

(2026-07-22, MSRV 1.56.1) for old toolchains, and the 0.32.10x line

(latest 0.32.102, 2026-07-15), which since 0.32.101 (2026-06-24)

has MSRV 1.60.0 and exposes the optional encoding feature wrapping

the sans-IO consensus_encoding crate — enabling that feature raises

the MSRV to 1.74.0. 0.32.100 was yanked because its blanket 1.74.0

MSRV bump was too aggressive.

0.33-beta and the 1.0 track

0.33.0-beta (2026-02-23) is the testing release for the next major

API; upstream states it will never release a plain 0.33.0 — the

next tag is 0.34.0-beta, and the -beta suffix drops once

bitcoin-units, bitcoin-primitives and bitcoin-consensus-encoding

reach 1.0.0. Of those three, only bitcoin-consensus-encoding has

shipped 1.x (1.2.0, 2026-08-13); as of September 2026

bitcoin-primitives is at 0.103.0 and bitcoin-units at 0.5.0

stable, with 1.0.0-rc builds published.

Breaking changes already in 0.33.0-beta:

21 million BTC instead of u64::MAX, and Amount::from_sat returns

Result<Amount, OutOfRangeError>.

Key types

the crate root).

ExtendedPubKey survive only as aliases deprecated since 0.31.

Quick examples

Address generation

use bitcoin::{Address, CompressedPublicKey, Network};
use bitcoin::secp256k1::{Secp256k1, SecretKey, PublicKey};

let secp = Secp256k1::new();
let sk = SecretKey::from_slice(&[1u8; 32]).unwrap();
let pk = PublicKey::from_secret_key(&secp, &sk);
let addr = Address::p2wpkh(&CompressedPublicKey(pk), Network::Bitcoin);
println!("{}", addr);   // bc1q...

Address::p2wpkh(pk: &CompressedPublicKey, hrp: impl Into<KnownHrp>)

returns Address directly, not a Result — no unwrap(). A

bitcoin::PublicKey may be uncompressed, so converting one is fallible

(CompressedPublicKey::try_from).

Parse + construct tx

use bitcoin::{Transaction, consensus::encode};

let raw = hex::decode("01000000...").unwrap();
let tx: Transaction = encode::deserialize(&raw).unwrap();
println!("txid: {}", tx.compute_txid());

let bytes = encode::serialize(&tx);

Sign with secp256k1

let secp = Secp256k1::new();
let msg = bitcoin::secp256k1::Message::from_digest_slice(&hash).unwrap();
let sig = secp.sign_ecdsa(&msg, &sk);

Modules

Use cases

Common pitfalls

take &Script.

See also

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.