How to use the @ledgerhq/hw-transport-node-hid.default.open function in @ledgerhq/hw-transport-node-hid

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 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 greymass / eos-voter / app / shared / actions / hardware / ledger.js View on Github external
return (dispatch: () => void, getState) => {
    switch (event.type) {
      case 'add': {
        const isConnected = (getState().ledger.devicePath !== null);
        const isCurrentDevice = (getState().ledger.devicePath === event.device.path);
        const isAppRunning = (getState().ledger.application !== null);
        const signPath = (getState().wallet.path);
        if (!isConnected) {
          if (!isCurrentDevice || !isAppRunning) {
            Transport
              .open(event.device.path)
              .then((transport) => {
                if (process.env.NODE_ENV === 'development') {
                  transport.setDebugMode(true);
                }
                hardwareLedger.destroy();
                hardwareLedger = new HardwareLedger(transport);
                dispatch({
                  payload: {
                    devicePath: event.device.path,
                    // transport,
                    signPath
                  },
                  type: types.HARDWARE_LEDGER_TRANSPORT_SUCCESS
                });
                dispatch(getAppConfiguration());
github LedgerHQ / ledger-live-desktop / scripts / legacy / live-cli.js View on Github external
async function actionLoop(props) {
  try {
    const { account, accounts, core, njsWalletPool, device } = props
    const actionToDo = await chooseAction(`What do you want to do with [${account.name}] ?`)
    if (actionToDo === 'send funds') {
      const transport = await TransportNodeHid.open(device.path)
      const accountToReceive = await chooseAccount('To which account?', accounts)
      const receiveAddress = await getFreshAddress({
        account: accountToReceive,
        core,
        njsWalletPool,
      })
      console.log(`the receive address is ${receiveAddress}`)
      const rawAccount = encodeAccount(account)
      console.log(`trying to sign and broadcast...`)
      const rawOp = await doSignAndBroadcast({
        account: rawAccount,
        transaction: {
          amount: 4200000,
          recipient: receiveAddress,
          feePerByte: 16,
          isRBF: false,
github tarassh / fairy-wallet / app / middleware / deviceListener.js View on Github external
next: e => {
                        const { ledger } = store.getState();
                        store.dispatch({
                            type: types.DEVICE_CONNECTED,
                            devicePath: e.device.path
                        });

                        if (e.type === 'add' && (ledger.devicePath !== e.device.path && ledger.publicKey === null)) {
                            sub.unsubscribe();
                            sub = null;
        
                            Transport.open(e.device.path).then(transport => {
                                transport.setDebugMode(true);
                                const api = new Api(transport);
                                api.getPublicKey("44'/194'/0'/0/0").then(result => {
                                    transport.close();
        
                                    store.dispatch({
                                        type: types.GET_PUBLIC_KEY_SUCCESS, 
                                        publicKey: result
                                    });
                                
                                    return result;
                                }).catch(err => {
                                    console.log(err);
                                    transport.close();

                                    store.dispatch({
github LedgerHQ / ledger-live-desktop / alix.js View on Github external
async function scanAccountsOnDevice(props) {
  try {
    const { devicePath, currencyId } = props
    console.log(`get or create wallet`)
    const wallet = await getOrCreateWallet(currencyId)
    console.log(`open device`)
    const transport = await CommNodeHid.open(devicePath)
    console.log(`create app`)
    const hwApp = new Btc(transport)
    console.log(`scan account`)
    const accounts = await scanNextAccount(wallet, hwApp)
    console.log(accounts)
    return []
  } catch (err) {
    console.log(err)
  }
}
github LedgerHQ / ledger-live-common / cli / src / live-common-setup.js View on Github external
      retry(() => TransportNodeHid.open(devicePath), {
        context: "open-hid"
github GetScatter / ScatterDesktop / electron / hardware / LedgerWallet.js View on Github external
static async add(device){
		const {path} = device;
		openedTransport = await Transport.open(path);
	}
github tarassh / fairy-wallet / app / actions / ledger.js View on Github external
next: event => {
        if (event.type === 'add') {
          if (getState().ledger.devicePath === null) {
            if (
              getState().ledger.devicePath !== event.device.path &&
              getState().ledger.application === null
            ) {
              dispatch(stopListen());

              Transport.open(event.device.path)
                .then(transport => {
                  if (process.env.NODE_ENV === 'development') {
                    transport.setDebugMode(true);
                  }

                  dispatch({
                    type: types.GET_APP_STATS_REQUEST
                  });

                  const api = new Api(transport);
                  api
                    .getAppConfiguration()
                    .then(result => {
                      dispatch({
                        type: types.GET_APP_STATS_SUCCESS,
                        application: result,