github.com/sberex/go-sberex@v1.8.2-0.20181113200658-ed96ac38f7d7/accounts/usbwallet/internal/trezor/trezor.go (about) 1 // This file is part of the go-sberex library. The go-sberex library is 2 // free software: you can redistribute it and/or modify it under the terms 3 // of the GNU Lesser General Public License as published by the Free 4 // Software Foundation, either version 3 of the License, or (at your option) 5 // any later version. 6 // 7 // The go-sberex library is distributed in the hope that it will be useful, 8 // but WITHOUT ANY WARRANTY; without even the implied warranty of 9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 10 // General Public License <http://www.gnu.org/licenses/> for more details. 11 12 // This file contains the implementation for interacting with the Trezor hardware 13 // wallets. The wire protocol spec can be found on the SatoshiLabs website: 14 // https://doc.satoshilabs.com/trezor-tech/api-protobuf.html 15 16 //go:generate protoc --go_out=import_path=trezor:. types.proto messages.proto 17 18 // Package trezor contains the wire protocol wrapper in Go. 19 package trezor 20 21 import ( 22 "reflect" 23 24 "github.com/golang/protobuf/proto" 25 ) 26 27 // Type returns the protocol buffer type number of a specific message. If the 28 // message is nil, this method panics! 29 func Type(msg proto.Message) uint16 { 30 return uint16(MessageType_value["MessageType_"+reflect.TypeOf(msg).Elem().Name()]) 31 } 32 33 // Name returns the friendly message type name of a specific protocol buffer 34 // type numbers. 35 func Name(kind uint16) string { 36 name := MessageType_name[int32(kind)] 37 if len(name) < 12 { 38 return name 39 } 40 return name[12:] 41 }