Skip to content

Latest commit

 

History

History
124 lines (56 loc) · 3.3 KB

bech32.md

File metadata and controls

124 lines (56 loc) · 3.3 KB

Module 0x2::bech32

Module which defines bech32 functions.

Constants

const E_DECODE_FAILED: u64 = 2;

const E_ENCODE_FAILED: u64 = 1;

const E_INVALID_BIP_CODE: u64 = 3;

const E_INVALID_NETWORK: u64 = 4;

const E_INVALID_WITNESS_VERSION: u64 = 5;

Function encode

@param hrp: human-readable part in string @param data: arbitrary data to be encoded. Encode arbitrary data using string as the human-readable part and append a bech32 checksum.

public fun encode(bip: u16, hrp: vector<u8>, data: vector<u8>): vector<u8>

Function segwit_encode

@param network: network to be selected, i.e. bc, tb, or bcrt @param witness_version: segwit witness version. 0 for bech32, 1 for bech32m and taproot, and 2-16 is included. @param data: arbitrary data to be encoded. Encode arbitrary data to a Bitcoin address using string as the network, number as the witness version

public fun segwit_encode(network: vector<u8>, witness_version: u8, data: vector<u8>): vector<u8>

Function decode

@param hrp: human-readable part bytes to be used as a decoding input @param encoded: encoded bytes to be decoded as data Decode a bech32 encoded string that includes a bech32 checksum.

public fun decode(hrp: vector<u8>, encoded: vector<u8>): vector<u8>

Function segwit_decode

@param hrp: human-readable part bytes to be used as a decoding input @param witness_ascii_version: segwit witness ASCII version to be used as a decoding input @param encoded: encoded bytes to be decoded as data Decode an encoded Bitcoin address

public fun segwit_decode(hrp: vector<u8>, witness_ascii_version: u8, encoded: vector<u8>): vector<u8>