Keyboard shortcuts

Press or to navigate between chapters

Press ? to show this help

Press Esc to hide this help

public_key_to_address

Generates a Bitcoin address from a public key for the specified address type and network.

This is the primary address generation function that handles all Bitcoin address types including legacy (P2PKH, P2SH) and SegWit (P2WPKH, P2WSH, P2TR) formats.

Arguments

  • public_key - The Bitcoin public key (x, y coordinates and compression flag)
  • address_type - The type of Bitcoin address to generate
  • network - The Bitcoin network (Mainnet, Testnet, or Regtest)

Returns

  • BitcoinAddress - Complete address structure including encoded address and script_pubkey

Fully qualified path: alexandria_btc::address::public_key_to_address

pub fn public_key_to_address(
    public_key: BitcoinPublicKey, address_type: BitcoinAddressType, network: BitcoinNetwork,
) -> BitcoinAddress