public final class KeepKeyMessageUtils extends Object
Utility class to provide the following to applications:
Modifier and Type | Method and Description |
---|---|
static List<Integer> |
buildAddressN(com.google.common.collect.ImmutableList<org.bitcoinj.crypto.ChildNumber> receivingAddressPath)
Build an AddressN chain code structure
|
static List<Integer> |
buildAddressN(int account,
org.bitcoinj.wallet.KeyChain.KeyPurpose keyPurpose,
int index)
Build an AddressN chain code structure
|
static KeepKeyType.TransactionType |
buildTxInputResponse(TxRequest txRequest,
com.google.common.base.Optional<org.bitcoinj.core.Transaction> requestedTx,
boolean binOutputType,
Map<Integer,com.google.common.collect.ImmutableList<org.bitcoinj.crypto.ChildNumber>> receivingAddressPathMap) |
static KeepKeyType.TransactionType |
buildTxMetaResponse(com.google.common.base.Optional<org.bitcoinj.core.Transaction> requestedTx) |
static KeepKeyType.TransactionType |
buildTxOutputResponse(TxRequest txRequest,
com.google.common.base.Optional<org.bitcoinj.core.Transaction> requestedTx,
boolean binOutputType,
Map<org.bitcoinj.core.Address,com.google.common.collect.ImmutableList<org.bitcoinj.crypto.ChildNumber>> changeAddressPathMap) |
static ByteBuffer |
formatAsHIDPackets(com.google.protobuf.Message message)
Format a KeepKey protobuf message as a byte buffer filled with HID packets
|
static void |
logPacket(String prefix,
int count,
byte[] buffer) |
static MessageEvent |
parse(KeepKeyMessage.MessageType type,
byte[] buffer) |
static MessageEvent |
parseAsHIDPackets(InputStream in)
Parse the contents of the input stream into a KeepKey protobuf message
|
static void |
writeAsHIDPackets(com.google.protobuf.Message message,
OutputStream out)
Write a KeepKey protocol buffer message to an OutputStream
|
public static MessageEvent parse(KeepKeyMessage.MessageType type, byte[] buffer)
type
- The message typebuffer
- The buffer containing the protobuf messagepublic static void logPacket(String prefix, int count, byte[] buffer)
prefix
- The logging prefix (usually ">" for write and "<" for read)count
- The packet countbuffer
- The buffer containing the packet to logpublic static void writeAsHIDPackets(com.google.protobuf.Message message, OutputStream out) throws IOException
Write a KeepKey protocol buffer message to an OutputStream
message
- The protocol buffer message to readout
- The data output stream (must be open)IOException
- If the device disconnects during IOpublic static ByteBuffer formatAsHIDPackets(com.google.protobuf.Message message)
Format a KeepKey protobuf message as a byte buffer filled with HID packets
message
- The KeepKey protobuf messagepublic static MessageEvent parseAsHIDPackets(InputStream in) throws IOException
Parse the contents of the input stream into a KeepKey protobuf message
in
- The input stream containing KeepKey HID packetsIOException
public static KeepKeyType.TransactionType buildTxMetaResponse(com.google.common.base.Optional<org.bitcoinj.core.Transaction> requestedTx)
requestedTx
- The requested txpublic static KeepKeyType.TransactionType buildTxInputResponse(TxRequest txRequest, com.google.common.base.Optional<org.bitcoinj.core.Transaction> requestedTx, boolean binOutputType, Map<Integer,com.google.common.collect.ImmutableList<org.bitcoinj.crypto.ChildNumber>> receivingAddressPathMap)
txRequest
- The KeepKey requestrequestedTx
- The requested tx (either current or a previous one providing inputs)binOutputType
- True if the requested tx is a parent (the receiving address map does not apply)receivingAddressPathMap
- A map of paths for rapid address lookup (called AddressN in KeepKey protobuf)public static KeepKeyType.TransactionType buildTxOutputResponse(TxRequest txRequest, com.google.common.base.Optional<org.bitcoinj.core.Transaction> requestedTx, boolean binOutputType, Map<org.bitcoinj.core.Address,com.google.common.collect.ImmutableList<org.bitcoinj.crypto.ChildNumber>> changeAddressPathMap)
txRequest
- The KeepKey requestrequestedTx
- The requested tx (either current or a previous one providing inputs)changeAddressPathMap
- A map of paths for rapid address lookup (called AddressN in KeepKey protobuf)public static List<Integer> buildAddressN(int account, org.bitcoinj.wallet.KeyChain.KeyPurpose keyPurpose, int index)
Build an AddressN chain code structure
account
- The plain account number (0 gives maximum compatibility)keyPurpose
- The key purpose (RECEIVE_FUNDS,CHANGE,REFUND,AUTHENTICATION etc)index
- The plain index of the required addresspublic static List<Integer> buildAddressN(com.google.common.collect.ImmutableList<org.bitcoinj.crypto.ChildNumber> receivingAddressPath)
Build an AddressN chain code structure
receivingAddressPath
- The Bitcoinj receiving address pathCopyright © 2013–2016 Bitcoin Solutions Ltd. All rights reserved.