Function hdPublicKeyToP2pkhLockingBytecode
- hd
Public Key To P2pkh Locking Bytecode<ThrowErrors>(__namedParameters): ThrowErrors extends true
? Uint8Array
: string | Uint8Array Type Parameters
Parameters
__namedParameters: {
addressIndex: number;
hdPublicKey: string;
hdPublicKeyDerivationPath?: string;
publicDerivationPath?: string;
throwErrors?: ThrowErrors;
}address
Index: number The non-hardened address index within the BIP32 account specified by
publicDerivationPathat which to derive the P2PKH locking bytecode.Non-hardened address indexes must be positive integers between
0and2147483647, inclusive. An error will be thrown or returned (in accordance withthrowErrors) for address indexes outside of this range.As standardized by BIP32, address indexes less than
2147483648(0x80000000) use standard derivation, while indexes equal to or greater than2147483648use the "hardened" derivation algorithm. Note that this prevents the HD public key derived from the provided HD private key (deriveHdPublicKey) from deriving any address indexes beyond2147483647. (In these cases, hdPublicKeyToP2pkhLockingBytecode and hdPublicKeyToP2pkhCashAddress will produce an error.)hd
Public Key: string An encoded HD public key, e.g.
xpub661MyMwAqRbcFkPHucMnrGNzDwb6teAX1RbKQmqtEF8kK3Z7LZ59qafCjB9eCRLiTVG3uxBxgKvRgbubRhqSKXnGGb1aoaqLrpMBDrVxga8HD private keys may be encoded for either mainnet or testnet (the network information is ignored).
OptionalhdPublic Key Derivation Path?: string The path at which the provided
hdPublicKeyshould have been derived from it's master HD private key. This is used only to verify that the depth encoded in the providedhdPublicKeyis equal to the expected depth. This verification can help to detect software incompatibility or HD public key transmission errors which might otherwise result in derivation of addresses at unexpected derivation paths.Defaults to an empty string (
""), which disables depth verification.OptionalpublicDerivation Path?: string The public derivation path for the BIP32 account to use in deriving the P2PKH address. By default,
i.This path uses the notation specified in BIP32 and the
icharacter to represent theaddressIndex.For example, for the first external P2PKH address of the first BCH account as standardized by SLIP44,
hdPublicKeyDerivationPathshould bem/44'/145'/0',publicDerivationPathshould be0/i, whileaddressIndexis set to0. (For "change" addresses,publicDerivationPathshould be1/i.)This path must be relative, see WalletTemplateHdKey.publicDerivationPath for details.
OptionalthrowErrors?: ThrowErrors If
true, this function will throw anErrorif the providedhdPublicKeyis invalid rather than returning the error as a string (defaults totrue).
Returns ThrowErrors extends true
? Uint8Array
: string | Uint8Array
Generated using TypeDoc

Derive the P2PKH locking bytecode at the provided index of the provided HD public key.
Note that this function defaults to throwing an error if provided with an invalid HD public key. To handle errors in a type-safe way, set
throwErrorstofalse.To derive the resulting CashAddress, use hdPublicKeyToP2pkhCashAddress. For non-HD public keys, use publicKeyToP2pkhLockingBytecode. For the HD private key equivalent, see hdPrivateKeyToP2pkhLockingBytecode.