github.com/arieschain/arieschain@v0.0.0-20191023063405-37c074544356/accounts/usbwallet/internal/trezor/trezor.go (about) 1 // This file contains the implementation for interacting with the Trezor hardware 2 // wallets. The wire protocol spec can be found on the SatoshiLabs website: 3 // https://doc.satoshilabs.com/trezor-tech/api-protobuf.html 4 5 //go:generate protoc --go_out=import_path=trezor:. types.proto messages.proto 6 7 // Package trezor contains the wire protocol wrapper in Go. 8 package trezor 9 10 import ( 11 "reflect" 12 13 "github.com/golang/protobuf/proto" 14 ) 15 16 // Type returns the protocol buffer type number of a specific message. If the 17 // message is nil, this method panics! 18 func Type(msg proto.Message) uint16 { 19 return uint16(MessageType_value["MessageType_"+reflect.TypeOf(msg).Elem().Name()]) 20 } 21 22 // Name returns the friendly message type name of a specific protocol buffer 23 // type numbers. 24 func Name(kind uint16) string { 25 name := MessageType_name[int32(kind)] 26 if len(name) < 12 { 27 return name 28 } 29 return name[12:] 30 }