Function encodeHdPublicKey

  • Encode an HD public key (as defined by BIP32) given a valid HdPublicNodeValid and network.

    Note that this function defaults to throwing encoding errors. To handle errors in a type-safe way, set throwErrors to false.

    Type Parameters

    • ThrowErrors extends boolean = true

    Parameters

    • keyParameters: DecodedHdKey<HdPublicNodeValid>

      An HD public node and the network for which to encode the key.

    • __namedParameters: {
          crypto?: {
              secp256k1: {
                  validatePublicKey: ((publicKey) => boolean);
              };
              sha256: {
                  hash: ((input) => Uint8Array) & ((input) => Uint8Array);
              };
          };
          throwErrors?: ThrowErrors;
      } = {}
      • Optional crypto?: {
            secp256k1: {
                validatePublicKey: ((publicKey) => boolean);
            };
            sha256: {
                hash: ((input) => Uint8Array) & ((input) => Uint8Array);
            };
        }

        An optional object containing an implementation of sha256 to use.

        • secp256k1: {
              validatePublicKey: ((publicKey) => boolean);
          }
          • validatePublicKey: ((publicKey) => boolean)
              • (publicKey): boolean
              • Parameters

                • publicKey: Uint8Array

                Returns boolean

        • sha256: {
              hash: ((input) => Uint8Array) & ((input) => Uint8Array);
          }
          • hash: ((input) => Uint8Array) & ((input) => Uint8Array)
      • Optional throwErrors?: ThrowErrors

        If true, this function will throw an Error when the provided HD node has a depth exceeding the maximum depth that can be encoded using the BIP32 serialization format rather than returning the error as a string (defaults to true).

    Returns ThrowErrors extends true
        ? HdPublicKeyEncodeResult
        : string | HdPublicKeyEncodeResult

Generated using TypeDoc