public class TrezorShieldSocketHardwareWallet extends AbstractTrezorHardwareWallet
Trezor implementation to provide the following to applications:
This class uses standard sockets but includes HID framing
specification
Constructor and Description |
---|
TrezorShieldSocketHardwareWallet()
Default constructor for use with dynamic binding
|
TrezorShieldSocketHardwareWallet(String host,
int port)
Create a new socket connection to a Trezor device
|
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.
|
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.
|
protected int |
writeToDevice(byte[] buffer)
Write a complete message buffer to the device.
|
disconnect, getDefaultSpecification, readMessage, writeMessage
getSpecification
public TrezorShieldSocketHardwareWallet()
public TrezorShieldSocketHardwareWallet(String host, int port)
Create a new socket connection to a Trezor device
host
- The host name or IP address (e.g. "192.168.0.1")port
- The port (e.g. 3000)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
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
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)
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)
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:
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 unitprotected int writeToDevice(byte[] buffer)
AbstractTrezorHardwareWallet
Write a complete message buffer to the device.
writeToDevice
in class AbstractTrezorHardwareWallet
buffer
- The buffer that will be written to the deviceCopyright © 2013–2017 Bitcoin Solutions Ltd. All rights reserved.