Address API Reference
The Address module provides utilities for encoding, decoding, and validating Midnight specific Bech32m addresses.
Bech32m Encoding
noxipher.address.bech32m
Bech32m address encoding/decoding for Midnight.
Implements BIP-350 Bech32m (NOT Bech32 v0 from BIP-173). Key difference: Bech32m uses constant 0x2bc830a3 instead of 1.
HRP table from docs.midnight.network (Apr 2026): Unshielded: mn_addr, mn_addr_preprod, mn_addr_preview, mn_addr_undeployed Shielded: mn_shield-addr, mn_shield-addr_preprod, mn_shield-addr_preview, mn_shield-addr_undeployed DUST: mn_dust, mn_dust_preprod, mn_dust_preview, mn_dust_undeployed
bech32m_decode(bech)
Decode Bech32m string → (hrp, data5). Raises AddressError on failure.
Source code in src/noxipher/address/bech32m.py
bech32m_encode(hrp, data5)
Encode HRP + 5-bit data to Bech32m string.
decode_address(address)
Decode Bech32m address.
Returns:
| Type | Description |
|---|---|
tuple[str, Network, bytes]
|
(addr_type, network, payload_bytes) |
Source code in src/noxipher/address/bech32m.py
encode_address(payload, addr_type, network)
Encode raw bytes to Bech32m address string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
payload
|
bytes
|
Raw address bytes (32 bytes for unshielded/dust, 64 bytes for shielded) |
required |
addr_type
|
str
|
"unshielded" | "shielded" | "dust" |
required |
network
|
Network
|
Target network |
required |
Returns:
| Type | Description |
|---|---|
str
|
Bech32m address string (e.g. "mn_addr_preprod1...") |