public abstract class AbstractTrezorHardwareWallet extends AbstractHardwareWallet
Abstract base class provide the following to Trezor hardware wallets:
The Trezor generally uses USB HID framing and protocol buffer messages
specification
Constructor and Description |
---|
AbstractTrezorHardwareWallet() |
Modifier and Type | Method and Description |
---|---|
void |
disconnect()
Break the connection to the device
|
HardwareWalletSpecification |
getDefaultSpecification() |
protected abstract 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.
|
com.google.common.base.Optional<MessageEvent> |
readMessage(int duration,
TimeUnit timeUnit)
Read a protobuf message from the hardware wallet and adapt it to a Core message event.
|
void |
writeMessage(com.google.protobuf.Message message)
Send a message to the hardware wallet using the generated protocol buffer classes
|
protected abstract int |
writeToDevice(byte[] buffer)
Write a complete message buffer to the device.
|
applySpecification, getSpecification
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
name
attach, connect, hardDetach, softDetach
public HardwareWalletSpecification getDefaultSpecification()
public void disconnect()
Connectable
Break the connection to the device
Implementers must ensure the following behaviour:
public com.google.common.base.Optional<MessageEvent> readMessage(int duration, TimeUnit timeUnit)
HardwareWallet
Read a protobuf message from the hardware wallet and adapt it to a Core message event.
Consumers of this interface should check the returned message event wrapper for failure modes as appropriate.
Forcing early adaption to a message event eases the implementation in many ways.
duration
- The durationtimeUnit
- The time unitpublic void writeMessage(com.google.protobuf.Message message)
HardwareWallet
Send a message to the hardware wallet using the generated protocol buffer classes
Any response will be provided through the event bus subscribers
If this call fails the hardware wallet will be closed and a DISCONNECT message will be emitted
message
- A generated protocol buffer message (e.g. Message.Initialize)protected abstract 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.
duration
- The durationtimeUnit
- The time unitprotected abstract int writeToDevice(byte[] buffer)
Write a complete message buffer to the device.
buffer
- The buffer that will be written to the deviceCopyright © 2013–2017 Bitcoin Solutions Ltd. All rights reserved.