sigil-bitcoin-encoding

sigil bitcoin encoding

(sigil bitcoin encoding) — Bitcoin address encoding formats

12 public exports

hex-encode

procedure

Encode a bytevector as lowercase hexadecimal text.

hex-decode

procedure

Decode an even-length hexadecimal string into a bytevector. Raises an error for odd-length input or invalid hex characters.

base58-encode

procedure

Encode a bytevector with Bitcoin's Base58 alphabet. Leading zero bytes are preserved as leading `1` characters.

base58-decode

procedure

Decode a Bitcoin Base58 string into a bytevector. Raises an error if the string contains characters outside the Bitcoin Base58 alphabet.

base58check-encode

procedure

Encode a Base58Check payload with a one-byte version prefix. The checksum is the first four bytes of HASH256(version || payload).

base58check-decode

procedure

Decode a Base58Check string. Returns `(version . payload)` and raises an error on checksum failure.

bech32-encode

procedure

Encode a Bech32 string using the BIP173 checksum constant. `hrp` is the human-readable part and `data` is a bytevector of 5-bit values.

bech32-decode

procedure

Decode a Bech32 string. Returns `(hrp . data)` where `data` excludes the six checksum values.

bech32m-encode

procedure

Encode a Bech32m string using the BIP350 checksum constant.

bech32m-decode

procedure

Decode a Bech32m string. Returns `(hrp . data)` where `data` excludes the six checksum values.

segwit-encode

procedure

Encode a native SegWit address for a witness version and program. Version 0 uses Bech32. Versions 1 through 16 use Bech32m.

segwit-decode

procedure

Decode a native SegWit address. Returns `(hrp version . program)` and validates the checksum variant required by the witness version.