Skip to content

redDwarf03/ledger_dart_lib

Repository files navigation

Pub Platform CodeFactor

ledger_dart_lib

Ledger dart library for Flutter. This library aims to provide a easy way to communicate with Ledger devices.

Informations

Library under construction.

Status (2022/03/02)

void main() {
  Uint8List transport(
    int cla,
    int ins,
    int p1,
    int p2, [
    Uint8List? payload,
  ]) {
    payload ??= Uint8List.fromList([]);
    return Uint8List.fromList([cla, ins, p1, p2, ...payload]);
  }

  LedgerTransportHidapi ledgerTransportHidapi = LedgerTransportHidapi();
  ledgerTransportHidapi.open(0x1011);

  LedgerTransportResult ledgerTransportResult = ledgerTransportHidapi.exchange(
      transport(0xe0, 0x02, 0x00, 0x00, Uint8List.fromList(hex.decode('00'))));

  print(ledgerTransportResult.data);
}

BUT, when i copied your files (with generated_bindings.dart) in a new project, it doesn't work.

flutter: pointer = Pointer<hid_device_info>: address=0x600000a23ec0
[ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: Exception: Cannot open the Ledger device!  Please check to make sure your Ledger is plugged properly, your Ledger is not locked, the Radix app (in your Ledger) is opening and showing message 'Radix is ready'.
#0      LedgerTransportHidapi.open
package:hid_sse/ledger_transport_hidapi.dart:109
#1      main
package:hid_sse/ledger_transport_hidapi.dart:303
#2      main
.dart_tool/flutter_build/generated_main.dart:80
#3      _runMainZoned.<anonymous closure>.<anonymous closure> (dart:ui/hooks.dart:128:38)

in the first case, i'm in the hid environment (= hid project from github) with all dart files... perhaps should i import other files in my new project...

The author of the example said "if you use the hid library, you will also have native C implementation of hidapi if you do not use hid library, you need to add C code to your project specifically, for macOS you need to add https://github.com/libusb/hidapi/blob/master/mac/hid.c"

I welcome contributions from anyone and is grateful for even the smallest of improvement.

Todo

  • Migrate project to plugin architecture with multiplatforms management
  • Fix the integration of desktop HID method
  • Test with windows, linux after macOS implementation
  • Explore Nano X implementation

About

Ledger dart library for Flutter

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published