Class: Address
Defined in: Address.ts:6
Class that implement address-related utility functions.
Constructors
Constructor
new Address():
Address
Returns
Address
Methods
convertAdressToScriptPubkey()
static
convertAdressToScriptPubkey(address
):Buffer
Defined in: Address.ts:97
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
Parameter | Type | Description |
---|---|---|
address | string | Bitcoin address |
Returns
Buffer
Script public key of the given Bitcoin address
Throws
Error when the provided address is not a valid Bitcoin address
convertPubKeyIntoAddress()
static
convertPubKeyIntoAddress(publicKey
,addressType
):object
Defined in: Address.ts:154
Convert a given public key into a corresponding Bitcoin address.
Parameters
Parameter | Type | Description |
---|---|---|
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
object
Bitcoin address that correspond to the given public key in both mainnet and testnet
Name | Type | Defined in |
---|---|---|
mainnet | undefined | string | Address.ts:161 |
testnet | undefined | string | Address.ts:163 |
isP2PKH()
static
isP2PKH(address
):boolean
Defined in: Address.ts:12
Check if a given Bitcoin address is a pay-to-public-key-hash (p2pkh) address.
Parameters
Parameter | Type | Description |
---|---|---|
address | string | Bitcoin address to be checked |
Returns
boolean
True if the provided address correspond to a valid P2PKH address, false if otherwise
isP2SH()
static
isP2SH(address
):boolean
Defined in: Address.ts:27
Check if a given Bitcoin address is a pay-to-script-hash (P2SH) address.
Parameters
Parameter | Type | Description |
---|---|---|
address | string | Bitcoin address to be checked |
Returns
boolean
True if the provided address correspond to a valid P2SH address, false if otherwise
isP2TR()
static
isP2TR(address
):boolean
Defined in: Address.ts:60
Check if a given Bitcoin address is a taproot address.
Parameters
Parameter | Type | Description |
---|---|---|
address | string | Bitcoin address to be checked |
Returns
boolean
True if the provided address is a taproot address, false if otherwise
isP2WPKH()
static
isP2WPKH(address
):boolean
Defined in: Address.ts:37
Check if a given Bitcoin address is a pay-to-witness-public-key-hash (P2WPKH) address.
Parameters
Parameter | Type | Description |
---|---|---|
address | string | Bitcoin address to be checked |
Returns
boolean
True if the provided address correspond to a valid P2WPKH address, false if otherwise
isP2WPKHWitness()
static
isP2WPKHWitness(witness
):boolean
Defined in: Address.ts:69
Check if a given witness stack corresponds to a P2WPKH address.
Parameters
Parameter | Type | Description |
---|---|---|
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()
static
isSingleKeyP2TRWitness(witness
):boolean
Defined in: Address.ts:84
Check if a given witness stack corresponds to a single-key-spend P2TR address.
Parameters
Parameter | Type | Description |
---|---|---|
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