Skip to main content

md_codec/
lib.rs

1//! # `md-codec`
2//!
3//! Reference implementation of the **Mnemonic Descriptor (MD)** format —
4//! an engravable backup format for [BIP 388 wallet policies][bip388].
5//!
6//! [bip388]: https://github.com/bitcoin/bips/blob/master/bip-0388.mediawiki
7//!
8//! v0.30 wire format: bit-aligned payload, sparse per-`@N` TLV overrides,
9//! 5-bit single-payload header (4-bit version=4 + `divergent_paths` flag),
10//! 6-bit bytecode tag space, decoder auto-dispatch between single and chunked
11//! payloads via the first 5-bit symbol's bit 0, symbol-aligned codex32
12//! wrapping with HRP `"md"`. See `design/SPEC_v0_30_wire_format.md` for the
13//! normative spec.
14
15pub mod bch;
16pub mod bch_decode;
17
18pub mod bitstream;
19pub mod canonical_origin;
20pub mod canonicalize;
21pub mod chunk;
22pub mod codex32;
23pub mod decode;
24pub mod derive;
25pub mod encode;
26pub mod error;
27pub mod header;
28pub mod identity;
29mod nums;
30pub mod origin_path;
31pub mod phrase;
32// The `@N`-template renderer is pure AST string-walking (no miniscript/derive
33// dependency); it sources the NUMS H-point from the ungated `nums` module, so
34// it is unconditional — available with or without the `derive` feature.
35pub mod render;
36pub mod tag;
37pub mod test_vectors;
38pub mod tlv;
39#[cfg(feature = "derive")]
40pub mod to_miniscript;
41pub mod tree;
42pub mod use_site_path;
43pub mod validate;
44pub mod varint;
45
46pub use canonicalize::canonicalize_placeholder_indices;
47pub use chunk::{
48    ChunkHeader, CorrectionDetail, decode_with_correction, derive_chunk_set_id, reassemble,
49    reassemble_with_opts, split,
50};
51pub use decode::{
52    DecodeOpts, decode_md1_string, decode_md1_string_with_opts, decode_payload,
53    decode_payload_with_opts,
54};
55pub use encode::{Descriptor, encode_md1_string, encode_payload};
56pub use error::Error;
57pub use header::Header;
58pub use identity::{
59    Md1EncodingId, WalletDescriptorTemplateId, WalletPolicyId, compute_md1_encoding_id,
60    compute_wallet_descriptor_template_id, compute_wallet_policy_id, validate_presence_byte,
61};
62pub use origin_path::{OriginPath, PathComponent, PathDecl, PathDeclPaths};
63pub use phrase::Phrase;
64pub use render::{RenderError, descriptor_to_template};
65pub use tag::Tag;
66pub use tlv::TlvSection;
67#[cfg(feature = "derive")]
68pub use to_miniscript::{
69    has_hardened_use_site, to_miniscript_descriptor, to_miniscript_descriptor_multipath,
70};