Function hdPublicKeyToP2pkhLockingBytecode

  • 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 throwErrors to false.

    To derive the resulting CashAddress, use hdPublicKeyToP2pkhCashAddress. For non-HD public keys, use publicKeyToP2pkhLockingBytecode. For the HD private key equivalent, see hdPrivateKeyToP2pkhLockingBytecode.

    Type Parameters

    • ThrowErrors extends boolean = true

    Parameters

    • __namedParameters: {
          addressIndex: number;
          hdPublicKey: string;
          hdPublicKeyDerivationPath?: string;
          publicDerivationPath?: string;
          throwErrors?: ThrowErrors;
      }
      • addressIndex: number

        The non-hardened address index within the BIP32 account specified by publicDerivationPath at which to derive the P2PKH locking bytecode.

        Non-hardened address indexes must be positive integers between 0 and 2147483647, 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.)

      • hdPublicKey: string

        An encoded HD public key, e.g. xpub661MyMwAqRbcFkPHucMnrGNzDwb6teAX1RbKQmqtEF8kK3Z7LZ59qafCjB9eCRLiTVG3uxBxgKvRgbubRhqSKXnGGb1aoaqLrpMBDrVxga8

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

      • Optional hdPublicKeyDerivationPath?: string

        The path at which the provided hdPublicKey should have been derived from it's master HD private key. This is used only to verify that the depth encoded in the provided hdPublicKey is 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.

      • Optional publicDerivationPath?: 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 i character to represent the addressIndex.

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

        This path must be relative, see WalletTemplateHdKey.publicDerivationPath for details.

      • Optional throwErrors?: ThrowErrors

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

    Returns ThrowErrors extends true
        ? Uint8Array
        : string | Uint8Array

Generated using TypeDoc