BitcoinerLab Descriptors API - v3.1.7
    Preparing search index...

    Function keyExpressionBIP32

    • Constructs a BIP32 key expression string from its constituent components.

      This function essentially performs the reverse operation of KeyExpressionParser. For detailed explanations and examples of the terms used here, refer to KeyExpressionParser.

      Parameters

      • params: {
            masterNode: BIP32InterfaceLike | ScureHDKeyLike;
            originPath: string;
            change?: number;
            index?: number | "*";
            keyPath?: string;
            isPublic?: boolean;
        }

        The parameters object.

        • masterNode: BIP32InterfaceLike | ScureHDKeyLike

          Root HD node. Pass either:

        • originPath: string

          Origin path from master, e.g. "/84'/0'/0'".

        • Optionalchange?: number

          Branch index (0 receive, 1 change).

        • Optionalindex?: number | "*"

          Address index or * for ranged descriptors.

        • OptionalkeyPath?: string

          Full suffix path (/change/index) alternative to change + index.

        • OptionalisPublic?: boolean

          Compute an xpub or xprv

          true
          

      Returns string

      Descriptor key expression (e.g. [f23f9fd2/84'/0'/0']xpub.../0/5).

      import * as ecc from '@bitcoinerlab/secp256k1';
      import { BIP32Factory } from 'bip32';
      import { keyExpressionBIP32 } from '@bitcoinerlab/descriptors';

      const BIP32 = BIP32Factory(ecc);
      const masterNode = BIP32.fromSeed(seedBytes);
      const keyExp = keyExpressionBIP32({
      masterNode,
      originPath: "/84'/0'/0'",
      change: 0,
      index: 5
      });
      import { HDKey } from '@scure/bip32';
      import { keyExpressionBIP32 } from '@bitcoinerlab/descriptors';

      const masterNode = HDKey.fromMasterSeed(seedBytes);
      const keyExp = keyExpressionBIP32({
      masterNode,
      originPath: "/84'/0'/0'",
      keyPath: '/0/*'
      });