Skip to Content

Address

class

Address

Class that implement address-related utility functions.

Constructor

constructor
Address(): Address

Returns:

Address

Methods

convertAdressToScriptPubkey
convertAdressToScriptPubkey(address: string): Buffer
Convert a given Bitcoin address into its corresponding script public key. Reference: https://github.com/buidl-bitcoin/buidl-python/blob/d79e9808e8ca60975d315be41293cb40d968626d/buidl/script.py#L607

Parameters:

address: string
Bitcoin address

Returns:

Buffer
Script public key of the given Bitcoin address
convertPubKeyIntoAddress
convertPubKeyIntoAddress(publicKey: Buffer, addressType: "p2pkh" | "p2sh-p2wpkh" | "p2wpkh" | "p2tr"): any
Convert a given public key into a corresponding Bitcoin address.

Parameters:

publicKey: Buffer
Public key for deriving the address, or internal public key for deriving taproot address
addressType: "p2pkh" | "p2sh-p2wpkh" | "p2wpkh" | "p2tr"
Bitcoin address type to be derived, must be either 'p2pkh', 'p2sh-p2wpkh', 'p2wpkh', or 'p2tr'

Returns:

any
Bitcoin address that correspond to the given public key in both mainnet and testnet
isP2PKH
isP2PKH(address: string): boolean
Check if a given Bitcoin address is a pay-to-public-key-hash (p2pkh) address.

Parameters:

address: string
Bitcoin address to be checked

Returns:

boolean
True if the provided address correspond to a valid P2PKH address, false if otherwise
isP2SH
isP2SH(address: string): boolean
Check if a given Bitcoin address is a pay-to-script-hash (P2SH) address.

Parameters:

address: string
Bitcoin address to be checked

Returns:

boolean
True if the provided address correspond to a valid P2SH address, false if otherwise
isP2TR
isP2TR(address: string): boolean
Check if a given Bitcoin address is a taproot address.

Parameters:

address: string
Bitcoin address to be checked

Returns:

boolean
True if the provided address is a taproot address, false if otherwise
isP2WPKH
isP2WPKH(address: string): boolean
Check if a given Bitcoin address is a pay-to-witness-public-key-hash (P2WPKH) address.

Parameters:

address: string
Bitcoin address to be checked

Returns:

boolean
True if the provided address correspond to a valid P2WPKH address, false if otherwise
isP2WPKHWitness
isP2WPKHWitness(witness: Buffer[]): boolean
Check if a given witness stack corresponds to a P2WPKH address.

Parameters:

witness: Buffer[]
Witness data associated with the toSign BIP-322 transaction

Returns:

boolean
True if the provided witness stack correspond to a valid P2WPKH address, false if otherwise
isSingleKeyP2TRWitness
isSingleKeyP2TRWitness(witness: Buffer[]): boolean
Check if a given witness stack corresponds to a single-key-spend P2TR address.

Parameters:

witness: Buffer[]
Witness data associated with the toSign BIP-322 transaction

Returns:

boolean
True if the provided address and witness stack correspond to a valid single-key-spend P2TR address, false if otherwise

Start building

XO

Request Demo

Schedule a call with our team

Select a product
Arrow right

Start building
Grateful

Contact Us

We're here to help