pub enum Error {
Show 49 variants
BitStreamTruncated {
requested: usize,
available: usize,
},
WireVersionMismatch {
got: u8,
},
MalformedHeader {
detail: String,
},
PathDepthExceeded {
got: usize,
max: usize,
},
KeyCountOutOfRange {
n: u8,
},
DivergentPathCountMismatch {
n: u8,
got: usize,
},
AltCountOutOfRange {
got: usize,
},
TagOutOfRange {
primary: u8,
},
ThresholdOutOfRange {
k: u8,
},
ChildCountOutOfRange {
count: usize,
},
KGreaterThanN {
k: u8,
n: usize,
},
TlvOrderingViolation {
prev: u8,
current: u8,
},
PlaceholderIndexOutOfRange {
idx: u8,
n: u8,
},
OverrideOrderViolation {
prev: u8,
current: u8,
},
EmptyTlvEntry {
tag: u8,
},
TlvLengthExceedsRemaining {
length: usize,
remaining: usize,
},
PlaceholderNotReferenced {
idx: u8,
n: u8,
},
PlaceholderFirstOccurrenceOutOfOrder {
expected_first: u8,
got_first: u8,
},
MultipathAltCountMismatch {
expected: usize,
got: usize,
},
BaselineUseSiteOverride {
idx: u8,
},
RedundantUseSiteOverride {
idx: u8,
},
ForbiddenTapTreeLeaf {
tag: u8,
},
OperatorContextViolation {
tag: Tag,
context: ContextKind,
},
ChunkCountOutOfRange {
count: u8,
},
ChunkIndexOutOfRange {
index: u8,
count: u8,
},
ChunkSetIdOutOfRange {
id: u32,
},
ChunkHeaderChunkedFlagMissing,
ChunkCountExceedsMax {
needed: usize,
},
Codex32DecodeError(String),
Codex32EncodeError(String),
ChunkSetEmpty,
ChunkSetInconsistent,
ChunkSetIncomplete {
got: usize,
expected: usize,
},
ChunkIndexGap {
expected: u8,
got: u8,
},
ChunkSetIdMismatch {
expected: u32,
derived: u32,
},
VarintOverflow {
value: u32,
},
MissingExplicitOrigin {
idx: u8,
},
InvalidPresenceByte {
reserved_bits: u8,
},
InvalidXpubBytes {
idx: u8,
},
MissingPubkey {
idx: u8,
},
ChainIndexOutOfRange {
chain: u32,
alt_count: usize,
},
HardenedPublicDerivation,
AddressDerivationFailed {
detail: String,
},
NUMSSentinelConflict,
DecodeRecursionDepthExceeded {
depth: u8,
max: u8,
},
TooManyErrors {
chunk_index: usize,
bound: u8,
},
PayloadTooLongForSingleString {
data_symbols: usize,
max: usize,
},
ChunkSymbolCountOutOfRange {
chunk_index: usize,
symbols: usize,
max: usize,
},
StringSymbolCountOutOfRange {
symbols: usize,
max: usize,
},
}Expand description
Errors produced by md-codec wire-format components.
Variants§
BitStreamTruncated
A read of requested bits was attempted but only available bits remained.
Fields
WireVersionMismatch
Wire-format version field doesn’t match v0.30 (=4). Returned when a payload or chunk-header is read with a version value outside the accepted v0.30 set. Per SPEC v0.30 §2.4 + §2.5 + §11.1.
MalformedHeader
Header malformed in a way other than version mismatch — e.g., chunked- flag inconsistent with caller context, or chunk-header internal field out of range. Per SPEC v0.30 §11.1.
PathDepthExceeded
Path depth exceeds MAX_PATH_COMPONENTS (15).
KeyCountOutOfRange
Key count n out of range. Per SPEC v0.30 §4: 1 ≤ n ≤ 32.
DivergentPathCountMismatch
Divergent path count doesn’t match key count.
AltCountOutOfRange
Multipath alt-count out of range. Per SPEC v0.30 §8: 2 ≤ count ≤ 9.
TagOutOfRange
Tag value outside the allocated v0.30 set: 6-bit primary in reserved
range 0x24..=0x3E, or extension prefix 0x3F followed by an unrecognized
4-bit subcode 0x00..=0x0F (the entire extension subspace is reserved
in v0.30). primary carries the raw 6-bit value read off the wire
(0x3F for extension-subspace failures); the 4-bit subcode is consumed
but not reported. Per SPEC v0.30 §3.2 and §11.1.
ThresholdOutOfRange
Threshold k out of range. Per SPEC v0.30 §4: 1 ≤ k ≤ 32.
ChildCountOutOfRange
Variable-arity child count out of range. Per SPEC v0.30 §4: 1 ≤ count ≤ 32.
KGreaterThanN
k > n in k-of-n threshold/multisig.
TlvOrderingViolation
TLV ordering violation: a TLV tag was followed by a smaller-or-equal tag.
PlaceholderIndexOutOfRange
Placeholder index in TLV entry exceeds key count n.
OverrideOrderViolation
Per-@N override entries within a TLV must be in ascending @N-index order.
EmptyTlvEntry
TLV entry has zero entries; encoder MUST omit empty TLVs per spec §7.5.
TlvLengthExceedsRemaining
TLV length exceeds remaining bits in stream.
PlaceholderNotReferenced
Placeholder @i was not referenced anywhere in the tree (BIP 388 well-formedness).
PlaceholderFirstOccurrenceOutOfOrder
First-occurrence ordering violated (BIP 388 well-formedness).
Fields
MultipathAltCountMismatch
All multipaths in a template must share the same alt-count.
BaselineUseSiteOverride
A use_site_path_overrides entry was keyed on @0. @0 is the
canonical baseline (Descriptor::use_site_path) and cannot be
overridden — an @0 entry is a non-canonical / adversarial wire
(our encoders only push overrides for i ≥ 1). Per the D5(a) decode
canonical-form check (restore-md1-per-key-use-site SPEC §4.1).
RedundantUseSiteOverride
A use_site_path_overrides entry’s UseSitePath equaled the
resolved baseline (Descriptor::use_site_path). A redundant override
is non-canonical (our encoders push an override only when it DIFFERS
from the baseline) and is rejected at decode. Per the D5(a) decode
canonical-form check.
ForbiddenTapTreeLeaf
Tap-script-tree leaf has a tag that is forbidden per spec §6.3.1.
OperatorContextViolation
Operator appears in a forbidden context per SPEC v0.30 §11.
TopLevel is enforced decoder-side at decode_payload; TapLeaf is
covered by the narrower Error::ForbiddenTapTreeLeaf; MultiBody is
structurally unreachable post-v0.30 Phase C (multi-family bodies carry
raw kiw-bit indices, not child tags).
Fields
context: ContextKindWhich tree-position the tag is forbidden in.
ChunkCountOutOfRange
Chunk count out of range. Per SPEC v0.30 §2.5: 1 ≤ count ≤ 64.
ChunkIndexOutOfRange
Chunk index ≥ count; require index < count.
ChunkSetIdOutOfRange
Chunk-set-id exceeds 20-bit range.
ChunkHeaderChunkedFlagMissing
Chunk header missing chunked-flag. Per SPEC v0.30 §2.2: bit 0 of the first 5-bit symbol of a chunked payload is the chunked-flag (followed by the 4-bit version field); it MUST be 1 in every chunk header.
ChunkCountExceedsMax
Encoding requires more chunks than the spec maximum (64).
Codex32DecodeError(String)
Codex32 decode error (HRP mismatch, alphabet violation, BCH verification failure).
Codex32EncodeError(String)
Codex32 encode error (BCH layer failure).
ChunkSetEmpty
Chunk set is empty (no strings provided to reassemble).
ChunkSetInconsistent
Chunks in the set disagree on version, chunk-set-id, or count.
ChunkSetIncomplete
Chunk set incomplete: got fewer chunks than expected.
ChunkIndexGap
Chunk index gap: expected index N, got M.
ChunkSetIdMismatch
Chunk-set-id mismatch between expected and reassembled-then-derived.
VarintOverflow
LP4-ext varint value exceeds single-extension payload range (29 bits).
MissingExplicitOrigin
A non-canonical wrapper has no explicit origin path for some @N,
either via OriginPathOverrides or a populated path_decl entry,
and canonical_origin(&d.tree) is None. Per spec v0.13 §6.3.
InvalidPresenceByte
presence_byte had non-zero reserved bits (bits 2..7) inside a
WalletPolicyId canonical-record preimage. Per spec v0.13 §5.3:
encoders MUST set reserved bits to 0 and decoders MUST reject
inputs with non-zero reserved bits. v0.13’s encoder masks reserved
bits explicitly when building the hash preimage; the helper
crate::identity::validate_presence_byte enforces the
decoder-side contract for canonical-record consumers.
InvalidXpubBytes
A Pubkeys TLV entry’s 33-byte compressed-pubkey field (bytes
32..65 of the 65-byte xpub payload) failed to parse as a valid
secp256k1 point. The 32-byte chain code prefix is unvalidated.
Per spec v0.13 §6.4.
MissingPubkey
Address derivation requires a populated Pubkeys TLV entry for
every @N; this descriptor is missing one (template-only or
partial-keys mode). v0.14+ derivation surface only.
ChainIndexOutOfRange
Descriptor::derive_address was called with a chain index
outside the use-site multipath alt-count (or non-zero when no
multipath is present).
Fields
HardenedPublicDerivation
Address derivation requires non-hardened use-site components, but this descriptor’s use-site path declares a hardened alternative or hardened wildcard. BIP 32 forbids hardened derivation from a public key, so an xpub-only restore cannot produce addresses for this wallet.
AddressDerivationFailed
Address derivation failed at the miniscript layer (or in the
AST → miniscript converter). Carries a free-form detail string
describing the underlying error — typically a miniscript::Error,
a Tr/Wsh constructor failure (type-check / context error), or
an arity/context mismatch raised by the converter.
NUMSSentinelConflict
Inside a tr() body, is_nums = false was paired with a key_index
out of range (key_index >= n). Per SPEC v0.30 §7 + §11: the
placeholder-index range is 0..n strictly; the v0.x NUMS sentinel
slot at key_index = n is gone (NUMS is now flag-driven via
Body::Tr.is_nums). Raised by validate_placeholder_usage when the
in-tr() overflow condition is hit.
DecodeRecursionDepthExceeded
Decode-side recursion depth exceeded the hardening cap.
read_node calls itself recursively for tags with child bodies
(Tag::Sh, Tag::AndV, Tag::TapTree, Tag::Multi, Tag::Tr,
etc.); a hostile wire payload nesting these tags arbitrarily deep
would blow the Rust stack. The cap is shared across all recursive
tags as a generic anti-DOS hardening bound. v0.19 introduced.
TooManyErrors
BCH correction capacity exceeded: a chunk’s syndrome pattern
indicated more than t = 4 errors (BCH(93, 80, 8) singleton
bound 2t = 8), so a unique correction cannot be derived.
v0.34.0 introduced; raised by crate::decode_with_correction.
Atomic per plan §1 D28: any chunk failing this check fails the
whole multi-chunk call without partial output.
Fields
PayloadTooLongForSingleString
Encode-side cap (cycle-4 H6): a single codex32 string’s data part
exceeded the regular code’s REGULAR_DATA_SYMBOLS_MAX = 80 symbols.
The codex32 regular code is BCH(93, 80, 8); a single string therefore
carries at most 80 data symbols + 13 checksum = 93. wrap_payload
rejects an over-length payload (fail-closed) rather than emit an
un-decodable / aliasing-prone single string — callers needing more
capacity must use chunked encoding (--force-chunked / split()).
Fields
ChunkSymbolCountOutOfRange
Decode-side cap, correcting path (cycle-4 M4): a chunk handed to the
BCH-correcting decoder (decode_with_correction) had more than 93
symbols. The codex32 regular code’s generator β has order 93, so a
degree d and d + 93 alias in chien_search for an over-93-symbol
word — the correcting decoder would mis-correct at an aliased root.
Reject the out-of-domain chunk before correction (fail-closed).
Fields
StringSymbolCountOutOfRange
Decode-side cap, non-correcting path (cycle-4 I1 / §5.2.3): a single
md1 string handed to the non-correcting primitive (unwrap_string /
decode_md1_string) had more than 93 symbols. A clean (residue == 0)
over-length word is BCH-verifiable by the length-agnostic
bch_verify_regular but is structurally out-of-domain for the regular
code; reject it before BCH verification (fail-closed). No chunk index
(single string, not a chunk).
Trait Implementations§
impl Eq for Error
Source§impl Error for Error
impl Error for Error
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()