Caravan Documentation
    Preparing search index...

    Function validateBIP32Path

    • Validate a given BIP32 derivation path string.

      • Path segments are validated numerically as well as statically (the value of 2^33 is an invalid path segment).

      • The mode option can be pass to validate fully hardened or unhardened paths.

      Parameters

      • pathString: any

        BIP32 derivation path string

      • Optionaloptions: any

        Additional options

      Returns
          | ""
          | "BIP32 path cannot be blank."
          | "BIP32 path is invalid."
          | "BIP32 path must be fully-hardened."
          | "BIP32 path cannot include hardened segments."
          | "BIP32 index cannot be blank."
          | "BIP32 index is invalid."
          | "Invalid BIP32 index."
          | "BIP32 index is too high."
          | "BIP32 index must be hardened."
          | "BIP32 index cannot be hardened."

      Empty string if valid, or error message if invalid

      import {validateBIP32Path} from "@caravan/bitcoin";
      console.log(validateBIP32Path("")); // "BIP32 path cannot be blank."
      console.log(validateBIP32Path("foo")); // "BIP32 path is invalid."
      console.log(validateBIP32Path("//45")); // "BIP32 path is invalid."
      console.log(validateBIP32Path("/45/")); // "BIP32 path is invalid."
      console.log(validateBIP32Path("/45''")); // "BIP32 path is invalid."
      console.log(validateBIP32Path('/45"')); // "BIP32 path is invalid."
      console.log(validateBIP32Path("/-45")); // "BIP32 path is invalid."
      console.log(validateBIP32Path("/8589934592")); // "BIP32 index is too high."
      console.log(validateBIP32Path("/45")); // ""
      console.log(validateBIP32Path("/45/0'")); // ""
      console.log(validateBIP32Path("/45/0'", {mode: "hardened")); // "BIP32 path must be fully-hardened."
      console.log(validateBIP32Path("/45'/0'", {mode: "hardened")); // ""
      console.log(validateBIP32Path("/0'/0", {mode: "unhardened")); // "BIP32 path cannot include hardened segments."
      console.log(validateBIP32Path("/0/0", {mode: "unhardened")); // ""