Skip to main content

Error

Enum Error 

Source
pub enum Error {
Show 44 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, }, 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, },
}
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

§requested: usize

Number of bits the caller requested.

§available: usize

Number of bits actually available in the stream.

§

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.

Fields

§got: u8

Version value parsed from the wire.

§

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.

Fields

§detail: String

Free-form description of the malformedness.

§

PathDepthExceeded

Path depth exceeds MAX_PATH_COMPONENTS (15).

Fields

§got: usize

Actual depth of the path.

§max: usize

Maximum allowed depth (15).

§

KeyCountOutOfRange

Key count n out of range. Per SPEC v0.30 §4: 1 ≤ n ≤ 32.

Fields

§n: u8

Actual key count provided.

§

DivergentPathCountMismatch

Divergent path count doesn’t match key count.

Fields

§n: u8

Expected key count.

§got: usize

Actual path count provided.

§

AltCountOutOfRange

Multipath alt-count out of range. Per SPEC v0.30 §8: 2 ≤ count ≤ 9.

Fields

§got: usize

Provided alt-count.

§

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.

Fields

§primary: u8

The raw 6-bit primary value read off the wire.

§

ThresholdOutOfRange

Threshold k out of range. Per SPEC v0.30 §4: 1 ≤ k ≤ 32.

Fields

§k: u8

Provided k value.

§

ChildCountOutOfRange

Variable-arity child count out of range. Per SPEC v0.30 §4: 1 ≤ count ≤ 32.

Fields

§count: usize

Provided child count.

§

KGreaterThanN

k > n in k-of-n threshold/multisig.

Fields

§k: u8

Threshold k.

§n: usize

Child count n.

§

TlvOrderingViolation

TLV ordering violation: a TLV tag was followed by a smaller-or-equal tag.

Fields

§prev: u8

Previous tag value.

§current: u8

Current tag value.

§

PlaceholderIndexOutOfRange

Placeholder index in TLV entry exceeds key count n.

Fields

§idx: u8

Provided index.

§n: u8

Key count n.

§

OverrideOrderViolation

Per-@N override entries within a TLV must be in ascending @N-index order.

Fields

§prev: u8

Previous index.

§current: u8

Current index.

§

EmptyTlvEntry

TLV entry has zero entries; encoder MUST omit empty TLVs per spec §7.5.

Fields

§tag: u8

Tag of the empty entry.

§

TlvLengthExceedsRemaining

TLV length exceeds remaining bits in stream.

Fields

§length: usize

Declared length.

§remaining: usize

Available bits.

§

PlaceholderNotReferenced

Placeholder @i was not referenced anywhere in the tree (BIP 388 well-formedness).

Fields

§idx: u8

The unreferenced placeholder index.

§n: u8

Key count.

§

PlaceholderFirstOccurrenceOutOfOrder

First-occurrence ordering violated (BIP 388 well-formedness).

Fields

§expected_first: u8

Expected placeholder index in canonical first-occurrence position.

§got_first: u8

Actual placeholder index encountered first.

§

MultipathAltCountMismatch

All multipaths in a template must share the same alt-count.

Fields

§expected: usize

Expected alt-count.

§got: usize

Mismatched alt-count.

§

ForbiddenTapTreeLeaf

Tap-script-tree leaf has a tag that is forbidden per spec §6.3.1.

Fields

§tag: u8

Primary 6-bit tag code (bytecode space) of the forbidden leaf.

§

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

§tag: Tag

The offending operator tag.

§context: ContextKind

Which tree-position the tag is forbidden in.

§

ChunkCountOutOfRange

Chunk count out of range. Per SPEC v0.30 §2.5: 1 ≤ count ≤ 64.

Fields

§count: u8

Provided count.

§

ChunkIndexOutOfRange

Chunk index ≥ count; require index < count.

Fields

§index: u8

Provided index.

§count: u8

Provided count.

§

ChunkSetIdOutOfRange

Chunk-set-id exceeds 20-bit range.

Fields

§id: u32

Provided ID.

§

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).

Fields

§needed: usize

Number of chunks needed.

§

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.

Fields

§got: usize

Provided chunk count.

§expected: usize

Expected chunk count.

§

ChunkIndexGap

Chunk index gap: expected index N, got M.

Fields

§expected: u8

Expected index in the sequence.

§got: u8

Actual index encountered.

§

ChunkSetIdMismatch

Chunk-set-id mismatch between expected and reassembled-then-derived.

Fields

§expected: u32

Expected (from chunks).

§derived: u32

Derived (from reassembled payload).

§

VarintOverflow

LP4-ext varint value exceeds single-extension payload range (29 bits).

Fields

§value: u32

The offending value.

§

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.

Fields

§idx: u8

The placeholder index for which an explicit origin is required.

§

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.

Fields

§reserved_bits: u8

The reserved-bit field (bits 2..7) of the offending presence byte.

§

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.

Fields

§idx: u8

The placeholder index whose xpub failed to parse.

§

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.

Fields

§idx: u8

The placeholder index whose xpub is absent.

§

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

§chain: u32

The provided chain index.

§alt_count: usize

The number of alternatives in the use-site multipath (0 when no multipath component is present).

§

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.

Fields

§detail: String

Free-form description of the underlying failure.

§

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.

Fields

§depth: u8

Current recursion depth at which the cap fired.

§max: u8

Maximum allowed depth.

§

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

§chunk_index: usize

0-indexed position of the offending chunk in the caller’s &[&str] slice.

§bound: u8

The BCH singleton bound 2t = 8 (i.e. 4 correctable errors).

Trait Implementations§

Source§

impl Debug for Error

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Error

Source§

fn fmt(&self, __formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Error for Error

1.30.0 · Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl PartialEq for Error

Source§

fn eq(&self, other: &Error) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for Error

Source§

impl StructuralPartialEq for Error

Auto Trait Implementations§

§

impl Freeze for Error

§

impl RefUnwindSafe for Error

§

impl Send for Error

§

impl Sync for Error

§

impl Unpin for Error

§

impl UnsafeUnpin for Error

§

impl UnwindSafe for Error

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.