Keyboard shortcuts

Press or to navigate between chapters

Press ? to show this help

Press Esc to hide this help

private_key_to_address

Generates a Bitcoin address from a private key for the specified address type.

This function derives the public key from the private key and generates the corresponding Bitcoin address based on the specified address type.

Arguments

  • private_key - The Bitcoin private key containing the key data, network, and compression flag
  • address_type - The type of Bitcoin address to generate (P2PKH, P2SH, P2WPKH, P2WSH, P2TR)

Returns

  • BitcoinAddress - Complete address structure with encoded address, script, and metadata

Fully qualified path: alexandria_btc::address::private_key_to_address

pub fn private_key_to_address(
    private_key: BitcoinPrivateKey, address_type: BitcoinAddressType,
) -> BitcoinAddress