Function hdPrivateKeyToP2pkhCashAddress

  • Derive the P2PKH address at the provided index of the provided HD private key.

    Note that this function defaults to throwing an error if provided with an invalid HD private key or derivation path. To handle errors in a type-safe way, set throwErrors to false.

    To derive only the locking bytecode, use hdPrivateKeyToP2pkhLockingBytecode. For non-HD private keys, use privateKeyToP2pkhCashAddress. For the HD public key equivalent, see hdPublicKeyToP2pkhCashAddress.

    Type Parameters

    • ThrowErrors extends boolean = true


    • __namedParameters: {
          addressIndex: number;
          hdPrivateKey: string;
          prefix?: "bitcoincash" | "bchtest" | "bchreg";
          privateDerivationPath?: string;
          throwErrors?: ThrowErrors;
          tokenSupport?: boolean;
      • addressIndex: number

        The address index within the BIP32 account specified by privateDerivationPath at which to derive the P2PKH address.

        Address indexes must be positive integers between 0 and 4294967295 (0xffffffff), inclusive. An error will be thrown or returned (in accordance with throwErrors) 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 than 2147483648 use 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 beyond 2147483647. (In these cases, hdPublicKeyToP2pkhLockingBytecode and hdPublicKeyToP2pkhCashAddress will produce an error.)

      • hdPrivateKey: string

        An encoded HD private key, e.g. xprv9s21ZrQH143K3GJpoapnV8SFfukcVBSfeCficPSGfubmSFDxo1kuHnLisriDvSnRRuL2Qrg5ggqHKNVpxR86QEC8w35uxmGoggxtQTPvfUu.

        HD private keys may be encoded for either mainnet or testnet (the network information is ignored in favor of prefix).

      • Optional prefix?: "bitcoincash" | "bchtest" | "bchreg"

        The CashAddressNetworkPrefix to use when encoding the address. (Default: bitcoincash)

      • Optional privateDerivationPath?: string

        The private 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 i character to represent the addressIndex.

        For example, for the first external P2PKH address of the first BCH account as standardized by SLIP44, privateDerivationPath should be m/44'/145'/0'/0/i, while addressIndex is set to 0. (For "change" addresses, privateDerivationPath should be m/44'/145'/0'/1/i.)

        This path may be relative or absolute, see WalletTemplateHdKey.privateDerivationPath for details.

      • Optional throwErrors?: ThrowErrors

        If true, this function will throw an Error if the provided hdPrivateKey is invalid rather than returning the error as a string (defaults to true).

      • Optional tokenSupport?: boolean

        If true, the address will indicate that the receiver accepts CashTokens; defaults to false.

    Returns ThrowErrors extends true
        ? CashAddressResult
        : string | CashAddressResult

Generated using TypeDoc