Skip to main content

Ledger

type Ledger​

A connection to the IOTA app on a Ledger device.

Every call completes once the device answers, which for address verification includes waiting for the user to confirm on the device. Calls on the same `Ledger`, including through the `LedgerSigner`s created from it, run one at a time.

type Ledger struct {
// contains filtered or unexported fields
}

func LedgerFromTransport​

func LedgerFromTransport(transport LedgerTransport) *Ledger

Communicate with the device through a transport implemented in the host language.

`open_app` closes whichever other app the transport reports as running, so do not call it on an emulator that reports a placeholder app name, such as Speculos started without `SPECULOS_APPNAME=IOTA:<version>`: it ends the emulated app.

func LedgerNativeHid​

func LedgerNativeHid() (*Ledger, error)

Connect to the first Ledger device attached over USB.

Fails in builds of the SDK without USB support, such as those for Android, iOS and the web.

func LedgerSpeculos​

func LedgerSpeculos(host string, port uint16) *Ledger

Connect to the APDU port of a Speculos emulator (by default this is `127.0.0.1:9999` in the emulator).

Calls through this connection block the thread running them until the emulator answers, and fail in the WASM bindings, which have no TCP sockets.

func LiftFromExternalLedger​

func LiftFromExternalLedger(handle uint64) *Ledger

func (*Ledger) Destroy​

func (object *Ledger) Destroy()

func (*Ledger) ExitApp​

func (_self *Ledger) ExitApp() error

Close the app running on the device and return to the dashboard.

On Speculos, this ends the emulated app.

func (*Ledger) GetPublicKey​

func (_self *Ledger) GetPublicKey(path string) (*Ed25519PublicKey, error)

Read the public key at a derivation path such as `m/44'/4218'/0'/0'/0'`.

func (*Ledger) IsAppOpen​

func (_self *Ledger) IsAppOpen() (bool, error)

Check whether the IOTA app is the app running on the device.

Speculos reports a placeholder app name unless started with `SPECULOS_APPNAME=IOTA:<version>`, so this returns `false` there.

func (*Ledger) OpenApp​

func (_self *Ledger) OpenApp() error

Open the IOTA app, from the dashboard or by closing another app first.

Does nothing if the IOTA app is already running, or on a `speculos` connection.

func (*Ledger) Signer​

func (_self *Ledger) Signer(path string) (*LedgerSigner, error)

Create a signer for the key at a derivation path such as `m/44'/4218'/0'/0'/0'`, reading its public key from the device.

The signer shares this `Ledger`'s connection, which stays usable.

func (*Ledger) VerifyAddress​

func (_self *Ledger) VerifyAddress(path string) (*Ed25519PublicKey, error)

Show the address at a derivation path on the device for the user to confirm, and return its public key.

func (*Ledger) Version​

func (_self *Ledger) Version() (LedgerAppVersion, error)

Read the version of the IOTA app.