Caravan Documentation
    Preparing search index...

    Class LedgerExportPublicKey

    Returns the public key at a given BIP32 path.

    import {LedgerExportPublicKey} from "@caravan/wallets";
    const interaction = new LedgerExportPublicKey({bip32Path: "m/48'/0'/0'/2'/0"});
    const publicKey = await interaction.run();
    console.log(publicKey);
    // "03..."

    Hierarchy

    • LedgerExportHDNode
      • LedgerExportPublicKey
    Index

    Constructors

    Properties

    appName?: string
    appVersion?: string
    bip32Path: string
    bip32ValidationErrorMessage?: LedgerDeviceError
    direct: boolean
    environment: Parser
    includeXFP: boolean
    isLegacySupported: true
    isV2Supported: false

    Methods

    • Close the Transport to free the interface (E.g. could be used in another tab now that the interaction is over)

      The way the pubkey/xpub/fingerprints are grabbed makes this a little tricky. Instead of re-writing how that works, let's just add a way to explicitly close the transport.

      Returns Promise<any>

    • Get fingerprint from parent pubkey. This is useful for generating xpubs which need the fingerprint of the parent pubkey

      Optionally get root fingerprint for device. This is useful for keychecks and necessary for PSBTs

      Parameters

      • root: boolean = false

      Returns Promise<string | number>

    • Returns whether or not the Ledger device will display a warning to the user about an unusual BIP32 path.

      A "usual" BIP32 path is exactly 5 segments long. The segments have the following constraints:

      • Segment 1: Must be equal to 44'
      • Segment 2: Can have any value
      • Segment 3: Must be between 0' and 100'
      • Segment 4: Must be equal to 0
      • Segment 5: Must be between 0 and 50000

      Any other kind of path is considered unusual and will trigger the warning.

      Returns boolean

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

      Parameters

      • __namedParameters: MessageMethodArgs

      Returns boolean

    • Inheriting classes should set properties this.isLegacySupported and this.isV2Supported to indicate whether a given interaction has support for a given interaction. This method can then be called to check the version of the app being called and return whether or not the interaction is supported based on that version

      Returns Promise<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

    • Type Parameters

      • T extends FormatType = "hex"

      Parameters

      • transactionSignature: string[]
      • format: T = ...

      Returns FormatReturnType<T>[]

    • Type Parameters

      • T extends FormatType = "hex"

      Parameters

      • inputSignature: string
      • format: T = ...

      Returns FormatReturnType<T>

    • Can be called by a subclass during its run() method.

      Creates a transport layer connection, initializes a bitcoin app object, and passes control to the callback function, with the app API as the first argument to the function and the transport API as the second.

      See the [Ledger API]https://github.com/LedgerHQ/ledgerjs for general information or the [bitcoin app API]https://github.com/LedgerHQ/ledgerjs/tree/master/packages/hw-app-btc for examples of API calls.

      Parameters

      • callback: (app: any, transport: any) => any

      Returns Promise<any>

      async run() {
      return await this.withApp(async (app, transport) => {
      return app.doSomething(); // Not a real Ledger bitcoin app API call
      });
      }
    • Can be called by a subclass during its run() method.

      Creates a transport layer connection and passes control to the callback function, with the transport API as the first argument to the function.

      See the [Ledger API]https://github.com/LedgerHQ/ledgerjs for general information or a [specific transport API]https://github.com/LedgerHQ/ledgerjs/tree/master/packages/hw-transport-u2f for examples of API calls.

      Parameters

      • callback: (transport: any) => any

      Returns Promise<any>

      async run() {
      return await this.withTransport(async (transport) => {
      return transport.doSomething(); // Not a real Ledger transport API call
      });
      }