Caravan Documentation
    Preparing search index...

    Class ColdcardExportExtendedPublicKey

    Reads an extended public key and (optionally) derives deeper from data in an exported JSON file uploaded from the Coldcard.

    const interaction = new ColdcardExportExtendedPublicKey({network: Network.MAINNET, bip32Path: 'm/45'/0/0'});
    const reader = new FileReader(); // application dependent
    const jsonFile = reader.readAsText('ccxp-0F056943.json'); // application dependent
    const {xpub, rootFingerprint, bip32Path} = interaction.parse(jsonFile);
    console.log(xpub);
    // "xpub..."
    console.log(rootFingerprint);
    // "0f056943"
    console.log(bip32Path);
    // "m/45'/0/0"

    Hierarchy

    • ColdcardMultisigSettingsFileParser
      • ColdcardExportExtendedPublicKey
    Index

    Constructors

    Properties

    bip32Path: string
    bip32ValidationError: string
    bip32ValidationErrorMessage: { code?: string; text?: string }
    environment: Parser
    indirect: boolean
    workflow: string[]

    Methods

    • This method will take the result from the Coldcard JSON and:

      1. determine which t/U/V/x/Y/Zpub to use
      2. derive deeper if necessary (and able) using functionality from @caravan/bitcoin

      Parameters

      • result: string | Record<string, unknown>

      Returns string

    • Return whether there are any messages matching the given options.

      Parameters

      • __namedParameters: MessageMethodArgs

      Returns boolean

    • Subclasses can override this method to indicate they are not supported.

      This method has access to whatever options may have been passed in by the constructor as well as the ability to interact with this.environment to determine whether the functionality is supported. See the Bowser documentation for more details: https://github.com/lancedikson/bowser

      Returns boolean

      isSupported() {
      return this.environment.satisfies({
      * declare browsers per OS
      windows: {
      "internet explorer": ">10",
      },
      macos: {
      safari: ">10.1"
      },

      * per platform (mobile, desktop or tablet)
      mobile: {
      safari: '>=9',
      'android browser': '>3.10'
      },

      * or in general
      chrome: "~20.1.1432",
      firefox: ">31",
      opera: ">=22",

      * also supports equality operator
      chrome: "=20.1.1432", * will match particular build only

      * and loose-equality operator
      chrome: "~20", * will match any 20.* sub-version
      chrome: "~20.1" * will match any 20.1.* sub-version (20.1.19 as well as 20.1.12.42-alpha.1)
      });
      }
    • Return the first message matching the given options (or null if none is found).

      Parameters

      • __namedParameters: MessageMethodArgs

      Returns null | Message

    • Return messages filtered by the given options.

      Multiple options can be given at once to filter along multiple dimensions.

      Parameters

      • __namedParameters: MessageMethodArgs

      Returns Message[]

      import {PENDING, ACTIVE} from "@caravan/bitcoin";
      // Create any interaction instance
      interaction.messages().forEach(msg => console.log(msg));
      { code: "device.connect", state: "pending", level: "info", text: "Please plug in your device."}
      { code: "device.active", state: "active", level: "info", text: "Communicating with your device..."}
      { code: "device.active.warning", state: "active", level: "warning", text: "Your device will warn you about...", version: "2.x"}
      interaction.messagesFor({state: PENDING}).forEach(msg => console.log(msg));
      { code: "device.connect", state: "pending", level: "info", text: "Please plug in your device."}
      interaction.messagesFor({code: ACTIVE}).forEach(msg => console.log(msg));
      { code: "device.active", state: "active", level: "info", text: "Communicating with your device..."}
      { code: "device.active.warning", state: "active", level: "warning", text: "Your device will warn you about...", version: "2.x"}
      interaction.messagesFor({version: /^2/}).forEach(msg => console.log(msg));
      { code: "device.active", state: "active", level: "warning", text: "Your device will warn you about...", version: "2.x"}
    • Retrieve the text of the first message matching the given options (or null if none is found).

      Parameters

      • __namedParameters: MessageMethodArgs

      Returns null | string

    • Parse the Coldcard JSON file and do some basic error checking add a field for rootFingerprint (it can sometimes be calculated if not explicitly included)

      Parameters

      • xpubJSONFile: any

      Returns { bip32Path: string; rootFingerprint: any; xpub: string }

    • Provide the request.

      Subclasses may override this function. It can return any kind of object. Strings, data for QR codes, HTTP requests, command lines, functions, &c. are all allowed. Whatever is appropriate for the interaction.

      Returns void

    • This validates three things for an incoming Coldcard bip32Path

      1. Is the bip32path valid syntactically?
      2. Does the bip32path start with one of the known Coldcard chroots?
      3. Are there any hardened indices in the relative path below the chroot?

      Parameters

      • bip32Path: string

      Returns string