Class: LedgerBitcoinInteraction

ledger.LedgerBitcoinInteraction()

Base class for interactions which must occur when the Ledger device is open to the bitcoin app.

Constructor

new LedgerBitcoinInteraction()

Source:

Extends

Methods

closeTransport() → {Promise}

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.

Inherited From:
Source:
Returns:
  • promise to close the transport
Type
Promise

messages() → {Array.<module:interaction.Message>}

Adds pending and active messages at the info level urging the user to be in the bitcoin app (ledger.app.bitcoin).

Overrides:
Source:
Returns:

messages for this interaction

Type
Array.<module:interaction.Message>

parse() → {void}

Throws an error.

Inherited From:
Source:
Throws:

An error since this is a direct interaction.

Returns:
Type
void

request() → {void}

Throws an error.

Inherited From:
Source:
Throws:

An error since this is a direct interaction.

Returns:
Type
void

(async) run() → {Promise}

Initiate the intended interaction and return a result.

Subclasses must override this function. This function must always return a promise as it is designed to be called within an await block.

Inherited From:
Source:
Returns:

Does the work of interacting with the keystore.

Type
Promise

withApp(callback) → {Promise}

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 for general information or the bitcoin app API for examples of API calls.

Parameters:
Name Type Description
callback function
  • accepts two parameters, app and transport, which are the Ledger APIs for the bitcoin app and the transport layer, respectively.
Inherited From:
Source:
Returns:

does the work of setting up an app instance (and transport connection)

Type
Promise
Example
async run() {
  return await this.withApp(async (app, transport) => {
    return app.doSomething(); // Not a real Ledger bitcoin app API call
  });
}

(async) withTransport(callback) → {Promise}

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 for general information or a specific transport API for examples of API calls.

Parameters:
Name Type Description
callback function
  • asynchronous function accepting a single parameter transport
Inherited From:
Source:
Returns:

does the work of setting up a transport connection

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