2014-03-25 18:20:36 +00:00
|
|
|
/**
|
|
|
|
* Types for TREZOR communication
|
|
|
|
*
|
|
|
|
* @author Marek Palatinus <slush@satoshilabs.com>
|
2014-06-05 19:55:56 +00:00
|
|
|
* @version 1.2
|
2014-03-25 18:20:36 +00:00
|
|
|
*/
|
|
|
|
|
2014-04-07 16:01:11 +00:00
|
|
|
// Sugar for easier handling in Java
|
|
|
|
option java_package = "com.satoshilabs.trezor.protobuf";
|
2014-02-03 22:13:09 +00:00
|
|
|
option java_outer_classname = "TrezorType";
|
2014-02-02 10:28:43 +00:00
|
|
|
|
2013-11-26 14:48:17 +00:00
|
|
|
import "google/protobuf/descriptor.proto";
|
|
|
|
|
2014-03-25 18:20:36 +00:00
|
|
|
/**
|
|
|
|
* Options for specifying message direction and type of wire (normal/debug)
|
|
|
|
*/
|
2013-11-26 14:48:17 +00:00
|
|
|
extend google.protobuf.EnumValueOptions {
|
2014-03-25 18:20:36 +00:00
|
|
|
optional bool wire_in = 50002; // message can be transmitted via wire from PC to TREZOR
|
|
|
|
optional bool wire_out = 50003; // message can be transmitted via wire from TREZOR to PC
|
2013-11-26 14:48:17 +00:00
|
|
|
optional bool wire_debug_in = 50004; // message can be transmitted via debug wire from PC to TREZOR
|
|
|
|
optional bool wire_debug_out = 50005; // message can be transmitted via debug wire from TREZOR to PC
|
|
|
|
}
|
|
|
|
|
2014-03-25 18:20:36 +00:00
|
|
|
/**
|
|
|
|
* Type of failures returned by Failure message
|
|
|
|
* @used_in Failure
|
|
|
|
*/
|
2013-11-26 14:48:17 +00:00
|
|
|
enum FailureType {
|
|
|
|
Failure_UnexpectedMessage = 1;
|
|
|
|
Failure_ButtonExpected = 2;
|
|
|
|
Failure_SyntaxError = 3;
|
|
|
|
Failure_ActionCancelled = 4;
|
|
|
|
Failure_PinExpected = 5;
|
|
|
|
Failure_PinCancelled = 6;
|
|
|
|
Failure_PinInvalid = 7;
|
|
|
|
Failure_InvalidSignature = 8;
|
2014-01-18 04:13:47 +00:00
|
|
|
Failure_Other = 9;
|
2014-02-08 23:15:03 +00:00
|
|
|
Failure_NotEnoughFunds = 10;
|
2014-02-11 15:59:24 +00:00
|
|
|
Failure_NotInitialized = 11;
|
2013-11-26 14:48:17 +00:00
|
|
|
Failure_FirmwareError = 99;
|
|
|
|
}
|
|
|
|
|
2014-03-25 18:20:36 +00:00
|
|
|
/**
|
|
|
|
* Type of script which will be used for transaction output
|
|
|
|
* @used_in TxOutputType
|
|
|
|
*/
|
2014-06-05 19:55:56 +00:00
|
|
|
enum OutputScriptType {
|
2013-11-26 14:48:17 +00:00
|
|
|
PAYTOADDRESS = 0;
|
|
|
|
PAYTOSCRIPTHASH = 1;
|
|
|
|
}
|
|
|
|
|
2014-06-05 19:55:56 +00:00
|
|
|
/**
|
|
|
|
* Type of script which will be used for transaction output
|
|
|
|
* @used_in TxInputType
|
|
|
|
*/
|
|
|
|
enum InputScriptType {
|
|
|
|
SPENDADDRESS = 0;
|
|
|
|
SPENDMULTISIG = 1;
|
|
|
|
}
|
|
|
|
|
2014-03-25 18:20:36 +00:00
|
|
|
/**
|
|
|
|
* Type of information required by transaction signing process
|
|
|
|
* @used_in TxRequest
|
|
|
|
*/
|
2013-11-26 14:48:17 +00:00
|
|
|
enum RequestType {
|
|
|
|
TXINPUT = 0;
|
|
|
|
TXOUTPUT = 1;
|
2014-03-25 18:20:36 +00:00
|
|
|
TXMETA = 2;
|
2014-04-09 18:19:30 +00:00
|
|
|
TXFINISHED = 3;
|
2013-11-26 14:48:17 +00:00
|
|
|
}
|
|
|
|
|
2014-03-25 18:20:36 +00:00
|
|
|
/**
|
|
|
|
* Type of button request
|
|
|
|
* @used_in ButtonRequest
|
|
|
|
*/
|
2014-02-04 16:47:29 +00:00
|
|
|
enum ButtonRequestType {
|
2014-02-06 09:34:50 +00:00
|
|
|
ButtonRequest_Other = 1;
|
|
|
|
ButtonRequest_FeeOverThreshold = 2;
|
|
|
|
ButtonRequest_ConfirmOutput = 3;
|
|
|
|
ButtonRequest_ResetDevice = 4;
|
|
|
|
ButtonRequest_ConfirmWord = 5;
|
|
|
|
ButtonRequest_WipeDevice = 6;
|
|
|
|
ButtonRequest_ProtectCall = 7;
|
2014-03-01 11:07:45 +00:00
|
|
|
ButtonRequest_SignTx = 8;
|
2014-02-04 16:47:29 +00:00
|
|
|
}
|
|
|
|
|
2014-03-25 18:20:36 +00:00
|
|
|
/**
|
|
|
|
* Type of PIN request
|
|
|
|
* @used_in PinMatrixRequest
|
|
|
|
*/
|
2014-03-10 17:08:34 +00:00
|
|
|
enum PinMatrixRequestType {
|
|
|
|
PinMatrixRequestType_Current = 1;
|
|
|
|
PinMatrixRequestType_NewFirst = 2;
|
|
|
|
PinMatrixRequestType_NewSecond = 3;
|
|
|
|
}
|
|
|
|
|
2014-03-25 18:20:36 +00:00
|
|
|
/**
|
|
|
|
* Structure representing BIP32 (hierarchical deterministic) node
|
|
|
|
* Used for imports of private key into the device and exporting public key out of device
|
|
|
|
* @used_in PublicKey
|
|
|
|
* @used_in LoadDevice
|
|
|
|
* @used_in DebugLinkState
|
|
|
|
* @used_in Storage
|
|
|
|
*/
|
2013-11-26 14:48:17 +00:00
|
|
|
message HDNodeType {
|
2014-02-21 21:14:41 +00:00
|
|
|
required uint32 depth = 1;
|
|
|
|
required uint32 fingerprint = 2;
|
|
|
|
required uint32 child_num = 3;
|
2014-03-01 10:17:06 +00:00
|
|
|
required bytes chain_code = 4;
|
|
|
|
optional bytes private_key = 5;
|
|
|
|
optional bytes public_key = 6;
|
2013-11-26 14:48:17 +00:00
|
|
|
}
|
|
|
|
|
2014-03-25 18:20:36 +00:00
|
|
|
/**
|
|
|
|
* Structure representing Coin
|
|
|
|
* @used_in Features
|
|
|
|
*/
|
2013-11-26 14:48:17 +00:00
|
|
|
message CoinType {
|
2014-03-01 10:17:06 +00:00
|
|
|
optional string coin_name = 1;
|
|
|
|
optional string coin_shortcut = 2;
|
2013-11-26 14:48:17 +00:00
|
|
|
optional uint32 address_type = 3;
|
|
|
|
optional uint64 maxfee_kb = 4;
|
|
|
|
}
|
|
|
|
|
2014-06-05 19:55:56 +00:00
|
|
|
/*
|
|
|
|
* Type of redeem script used in input
|
|
|
|
* @used_in TxInputType
|
|
|
|
*/
|
|
|
|
message MultisigRedeemScriptType {
|
|
|
|
repeated bytes pubkeys = 1; // pubkeys from multisig address (sorted lexicographically)
|
|
|
|
repeated bytes signatures = 2; // existing signatures for partially signed input
|
|
|
|
}
|
|
|
|
|
2014-03-25 18:20:36 +00:00
|
|
|
/**
|
|
|
|
* Structure representing transaction input
|
|
|
|
* @used_in SimpleSignTx
|
|
|
|
* @used_in TransactionType
|
|
|
|
*/
|
2013-11-26 14:48:17 +00:00
|
|
|
message TxInputType {
|
2014-06-05 19:55:56 +00:00
|
|
|
repeated uint32 address_n = 1; // BIP-32 path to derive the key from master node
|
|
|
|
required bytes prev_hash = 2; // hash of previous transaction output to spend by this input
|
|
|
|
required uint32 prev_index = 3; // index of previous output to spend
|
|
|
|
optional bytes script_sig = 4; // script signature, unset for tx to sign
|
|
|
|
optional uint32 sequence = 5 [default=0xffffffff]; // sequence
|
|
|
|
optional InputScriptType script_type = 6 [default=SPENDADDRESS]; // defines template of input script
|
|
|
|
optional MultisigRedeemScriptType multisig = 7; // Filled if input is going to spend multisig tx
|
2013-11-26 14:48:17 +00:00
|
|
|
}
|
|
|
|
|
2014-03-25 18:20:36 +00:00
|
|
|
/**
|
|
|
|
* Structure representing transaction output
|
|
|
|
* @used_in SimpleSignTx
|
|
|
|
* @used_in TransactionType
|
|
|
|
*/
|
2013-11-26 14:48:17 +00:00
|
|
|
message TxOutputType {
|
2014-06-05 19:55:56 +00:00
|
|
|
optional string address = 1; // target coin address in Base58 encoding
|
|
|
|
repeated uint32 address_n = 2; // BIP-32 path to derive the key from master node; has higher priority than "address"
|
|
|
|
required uint64 amount = 3; // amount to spend in satoshis
|
|
|
|
required OutputScriptType script_type = 4; // output script type
|
2013-11-26 14:48:17 +00:00
|
|
|
}
|
|
|
|
|
2014-03-25 18:20:36 +00:00
|
|
|
/**
|
|
|
|
* Structure representing compiled transaction output
|
|
|
|
* @used_in TransactionType
|
|
|
|
*/
|
2013-11-26 14:48:17 +00:00
|
|
|
message TxOutputBinType {
|
|
|
|
required uint64 amount = 1;
|
2014-03-01 10:17:06 +00:00
|
|
|
required bytes script_pubkey = 2;
|
2013-11-26 14:48:17 +00:00
|
|
|
}
|
|
|
|
|
2014-03-25 18:20:36 +00:00
|
|
|
/**
|
|
|
|
* Structure representing transaction
|
|
|
|
* @used_in SimpleSignTx
|
|
|
|
*/
|
2013-11-26 14:48:17 +00:00
|
|
|
message TransactionType {
|
2014-03-25 18:20:36 +00:00
|
|
|
optional uint32 version = 1;
|
2013-11-26 14:48:17 +00:00
|
|
|
repeated TxInputType inputs = 2;
|
2014-04-02 18:27:42 +00:00
|
|
|
repeated TxOutputBinType bin_outputs = 3;
|
|
|
|
repeated TxOutputType outputs = 5;
|
|
|
|
optional uint32 lock_time = 4;
|
2014-04-17 11:27:18 +00:00
|
|
|
optional uint32 inputs_cnt = 6;
|
|
|
|
optional uint32 outputs_cnt = 7;
|
2013-11-26 14:48:17 +00:00
|
|
|
}
|
2014-04-10 12:42:50 +00:00
|
|
|
|
2014-06-05 18:15:38 +00:00
|
|
|
/*
|
|
|
|
* @used_in TxRequest
|
|
|
|
*/
|
2014-04-10 12:42:50 +00:00
|
|
|
message TxRequestDetailsType {
|
2014-04-11 13:22:50 +00:00
|
|
|
optional uint32 request_index = 1; // device expects TxAck message from the computer
|
|
|
|
optional bytes tx_hash = 2; // tx_hash of requested transaction
|
2014-04-10 12:42:50 +00:00
|
|
|
}
|
|
|
|
|
2014-06-05 18:15:38 +00:00
|
|
|
/*
|
|
|
|
* @used_in TxRequest
|
|
|
|
*/
|
2014-04-10 12:42:50 +00:00
|
|
|
message TxRequestSerializedType {
|
2014-04-11 13:22:50 +00:00
|
|
|
optional uint32 signature_index = 1; // 'signature' field contains signed input of this index
|
|
|
|
optional bytes signature = 2; // signature of the signature_index input
|
|
|
|
optional bytes serialized_tx = 3; // part of serialized and signed transaction
|
2014-04-10 12:42:50 +00:00
|
|
|
}
|