How to use @ledgerhq/hw-transport-node-hid - 10 common examples

To help you get started, we’ve selected a few @ledgerhq/hw-transport-node-hid examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cryppadotta / dotta-license / dot-abi-cli / bin / test-ledger-address.js View on Github external
const getAddress = async () => {
  console.log('Testing Ledger Hardware...');
  console.log('supported:', await Transport.isSupported());
  console.log('Devices:');
  console.log(await Transport.list());
  const transport = await Transport.create();
  const eth = new AppEth(transport);

  // note: this path matches MEWs: m/44'/60'/0'
  const result = await eth.getAddress("m/44'/60'/0'/0");
  return result;
};
getAddress().then(a => console.log(a));
github cryppadotta / dotta-license / dot-abi-cli / bin / test-ledger-address.js View on Github external
const getAddress = async () => {
  console.log('Testing Ledger Hardware...');
  console.log('supported:', await Transport.isSupported());
  console.log('Devices:');
  console.log(await Transport.list());
  const transport = await Transport.create();
  const eth = new AppEth(transport);

  // note: this path matches MEWs: m/44'/60'/0'
  const result = await eth.getAddress("m/44'/60'/0'/0");
  return result;
};
getAddress().then(a => console.log(a));
github cryppadotta / dotta-license / dot-abi-cli / bin / test-ledger-address.js View on Github external
const getAddress = async () => {
  console.log('Testing Ledger Hardware...');
  console.log('supported:', await Transport.isSupported());
  console.log('Devices:');
  console.log(await Transport.list());
  const transport = await Transport.create();
  const eth = new AppEth(transport);

  // note: this path matches MEWs: m/44'/60'/0'
  const result = await eth.getAddress("m/44'/60'/0'/0");
  return result;
};
getAddress().then(a => console.log(a));
github iov-one / iov-core / packages / iov-ledger-bns / src / scripts / checkapp.ts View on Github external
// use the function as a status check... if it works, we are in the app
      // otherwise no
      appVersion(transport)
        .then((version: number) => {
          inApp = true;
          console.log(`>>> Entered app (version ${version})`);
        })
        .catch(() => 0);
    } catch (err) {
      console.log("Error connecting to ledger: " + err);
    }
  });
};

// listen for all changed
TransportNodeHid.listen(listener);

console.log("Press any key to exit");
(process.stdin.setRawMode as any)(true);
process.stdin.resume();
process.stdin.on("data", () => process.exit(0));
github iov-one / iov-core / packages / iov-ledger-bns / src / scripts / listen.ts View on Github external
// tslint:disable:no-console
import TransportNodeHid, { DescriptorEvent } from "@ledgerhq/hw-transport-node-hid";
import { Device } from "node-hid";

// tslint:disable-next-line:readonly-array
const events: Array> = [];

const listener = {
  next: (e: DescriptorEvent) => events.push(e),
  error: console.log,
  complete: () => console.log("Listener finished"),
};

TransportNodeHid.listen(listener);

// const pprint = (e: any) => console.log(JSON.stringify(e, null, 2));

console.log("Press space to see events, any key to exit");
(process.stdin.setRawMode as any)(true);
process.stdin.resume();
process.stdin.on("data", e => {
  showAll(events);
  if (e[0] !== 0x20) {
    process.exit(0);
  }
});

const showAll = (evts: ReadonlyArray>) => console.log(evts.map(desc));

const format = (e: DescriptorEvent): string => prefix(e.type) + genericDev(e.device);
github stellarchat / desktop-client / src / main / hardwareWalletLedger.js View on Github external
HardwareWalletLedger.init = () => {
    HardwareWalletLedger.unsubscribeTransport = Transport.listen({next: async (e) => {
      const uid = hash(JSON.stringify({
        manufacturer: e.manufacturer,
        product     : e.product     ,
        productId   : e.productId   ,
        release     : e.release     ,
        serialNumber: e.serialNumber,
        vendorId    : e.vendorId    ,
      })).toString('base64').substr(0, 8);
      // console.log(uid, e)
      try {
        switch(e.type) {
          case('add'): {
            if(!HardwareWalletLedger.listOfLedgers.has(uid)) HardwareWalletLedger.listOfLedgers.set(uid, new HardwareWalletLedger(uid, e.device));
            await HardwareWalletLedger.listOfLedgers.get(uid)._changeState(HWW_STATE.ONLINE, e.descriptor);
            break;
          }
github stellarchat / desktop-client / src / main / hardwareWalletLedger.js View on Github external
async _watchdogCallback() {
      console.log(`Hardwallet<${this.uid}> Watchdog: state='${this.state}' busy='${this.busy}'`)
      if(!this.transport) {
        try {
          const transport = await Transport.open(this.descriptor);
          const str = new Str(transport);
          this.transport = transport;
          this.str = str;
          console.info(`Hardwallet<${this.uid}>: Transport open.`)
        } catch(e) {
          console.warn(`Hardwallet<${this.uid}> Watchdog: recovering from error... (${e.message})`)
          return;  // Skip the rest try again later.
        }
      }

      let newState;
      try {

        if(this.subaccount) {
          if(!this.publicKey && !this.busy) await this.selectSubaccount(this.subaccount)
          if(!this.busy) await this.ping();
github LedgerHQ / ledger-live-desktop / alix.js View on Github external
waitForDevices(async device => {
  // const accounts = await scanAccountsOnDevice({
  //   devicePath: device.path,
  //   currencyId: 'bitcoin_testnet',
  // })
  // console.log(accounts)
  try {
    console.log(`> Creating transport`)
    const transport = await CommNodeHid.open(device.path)

    // transport.setDebugMode(true)

    console.log(`> Instanciate BTC app`)
    const hwApp = new Btc(transport)

    console.log(`> Get currency`)
    const currency = await getCurrency('bitcoin_testnet')

    console.log(`> Create wallet`)
    const wallet = CREATE ? await createWallet('khalil', currency) : await getWallet('khalil')

    console.log(`> Create account`)
    const account = CREATE ? await createAccount(wallet, hwApp) : await wallet.getAccount(0)

    console.log(`> Sync account`)
github cryppadotta / dotta-license / dotlicense-cli / lib / experiments / get-ledger-address.js View on Github external
const getAddress = async () => {
  console.log('Testing Ledger Hardware...');
  console.log('supported:', await Transport.isSupported());
  console.log('Devices:');
  console.log(await Transport.list());
  const transport = await Transport.create();
  const eth = new AppEth(transport);

  // note: this path matches MEWs: m/44'/60'/0'
  const result = await eth.getAddress("m/44'/60'/0'/0");
  return result;
};
getAddress().then(a => console.log(a));
github cryppadotta / dotta-license / dotlicense-cli / lib / experiments / get-ledger-address.js View on Github external
const getAddress = async () => {
  console.log('Testing Ledger Hardware...');
  console.log('supported:', await Transport.isSupported());
  console.log('Devices:');
  console.log(await Transport.list());
  const transport = await Transport.create();
  const eth = new AppEth(transport);

  // note: this path matches MEWs: m/44'/60'/0'
  const result = await eth.getAddress("m/44'/60'/0'/0");
  return result;
};
getAddress().then(a => console.log(a));