| Crates.io | bitcoin-bosd |
| lib.rs | bitcoin-bosd |
| version | 0.4.2 |
| created_at | 2025-01-09 15:31:40.547395+00 |
| updated_at | 2025-06-02 11:12:09.125625+00 |
| description | Rust implementation of a Bitcoin binary output script descriptor (BOSD) |
| homepage | |
| repository | https://github.com/alpenlabs/bitcoin-bosd |
| max_upload_size | |
| id | 1510038 |
| size | 126,980 |
OP_RETURN outputs.serde and borsh serialization.bitcoin::ScriptBuf.[!NOTE] The full specification is available in the BOSD Specification document.
BOSD uses a simple binary format consisting of a 1-byte type tag followed by a cryptographic payload. The format is designed to be compact and efficiently represent standard Bitcoin output types:
| Type | Payload Length(s) | Payload Interpretation | Spend Type | Mainnet Address Prefix |
|---|---|---|---|---|
| 0 | ..=80 | OP_RETURN payload |
(N/A) | (N/A) |
| 1 | 20 | pubkey hash | P2PKH | 1... |
| 2 | 20 | script hash | P2SH | 3... |
| 3 | 20, 32 | SegWit v0 hash | P2WPKH, P2WSH | bc1q... |
| 4 | 32 | SegWit v1 public key | P2TR | bc1p... |
034d6151263d87371392bb1b60405392c5ba2e3297 $\iff$ bc1qf4s4zf3asum38y4mrdsyq5ujckazuv5hczg979041234123412341234123412341234123412341234123412341234123412341234
$\iff$ bc1pzg6pydqjxsfrgy35zg6pydqjxsfrgy35zg6pydqjxsfrgy35zg6qf6d5seOP_RETURN payload given a hex string that is less than 80 bytes:
00deadbeefcafebabe $\iff$ RETURN PUSHDATA(deadbeefcafebabe)use bitcoin::Network;
use bitcoin_bosd::Descriptor;
// Parse from binary
let desc = Descriptor::from_bytes(&[0x04, /* 32 bytes of pubkey */])?;
// Convert to Address
let address = desc.to_address(Network::Bitcoin)?;
// Convert to ScriptBuf
let script = desc.to_script()?;
// Serialize/deserialize
let json = serde_json::to_string(&desc)?;
let serde_bytes = serde_json::to_vec(&desc)?;
let borsh_bytes = borsh::to_vec(&desc)?;
| Feature | Default? | standalone | Description |
|---|---|---|---|
address |
✓ | ✓ | Adds Bitcoin Address and ScriptBuf functionality |
arbitrary |
needs address |
Adds Arbitrary to generate random descriptors for fuzzing and property testing |
|
borsh |
✓ | Adds descriptor serialization and deserialization via borsh |
|
serde |
✓ | ✓ | Adds descriptor serialization and deserialization via serde |
Contributions are generally welcome. If you intend to make larger changes please discuss them in an issue before opening a PR to avoid duplicate work and architectural mismatches.
For more information please see CONTRIBUTING.md.
This work is dual-licensed under MIT and Apache 2.0. You can choose between one of them if you use this work.