pub fn encode_payload(d: &Descriptor) -> Result<(Vec<u8>, usize), Error>Expand description
Encode a Descriptor into the canonical payload bit stream and return
(bytes, total_bit_count). The bytes are zero-padded; total_bit_count
is the exact unpadded length needed for round-trip decoding (see §3.7’s
“TLV section ends when codex32 total-length is exhausted” rule).
Per SPEC §6.1, the encoder canonicalizes BIP 388 placeholder
ordering before emitting bits: @i first appears in the tree before
@j for j > i. Canonicalization permutes the tree indices,
divergent path decl, and per-@N TLV maps atomically; if d is
already canonical it is unchanged.