Caravan Documentation
    Preparing search index...

    Function deriveChildExtendedPublicKey

    • Return the extended public key at the given BIP32 path below the given extended public key.

      Parameters

      • extendedPublicKey: string

        base58 encoded extended public key (xpub...)

      • bip32Path: string

        BIP32 derivation path string (with or without initial m/)

      • network: BitcoinNetwork

        bitcoin network

      Returns string

      child extended public key in base58

      import {deriveChildExtendedPublicKey, MAINNET} from "@caravan/bitcoin";
      const xpub = "xpub6CCHViYn5VzKSmKD9cK9LBDPz9wBLV7owXJcNDioETNvhqhVtj3ABnVUERN9aV1RGTX9YpyPHnC4Ekzjnr7TZthsJRBiXA4QCeXNHEwxLab";
      console.log(deriveChildExtendedPublicKey(xpub, "m/0/0", MAINNET));
      // "xpub6GYTTMaaN8bSEhicdKq7ji9H7B2SL4un33obThv9aekop4J7L7B3snYMnJUuwXJiUmsbSVSyZydbqLC97JMWnj3R4MHz6JNunMJhjEBKovS"
      console.log(deriveChildExtendedPublicKey(xpub, "0/0", MAINNET)); // without initial `m/`
      // "xpub6GYTTMaaN8bSEhicdKq7ji9H7B2SL4un33obThv9aekop4J7L7B3snYMnJUuwXJiUmsbSVSyZydbqLC97JMWnj3R4MHz6JNunMJhjEBKovS"