public class TrezorShieldUsbHardwareWallet extends AbstractTrezorHardwareWallet implements org.hid4java.HidServicesListener
Trezor implementation to provide the following to applications:
This class uses hidapi
for each platform due to the
custom UART-to-USB present on the RPi Shield hardware.
specification
Constructor and Description |
---|
TrezorShieldUsbHardwareWallet()
Default constructor for use with dynamic binding
|
TrezorShieldUsbHardwareWallet(com.google.common.base.Optional<Integer> vendorId,
com.google.common.base.Optional<Integer> productId,
com.google.common.base.Optional<String> serialNumber)
Create a new instance of a USB-based Trezor emulator running on a Raspberry Pi with the Shield hardware
|
Modifier and Type | Method and Description |
---|---|
void |
applySpecification(HardwareWalletSpecification specification)
Apply any hardware wallet specific parameters
|
boolean |
attach()
Handle device attachment.
|
boolean |
connect()
Attempt a connection to the underlying hardware to establish communication only (no higher level messages)
|
void |
hardDetach()
Handle device detachment and imminent shutdown.
|
void |
hidDeviceAttached(org.hid4java.event.HidServicesEvent event) |
void |
hidDeviceDetached(org.hid4java.event.HidServicesEvent event) |
void |
hidFailure(org.hid4java.event.HidServicesEvent event) |
String |
name()
Assist downstream API consumers with identifying the source of events
|
protected com.google.common.base.Optional<MessageEvent> |
readFromDevice(int duration,
TimeUnit timeUnit)
Read a complete message buffer from the device and convert it into a Core message.
|
void |
softDetach()
Handle device detachment.
|
int |
writeToDevice(byte[] buffer)
Write a complete message buffer to the device.
|
disconnect, getDefaultSpecification, readMessage, writeMessage
getSpecification
public TrezorShieldUsbHardwareWallet()
public TrezorShieldUsbHardwareWallet(com.google.common.base.Optional<Integer> vendorId, com.google.common.base.Optional<Integer> productId, com.google.common.base.Optional<String> serialNumber)
Create a new instance of a USB-based Trezor emulator running on a Raspberry Pi with the Shield hardware
vendorId
- The vendor ID (default is 0x10c4)productId
- The product ID (default is 0xea80)serialNumber
- The device serial number (default is to accept any)public void applySpecification(HardwareWalletSpecification specification)
HardwareWallet
Apply any hardware wallet specific parameters
Implementers should override this, but call super.applySpecification(specification) as part of the application process
applySpecification
in interface HardwareWallet
applySpecification
in class AbstractHardwareWallet
specification
- The HardwareWalletSpecification
public String name()
HardwareWallet
Assist downstream API consumers with identifying the source of events
name
in interface HardwareWallet
public boolean attach()
Connectable
Handle device attachment. The transport to the device is new formed (device attached, socket server started etc)
Implementations should verify the supporting environment before attempting a connection. Typically this would involve initialising native libraries and verifying their communications
attach
in interface Connectable
public boolean connect()
Connectable
Attempt a connection to the underlying hardware to establish communication only (no higher level messages)
Implementers must ensure the following behaviour:
connect
in interface Connectable
public void softDetach()
Connectable
Handle device detachment. The transport to the device is gone (device removed, socket server shut down etc)
Implementations may assume that recovery is possible (the hardware drivers still remain operational)
softDetach
in interface Connectable
public void hardDetach()
Connectable
Handle device detachment and imminent shutdown.
Recovery is not possible (the controlling thread is about to close, hardware drivers are closing)
hardDetach
in interface Connectable
protected com.google.common.base.Optional<MessageEvent> readFromDevice(int duration, TimeUnit timeUnit)
AbstractTrezorHardwareWallet
Read a complete message buffer from the device and convert it into a Core message.
readFromDevice
in class AbstractTrezorHardwareWallet
duration
- The durationtimeUnit
- The time unitpublic int writeToDevice(byte[] buffer)
AbstractTrezorHardwareWallet
Write a complete message buffer to the device.
writeToDevice
in class AbstractTrezorHardwareWallet
buffer
- Buffer to write to devicepublic void hidDeviceAttached(org.hid4java.event.HidServicesEvent event)
hidDeviceAttached
in interface org.hid4java.HidServicesListener
public void hidDeviceDetached(org.hid4java.event.HidServicesEvent event)
hidDeviceDetached
in interface org.hid4java.HidServicesListener
public void hidFailure(org.hid4java.event.HidServicesEvent event)
hidFailure
in interface org.hid4java.HidServicesListener
Copyright © 2013–2018 Bitcoin Solutions Ltd. All rights reserved.