@Override public void run() { while (true) { try { // Blocking read to get the client message (e.g. "Initialize") formatted as HID packets for simplicity log.debug("Waiting for client message..."); MessageEvent messageFromClient = TrezorMessageUtils.parseAsHIDPackets(inputFromClient); // Send the Message to the trezor (serialising again to protobuf) log.debug("Writing message to hardware wallet"); hardwareWallet.writeMessage(messageFromClient.getRawMessage().get()); } catch (Exception e) { log.error("Failed in hardware wallet/client read", e); break; } } }
@Override public void run() { while (true) { try { // Blocking read to get the client message (e.g. "Initialize") formatted as HID packets for simplicity log.debug("Waiting for client message..."); MessageEvent messageFromClient = KeepKeyMessageUtils.parseAsHIDPackets(inputFromClient); // Send the Message to the keepKey (serialising again to protobuf) log.debug("Writing message to hardware wallet"); hardwareWallet.writeMessage(messageFromClient.getRawMessage().get()); } catch (Exception e) { log.error("Failed in hardware wallet/client read", e); break; } } }
@Override public void run() { while (true) { log.debug("Waiting for hardware wallet message..."); Optional<MessageEvent> messageEvent = hardwareWallet.readMessage(1, TimeUnit.MINUTES); if (messageEvent.isPresent()) { if (MessageEventType.DEVICE_FAILED.equals(messageEvent.get().getEventType())) { // Stop reading messages on this thread for a short while to allow recovery time Uninterruptibles.sleepUninterruptibly(1, TimeUnit.SECONDS); } else { // Send the Message back to the client log.debug("Sending raw message to client"); writeMessage(messageEvent.get().getRawMessage().get(), outputToClient); } } } }
@Override public void run() { while (true) { log.debug("Waiting for hardware wallet message..."); Optional<MessageEvent> messageEvent = hardwareWallet.readMessage(1, TimeUnit.MINUTES); if (messageEvent.isPresent()) { if (MessageEventType.DEVICE_FAILED.equals(messageEvent.get().getEventType())) { // Stop reading messages on this thread for a short while to allow recovery time Uninterruptibles.sleepUninterruptibly(1, TimeUnit.SECONDS); } else { // Send the Message back to the client log.debug("Sending raw message to client"); writeMessage(messageEvent.get().getRawMessage().get(), outputToClient); } } } }