Skip to main content

encode_5bit_to_string

Function encode_5bit_to_string 

Source
pub fn encode_5bit_to_string(data_5bit: &[u8]) -> Result<String, Error>
Expand description

Encode a 5-bit-symbol data stream as a complete mk1 string.

The data stream is the concatenation header_symbols || bytes_to_5bit(payload_bytes) where header_symbols is the 2-symbol single-string header or the 8-symbol chunked header (closure Q-5). The BCH code variant (regular or long) is auto-selected from the resulting data-part length per BIP 93: regular for ≤93-symbol data parts, long for 96–108-symbol data parts. Lengths in the reserved-invalid 94–95 gap or outside the BIP 93 valid range return [Error::InvalidStringLength].

Per the v0.1 emit policy described in design/IMPLEMENTATION_PLAN_mk_v0_1.md §5.4, callers control fragment sizing so that each chunked fragment lands within long-code territory. Single-string mk1 may pick regular or long based on bytecode size.

Returns the full string starting with crate::consts::HRP and the BIP 173 separator ("mk1").