pubkey_hash_to_address
Generates a Bitcoin address from a public key hash for the specified address type and network.
This function generates addresses for address types that can be derived directly from
a public key hash: P2PKH, P2SH, and P2WPKH. For P2WSH and P2TR, use public_key_to_address
instead as they require additional information beyond the pubkey hash.
Arguments
pubkey_hash- The 20-byte public key hash (HASH160 of public key)address_type- The type of Bitcoin address to generate (P2PKH, P2SH, or P2WPKH)network- The Bitcoin network (Mainnet, Testnet, or Regtest)
Returns
BitcoinAddress- Complete address structure including encoded address and script_pubkey
Panics
Panics if address_type is P2WSH or P2TR (use public_key_to_address for these types)
Fully qualified path: alexandria_btc::address::pubkey_hash_to_address
pub fn pubkey_hash_to_address(
pubkey_hash: Array<u8>, address_type: BitcoinAddressType, network: BitcoinNetwork,
) -> BitcoinAddress