- Struct
BitcoinAddress
- Constants
- Function
new_p2pkh
- Function
new_p2sh
- Function
new_witness_program
- Function
from_bytes
- Function
is_p2pkh
- Function
is_p2sh
- Function
is_witness_program
- Function
is_empty
- Function
as_bytes
- Function
into_bytes
- Function
to_bech32
use 0x1::string;
use 0x1::vector;
BitcoinAddress is a struct that represents a Bitcoin address. We just keep the raw bytes of the address and do care about the network.
#[data_struct]
struct BitcoinAddress has copy, drop, store
const ErrorAddressBytesLen: u64 = 1;
const P2PKH_ADDR_BYTE_LEN: u64 = 21;
const P2PKH_ADDR_DECIMAL_PREFIX_MAIN: u8 = 0;
const P2PKH_ADDR_DECIMAL_PREFIX_TEST: u8 = 111;
const P2SH_ADDR_BYTE_LEN: u64 = 21;
const P2SH_ADDR_DECIMAL_PREFIX_MAIN: u8 = 5;
const P2SH_ADDR_DECIMAL_PREFIX_TEST: u8 = 196;
const PUBKEY_HASH_LEN: u64 = 20;
const SCRIPT_HASH_LEN: u64 = 20;
public fun new_p2pkh(pubkey_hash: vector<u8>): bitcoin_address::BitcoinAddress
public fun new_p2sh(script_hash: vector<u8>): bitcoin_address::BitcoinAddress
public fun new_witness_program(program: vector<u8>): bitcoin_address::BitcoinAddress
public fun from_bytes(bytes: vector<u8>): bitcoin_address::BitcoinAddress
public fun is_p2pkh(addr: &bitcoin_address::BitcoinAddress): bool
public fun is_p2sh(addr: &bitcoin_address::BitcoinAddress): bool
public fun is_witness_program(addr: &bitcoin_address::BitcoinAddress): bool
Empty address is a special address that is used to if we parse address failed from script.
public fun is_empty(addr: &bitcoin_address::BitcoinAddress): bool
public fun as_bytes(addr: &bitcoin_address::BitcoinAddress): &vector<u8>
public fun into_bytes(addr: bitcoin_address::BitcoinAddress): vector<u8>
public fun to_bech32(_addr: &bitcoin_address::BitcoinAddress): string::String