public class KeepKeyV1HidHardwareWallet extends AbstractKeepKeyHardwareWallet implements org.hid4java.HidServicesListener
KeepKey implementation to provide the following to applications:
This uses a hybrid approach between libusb and hidapi
specification
Constructor and Description |
---|
KeepKeyV1HidHardwareWallet()
Default constructor for use with dynamic binding
|
KeepKeyV1HidHardwareWallet(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 KeepKey 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, writeMessage
getSpecification
public KeepKeyV1HidHardwareWallet()
public KeepKeyV1HidHardwareWallet(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 KeepKey device (standard)
vendorId
- The vendor ID (default is 0x2b24)productId
- The product ID (default is 0x01)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 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
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
protected int writeToDevice(byte[] buffer)
AbstractKeepKeyHardwareWallet
Write a complete message buffer to the device.
writeToDevice
in class AbstractKeepKeyHardwareWallet
buffer
- The buffer that will be written to the deviceprotected com.google.common.base.Optional<MessageEvent> readFromDevice(int duration, TimeUnit timeUnit)
AbstractKeepKeyHardwareWallet
Read a complete message buffer from the device and convert it into a Core message.
readFromDevice
in class AbstractKeepKeyHardwareWallet
duration
- The durationtimeUnit
- The time unitpublic 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–2016 Bitcoin Solutions Ltd. All rights reserved.