Skip to content

Latest commit

 

History

History
247 lines (99 loc) · 6.94 KB

bitcoin_address.md

File metadata and controls

247 lines (99 loc) · 6.94 KB

Module 0x3::bitcoin_address

Struct BitcoinAddress

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

Constants

const ErrorAddressBytesLen: u64 = 1;

const P2PKH_ADDR_BYTE_LEN: u64 = 21;

const P2SH_ADDR_BYTE_LEN: u64 = 21;

const PUBKEY_HASH_LEN: u64 = 20;

const SCRIPT_HASH_LEN: u64 = 20;

Function new_p2pkh

public fun new_p2pkh(pubkey_hash: vector<u8>): bitcoin_address::BitcoinAddress

Function new_p2sh

public fun new_p2sh(script_hash: vector<u8>): bitcoin_address::BitcoinAddress

Function new_witness_program

Function from_bytes

Function is_p2pkh

public fun is_p2pkh(addr: &bitcoin_address::BitcoinAddress): bool

Function is_p2sh

public fun is_p2sh(addr: &bitcoin_address::BitcoinAddress): bool

Function is_witness_program

Function is_empty

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

Function as_bytes

Function into_bytes

Function to_bech32