github.com/linapex/ethereum-dpos-chinese@v0.0.0-20190316121959-b78b3a4a1ece/accounts/usbwallet/internal/trezor/trezor.go (about)

     1  
     2  //<developer>
     3  //    <name>linapex 曹一峰</name>
     4  //    <email>linapex@163.com</email>
     5  //    <wx>superexc</wx>
     6  //    <qqgroup>128148617</qqgroup>
     7  //    <url>https://jsq.ink</url>
     8  //    <role>pku engineer</role>
     9  //    <date>2019-03-16 12:09:27</date>
    10  //</624342586764562432>
    11  
    12  
    13  //此文件包含用于与Trezor硬件交互的实现
    14  //钱包。有线协议规范可在Satoshilabs网站上找到:
    15  //https://doc.satoshilabs.com/trezor-tech/api-protobuf.html网站
    16  
    17  //go:generate protoc--go_out=import_path=trezor:。types.proto消息.proto
    18  
    19  //包trezor在go中包含有线协议包装器。
    20  package trezor
    21  
    22  import (
    23  	"reflect"
    24  
    25  	"github.com/golang/protobuf/proto"
    26  )
    27  
    28  //类型返回特定消息的协议缓冲区类型号。如果
    29  //消息为零,此方法会恐慌!
    30  func Type(msg proto.Message) uint16 {
    31  	return uint16(MessageType_value["MessageType_"+reflect.TypeOf(msg).Elem().Name()])
    32  }
    33  
    34  //name返回特定协议缓冲区的友好消息类型名称
    35  //类型号。
    36  func Name(kind uint16) string {
    37  	name := MessageType_name[int32(kind)]
    38  	if len(name) < 12 {
    39  		return name
    40  	}
    41  	return name[12:]
    42  }
    43