public class TrezorV1HidHardwareWallet extends AbstractTrezorHardwareWallet implements org.hid4java.HidServicesListener
Trezor implementation to provide the following to applications:
This uses a hybrid approach between libusb and hidapi
specification| Constructor and Description |
|---|
TrezorV1HidHardwareWallet()
Default constructor for use with dynamic binding
|
TrezorV1HidHardwareWallet(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 device (standard)
|
| 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.
|
String |
toString() |
protected int |
writeToDevice(byte[] buffer)
Write a complete message buffer to the device.
|
disconnect, getDefaultSpecification, readMessage, writeMessagegetSpecificationpublic TrezorV1HidHardwareWallet()
public TrezorV1HidHardwareWallet(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 device (standard)
vendorId - The vendor ID (default is 0x534c)productId - The product ID (default is 0x01)serialNumber - The device serial number (default is to accept any)public void applySpecification(HardwareWalletSpecification specification)
HardwareWalletApply any hardware wallet specific parameters
Implementers should override this, but call super.applySpecification(specification) as part of the application process
applySpecification in interface HardwareWalletapplySpecification in class AbstractHardwareWalletspecification - The HardwareWalletSpecificationpublic String name()
HardwareWalletAssist downstream API consumers with identifying the source of events
name in interface HardwareWalletpublic boolean attach()
ConnectableHandle 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 Connectablepublic void softDetach()
ConnectableHandle 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 Connectablepublic void hardDetach()
ConnectableHandle device detachment and imminent shutdown.
Recovery is not possible (the controlling thread is about to close, hardware drivers are closing)
hardDetach in interface Connectablepublic boolean connect()
ConnectableAttempt a connection to the underlying hardware to establish communication only (no higher level messages)
Implementers must ensure the following behaviour:
connect in interface Connectableprotected int writeToDevice(byte[] buffer)
AbstractTrezorHardwareWalletWrite a complete message buffer to the device.
writeToDevice in class AbstractTrezorHardwareWalletbuffer - The buffer that will be written to the deviceprotected com.google.common.base.Optional<MessageEvent> readFromDevice(int duration, TimeUnit timeUnit)
AbstractTrezorHardwareWalletRead a complete message buffer from the device and convert it into a Core message.
readFromDevice in class AbstractTrezorHardwareWalletduration - The durationtimeUnit - The time unitpublic void hidDeviceAttached(org.hid4java.event.HidServicesEvent event)
hidDeviceAttached in interface org.hid4java.HidServicesListenerpublic void hidDeviceDetached(org.hid4java.event.HidServicesEvent event)
hidDeviceDetached in interface org.hid4java.HidServicesListenerpublic void hidFailure(org.hid4java.event.HidServicesEvent event)
hidFailure in interface org.hid4java.HidServicesListenerCopyright © 2013–2016 Bitcoin Solutions Ltd. All rights reserved.