Type alias WalletTemplateHdKey

WalletTemplateHdKey: WalletTemplateKeyBase & WalletTemplateVariableBase & {
    addressOffset?: number;
    description?: string;
    hdPublicKeyDerivationPath?: string;
    name?: string;
    privateDerivationPath?: string;
    publicDerivationPath?: string;
    type: "HdKey";

Type declaration

  • Optional addressOffset?: number

    The offset by which to increment the addressIndex provided in the compilation data when deriving this HdKey. (Default: 0)

    This is useful for deriving the "next" (1) or "previous" (-1) address for use in the current compilation.

  • Optional description?: string

    A single-line, human readable description for this HD key.

  • Optional hdPublicKeyDerivationPath?: string

    The path to derive the entity's HD public key from the entity's provided HD private key. By default, an empty string (""), i.e. the entity's HD public key represents the same node in the HD tree as the provided HD private key.

    This can be used to specify another relative or absolute derivation path from which the publicDerivationPath begins, e.g. m/0'/1'/2'. See publicDerivationPath for details.

    This path may optionally begin with an m (for relative private derivation) and must be fixed – it cannot contain any i characters to represent the address index, as a dynamic hardened path would require a new HD public key for each address.

    Note, hdPublicKeyDerivationPath could be automatically determined in some cases, but it's always defined independently to improve validation and auditability.

  • Optional name?: string

    A single-line, Title Case, human-readable name for this HD key.

  • Optional privateDerivationPath?: string

    The relative or absolute derivation path used to derive this HdKey from the owning entity's HD private key. By default, i.

    If the first character is m, the path is an absolute path, otherwise, the path is a relative path. For absolute paths, the compiler will verify that the relevant entity's HD private key is a master private key (encoded with a depth of zero); HdKeys with relative privateDerivationPath may be resolved using non-master private keys (e.g. hardened accounts that have been previously derived and delegated to a sub-entity prior to compilation).

    This path uses the notation specified in BIP32 and the i character to represent the addressIndex:

    An optional m character (indicating an absolute, private derivation path), followed by sets of / and a number representing the child index used in the derivation at that depth. Hardened derivation is represented by a trailing ', and hardened child indexes are represented with the hardened index offset (2147483648) subtracted. All i characters are replaced with the value of addressIndex plus this HdKey's addressOffset. If the i character is followed by ', the hardened index offset is added (2147483648) and hardened derivation is used.

    For example, m/0/1'/i' has 3 levels of derivation, with child indexes in the following order:

    derive(derive(derive(masterKey, 0), 2147483648 + 1), 2147483648 + addressIndex + addressOffset)

    As the path is absolute (begins with m), the compiler will also verify that a zero-depth ("master") HD private key is provided for the entity owning this HdKey.

    Note, because hardened derivation requires knowledge of the private key, HdKey variables with privateDerivationPaths that include hardened derivation must configure hdPublicKeyDerivationPath to support HD public derivation.

  • Optional publicDerivationPath?: string

    The relative derivation path used to derive this HdKey's public key from the owning entity's HD public key (configured via hdPublicKeyDerivationPath). If not set, the relative path (following the m/ of privateDerivationPath) is used. For the privateDerivationPath default of i, this is i.

    If privateDerivationPath uses hardened derivation for some levels, but later derivation levels use non-hardened derivation, publicDerivationPath can be used to specify a public derivation path beginning from hdPublicKeyDerivationPath (i.e. publicDerivationPath should always be a non-hardened segment of privateDerivationPath that follows hdPublicKeyDerivationPath).

    The publicDerivationPath must be a relative HD derivation path: non-hardened positive integer child indexes (between 0 and 2147483647, without any trailing 's) separated by /s.

    For example, if privateDerivationPath is m/0'/i, it is not possible to derive the equivalent public key with only the HD public key M. (The path M/0'/i is impossible.) However, given the HD public key for m/0', it is possible to derive the public key of m/0'/i for any i. In this case, hdPublicKeyDerivationPath would be m/0' and publicDerivationPath would be the remaining i.


    Non-hardened derivation paths are more useful for some templates, e.g. to allow for new locking scripts to be generated without communicating new public keys between entities for each. However, using a non-hardened key has critical security implications. If an attacker gains possession of both a parent HD public key and any child private key, the attacker can easily derive the parent HD private key, and with it, all hardened and non-hardened child keys. See Libauth's crackHdPrivateNodeFromHdPublicNodeAndChildPrivateNode for details.

  • type: "HdKey"

    The HdKey (Hierarchical-Deterministic Key) type automatically manages key generation and mapping in a standard way. For greater control, use Key.

Generated using TypeDoc