Skip to content

Commit

Permalink
added and generated protobufs
Browse files Browse the repository at this point in the history
  • Loading branch information
solipsis committed Nov 1, 2017
0 parents commit f1fea22
Show file tree
Hide file tree
Showing 8 changed files with 5,744 additions and 0 deletions.
314 changes: 314 additions & 0 deletions internal/exchange.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

58 changes: 58 additions & 0 deletions internal/exchange.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Exchange communication
*
* @keepkey_version 2.0.0
*/

// Sugar for easier handling in Java
option java_package = "com.keepkey.device-protocol";
option java_outer_classname = "KeepKeyExchange";

/**
* Structure representing address for various coin types (BTC, LTC, and etc).
* @used in ExchangeResponse
*/
message ExchangeAddress {
optional string coin_type = 1;
optional string address = 2;
optional string dest_tag = 3;
optional string rs_address = 4;
}

/**
* Structure representing exchange response version 2
*/
message ExchangeResponseV2 {
optional ExchangeAddress deposit_address = 1;
optional bytes deposit_amount = 2;
optional int64 expiration = 3;
optional bytes quoted_rate = 4;
optional ExchangeAddress withdrawal_address = 5;
optional bytes withdrawal_amount = 6;
optional ExchangeAddress return_address = 7;
optional bytes api_key = 8;
optional bytes miner_fee = 9;
optional bytes order_id = 10;
}

message SignedExchangeResponse {
optional ExchangeResponse response = 1; /* deprecated - latest firmware version throws error if this field is used */
optional bytes signature = 2;
optional ExchangeResponseV2 responseV2 = 3;
}

/**
* Structure representing exchange response version 1 (deprecated)
*/
message ExchangeResponse {
optional ExchangeAddress deposit_address = 1;
optional uint64 deposit_amount = 2;
optional int64 expiration = 3;
optional uint64 quoted_rate = 4;
optional ExchangeAddress withdrawal_address = 5;
optional uint64 withdrawal_amount = 6;
optional ExchangeAddress return_address = 7;
optional bytes api_key = 8;
optional uint64 miner_fee = 9;
optional bytes order_id = 10;
}
16 changes: 16 additions & 0 deletions internal/keepkey.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//go:generate protoc --go_out=import_path=keepkey:. types.proto exchange.proto messages.proto
package keepkey

import (
"reflect"

"github.com/golang/protobuf/proto"
)

func Type(msg proto.Message) uint16 {
return uint16(MessageType_value["MessageType_"+reflect.TypeOf(msg).Elem().Name()])
}

func Name(kind uint16) string {
return MessageType_name[int32(kind)]
}
Loading

0 comments on commit f1fea22

Please sign in to comment.