Expand description
Hex parsing + encoding helpers.
Replaces the s.strip_prefix("0x").unwrap_or(s); hex::decode(s)
pattern duplicated across nine sites in the wallet / runtime /
cli crates. All parsers accept 0x-prefixed and bare-hex input.
Enums§
Functions§
- is_hex
trueiffsparses as hex (with or without0x). Whenbyte_lenisSome(n), also requires the decoded length to equalnbytes — handy for “is this a valid 32-byte hash” checks.- parse_
hex - Parse a hex string (with or without
0xprefix) into bytes. - parse_
hex_ n - Parse a hex string into a fixed-size byte array. Errors when the
decoded length doesn’t match
N. Useful for IDs, hashes, public-key bytes that must be exactly N bytes. - to_hex
- Lowercase hex without
0xprefix. - to_
hex_ prefixed - Lowercase hex with
0xprefix.