diff --git a/.travis.yml b/.travis.yml index 3f1e4c4709b..34fa71b3d15 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,6 +8,7 @@ sudo: false before_install: - bash install-protobuf.sh + - bash install-googleapis.sh # check what has been installed by listing contents of protobuf folder before_script: @@ -16,4 +17,8 @@ before_script: # let's use protobuf script: - $HOME/protobuf/bin/protoc --java_out=./ ./core/*.proto ./api/*.proto + - $HOME/protobuf/bin/protoc -I. -I$GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis --go_out=./ ./core/*.proto + - $HOME/protobuf/bin/protoc -I. -I$GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis --go_out=./ ./api/*.proto + - $HOME/protobuf/bin/protoc -I. -I$GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis --grpc-gateway_out=logtostderr=true:./ ./api/*.proto + - ls -l \ No newline at end of file diff --git a/Chinese version of TRON Protocol document.md b/Chinese version of TRON Protocol document.md new file mode 100644 index 00000000000..cc1bd2d68d9 --- /dev/null +++ b/Chinese version of TRON Protocol document.md @@ -0,0 +1,698 @@ +# TRON protobuf protocol + +## TRON使用Google protobuf协议,协议内容涉及到账户,区块,传输多个层面。 + ++ 账户有基本账户、资产发布账户和合约账户三种类型。一个账户包含:账户名称,账户类型,地址,余额,投票,其他资产6种属性。 ++ 更进一步的,基本账户可以申请成为验证节点,验证节点具有额外的属性,投票统计数目,公钥,URL,以及历史表现等参数。 + + 3种`Account`类型:`Normal`,`AssetIssue`,`Contract`。 + + enum AccountType {
 + Normal = 0;
 + AssetIssue = 1;
 + Contract = 2;
 + } + + 一个`Account`包含7种参数: + `account_name`:该账户的名称——比如: ”_SicCongsAccount_”。 + `type`:该账户的类型——比如: _0_ 代表的账户类型是`Normal`。 + `balance`:该账户的TRX余额——比如:_4213312_。 + `votes`:账户所得投票数——比如:_{(“0x1b7w…9xj3”,323),(“0x8djq…j12m”,88),…,(“0x82nd…mx6i”,10001)}_。 + `asset`:除TRX以外账户上的其他资产——比如:_{<”WishToken”,66666>,<”Dogie”,233>}_。 + `latest_operation_time`: 该账户的最新活跃时间。 + + // Account
 + message Account {
 + message Vote {
 + bytes vote_address = 1;
 + int64 vote_count = 2;
 + }
 + bytes accout_name = 1;
 + AccountType type = 2;
 + bytes address = 3;
 + int64 balance = 4;
 + repeated Vote votes = 5;
 + map asset = 6;
 + int64 latest_operation_time = 10; + } + + 一个`Witness`包含8种参数: + `address`:验证节点的地址——比如:_“0xu82h…7237”_。 + `voteCount`:验证节点所得投票数——比如:_234234_。 + `pubKey`:验证节点的公钥——比如:_“0xu82h…7237”_。 + `url`:验证节点的url链接。 + `totalProduce`:验证节点产生的区块数——比如:_2434_。 + `totalMissed`:验证节点丢失的区块数——比如:_7_。 + `latestBlockNum`:最新的区块高度——比如:_4522_。 + `isJobs`:布尔表类型标志位。 + + // Witness
 + message Witness {
 + bytes address = 1;
 + int64 voteCount = 2;
 + bytes pubKey = 3;
 + string url = 4;
 + int64 totalProduced = 5;
 + int64 totalMissed = 6;
 + int64 latestBlockNum = 7; + bool isJobs = 9; + 
} + ++ 一个区块由区块头和多笔交易构成。区块头包含时间戳,交易字典树的根,父哈希,签名等区块基本信息。 + + 一个`block`包含`transactions`和`block_header`。 + `transactions`:区块里的交易信息。 + `block_header`:区块的组成部分之一。 + + // block
 + message Block {
 + repeated Transaction transactions = 1;
 + BlockHeader block_header = 2; + 
} + + `BlockHeader` 包括`raw_data`和`witness_signature`。 + `raw_data`:`raw`信息。 + `witness_signature`:区块头到验证节点的签名。 + + message `raw`包含6种参数: + `timestamp`:该消息体的时间戳——比如:_14356325_。 + `txTrieRoot`:Merkle Tree的根——比如:_“7dacsa…3ed”_。 + `parentHash`:上一个区块的哈希值——比如:_“7dacsa…3ed”_。 + `number`:区块高度——比如:_13534657_。 + `witness_id`:验证节点的id——比如:_“0xu82h…7237”_。 + `witness_address`:验证节点的地址——比如:_“0xu82h…7237”_。 + + message BlockHeader {
 + message raw {
 + int64 timestamp = 1;
 + bytes txTrieRoot = 2;
 + bytes parentHash = 3;
 + //bytes nonce = 5;
 + //bytes difficulty = 6;
 + uint64 number = 7;
 + uint64 witness_id = 8;
 + bytes witness_address = 9;
 + }
 + raw raw_data = 1;
 + bytes witness_signature = 2; + 
} + + 消息体 `ChainInventory` 包括 `BlockId` 和 `remain_num`。 + `BlockId`: block的身份信息。 + `remain_num`:在同步过程中,剩余的区块数量。 + + A `BlockId` contains 2 parameters: + `hash`: 该区块的哈希值。 + `number`: 哈希值和高度即为当前区块块号。 + + message ChainInventory { + message BlockId { + bytes hash = 1; + int64 number = 2; + } + repeated BlockId ids = 1; + int64 remain_num = 2; + } + ++ 交易合约有多种类型,包括账户创建合约、账户更新合约、转账合约、转账断言合约、资产投票合约、见证节点投票合约、见证节点创建合约、见证节点更新合约、资产发布合约、参与资产发布和与部署合约11种类型。 + + `AccountCreatContract`包含3种参数: + `type`:账户类型——比如:_0_ 代表的账户类型是`Normal`。 + `account_name`: 账户名称——比如: _"SiCongsaccount”_。 + `owner_address`:合约持有人地址——比如: _“0xu82h…7237”_。 + + message AccountCreateContract {
 + AccountType type = 1;
 + bytes account_name = 2;
 + bytes owner_address = 3;
 + } + `AccountUpdateContract`包含2种参数: + `account_name`: 账户名称——比如: _"SiCongsaccount”_。 + `owner_address`:合约持有人地址——比如: _“0xu82h…7237”_。 + + message AccountUpdateContract { + bytes account_name = 1; + bytes owner_address = 2; + } + + `TransferContract`包含3种参数: + `amount`:TRX数量——比如:_12534_。 + `to_address`: 接收方地址——比如:_“0xu82h…7237”_。 + `owner_address`:合约持有人地址——比如:_“0xu82h…7237”_。 + + message TransferContract {
 + bytes owner_address = 1;
 + bytes to_address = 2;
 + int64 amount = 3; + 
} + + `TransferAssetContract`包含4种参数: + `asset_name`:资产名称——比如:_”SiCongsaccount”_。 + `to_address`:接收方地址——比如:_“0xu82h…7237”_。 + `owner_address`:合约持有人地址——比如:_“0xu82h…7237”_。 + `amount`:目标资产数量——比如:_12353_。 + + message TransferAssetContract {
 + bytes asset_name = 1;
 + bytes owner_address = 2;
 + bytes to_address = 3;
 + int64 amount = 4;
 + } + + `VoteAssetContract`包含4种参数: + `vote_address`:投票人地址——比如:_“0xu82h…7237”_。 + `support`:投票赞成与否——比如:_true_。 + `owner_address`:合约持有人地址——比如:_“0xu82h…7237”_。 + `count`:投票数目——比如:_2324234_。 + + message VoteAssetContract {
 + bytes owner_address = 1;
 + repeated bytes vote_address = 2;
 + bool support = 3;
 + int32 count = 5; + } + + `VoteWitnessContract`包含4种参数: + `vote_address`:投票人地址——比如:_“0xu82h…7237”_。 + `support`:投票赞成与否——比如:_true_。 + `owner_address`:合约持有人地址——比如:_“0xu82h…7237”_。 + `count`:投票数目——比如:_32632_。 + + message VoteWitnessContract {
 + bytes owner_address = 1;
 + repeated bytes vote_address = 2;
 + bool support = 3;
 + int32 count = 5;
 + } + + `WitnessCreateContract`包含3种参数: + `private_key`:合约的私钥——比如:_“0xu82h…7237”_。 + `owner_address`:合约持有人地址——比如:_“0xu82h…7237”_。 + `url`:合约的url链接。 + + message WitnessCreateContract {
 + bytes owner_address = 1;
 + bytes private_key = 2;
 + bytes url = 12; + 
} + + `WitnessUpdateContract`包含2种参数: + `owner_address`:合约持有人地址——比如:_“0xu82h…7237”_。 + `update_url`:合约的url链接。 + + message WitnessUpdateContract { + bytes owner_address = 1; + bytes update_url = 12; + } + + `AssetIssueContract`包含11种参数: + `name`:合约名称——比如:_“SiCongcontract”_。 + `total_supply`:合约的赞成总票数——比如:_100000000_。 + `owner_address`:合约持有人地址——比如:_“0xu82h…7237”_。 + `trx_num`:对应TRX数量——比如:_232241_。 + `num`: 对应的自定义资产数目。 + `start_time`:开始时间——比如:_20170312_。 + `end_time`:结束时间——比如:_20170512_。 + `decav_ratio`:衰减速率。 + `vote_score`:合约的评分——比如:_12343_。 + `description`:合约的描述——比如:_”trondada”_。 + `url`:合约的url地址链接。 + + message AssetIssueContract {
 + bytes owner_address = 1;
 + bytes name = 2;
 + int64 total_supply = 4;
 + int32 trx_num = 6;
 + int32 num = 8;
 + int64 start_time = 9;
 + int64 end_time = 10;
 + int32 decay_ratio = 15;
 + int32 vote_score = 16;
 + bytes description = 20;
 + bytes url = 21;
 + } + + `ParticipateAssetIssueContract`包含4种参数: + `owner_address`:合约持有人地址——比如:_“0xu82h…7237”_。 + `to_address`:接收方地址——比如:_“0xu82h…7237”_。 + `asset_name`: 目标资产的名称。 + `amount`: 小部分数量。 + + `DeployContract`包含2种参数: + `script`:脚本。 + `owner_address`:合约持有人地址——比如:_“0xu82h…7237”_。 + + message DeployContract {
 + bytes owner_address = 1;
 + bytes script = 2;
 + } + + 消息体 `Result` 包含 `fee` and `ret`2个参数. + `ret`: 交易结果。 + `fee`: 交易扣除的费用。 + + `code`是`ret`的类型定义,有`SUCCESS`和`FAILED`两种类型。 + + message Result { + enum code { + SUCESS = 0; + FAILED = 1; + } + int64 fee = 1; + code ret = 2; + } + ++ 每一个交易还包含多个输入与多个输出,以及其他一些相关属性。其中交易内的输入,交易本身,区块头均需签名。 + + 消息体 `Transaction`包括`raw_data`和`signature`。 + `raw_data`: 消息体`raw`。 + `signature`: 所有输入节点的签名。 + + `raw_data`包含8种参数: + `type`:消息体raw的交易类型。 + `vin`: 输入值。 + `vout`: 输出值。 + `expiration`:过期时间——比如:_20170312_。 + `data`: 数据。 + `contract`: 该交易内的合约。 + `script`: 脚本。 + `timestamp`:该消息体的时间戳。 + + 消息体 `Contract`包含`type`和`parameter`。 + `type`:合约的类型。 + `parameter`:任意参数。 + + 有八种账户类型合约:`AccountCreateContract`,`TransferContract`,`TransferAssetContract`,`VoteAssetContract`,`VoteWitnessContract`,`WitnessCreateContract`,`AssetIssueContract` 和`DeployContract`。 + + `TransactionType`包括`UtxoType`和`ContractType`。 + + message Transaction {
 + enum TranscationType {
 + UtxoType = 0;
 + ContractType = 1;
 + }
 + message Contract {
 + enum ContractType {
 + AccountCreateContract = 0;
 + TransferContract = 1;
 + TransferAssetContract = 2;
 + VoteAssetContract = 3;
 + VoteWitnessContract = 4;
 + WitnessCreateContract = 5;
 + AssetIssueContract = 6;
 + DeployContract = 7;
 + }
 + ContractType type = 1;
 + google.protobuf.Any parameter = 2;
 + }
 + message raw {
 + TranscationType type = 2;
 + repeated TXInput vin = 5;
 + repeated TXOutput vout = 7;
 + int64 expiration = 8;
 + bytes data = 10;
 + repeated Contract contract = 11;
 + bytes scripts = 16;
 + in64 timestamp = 17; + }
 + raw raw_data = 1;
 + repeated bytes signature = 5;
 + } + + 消息体 `TXOutputs`由`outputs`构成。 + `outputs`: 元素为`TXOutput`的数组。 + + message TXOutputs {
 + repeated TXOutput outputs = 1; + 
} + + 消息体 `TXOutput`包括`value`和`pubKeyHash`。 + `value`:输出值。 + `pubKeyhash`:公钥的哈希。 + + message TXOutput {
 + int64 value = 1;
 + bytes pubKeyHash = 2; + 
} + + 消息体 `TXIutput`包括`raw_data`和`signature`。 + `raw_data`:消息体`raw`。 + `signature`:`TXInput`的签名。 + + 消息体 `raw`包含`txID`,`vout`和 `pubKey`。 + `txID`:交易ID。 + `Vout`:上一个输出的值。 + `pubkey`:公钥。 + + message TXInput {
 + message raw {
 + bytes txID = 1;
 + int64 vout = 2;
 + bytes pubKey = 3;
 + }
 + raw raw_data = 1;
 + bytes signature = 4;
} + ++ 传输涉及的协议Inventory主要用于传输中告知接收方传输数据的清单。 + + `Inventory`包括`type`和`ids`。 + `type`:清单类型——比如:_0_ 代表`TRX`。 + `ids`:清单中的物品ID。 + + `InventoryType`包含`TRX`和 `BLOCK`。 + `TRX`:交易。 + `BLOCK`:区块。 + + // Inventory
 + message Inventory {
 + enum InventoryType {
 + TRX = 0;
 + BLOCK = 1;
 + }
 + InventoryType type = 1;
 + repeated bytes ids = 2; + 
} + + 消息体 `Items`包含4种参数: + `type`:物品类型——比如:_1_ 代表 `TRX`。 + `blocks`:物品中区块。 + `blockheaders`:区块头。 + `transactions`:交易。 + + `Items`有四种类型,分别是 `ERR`, `TRX`,`BLOCK` 和`BLOCKHEADER`。 + `ERR`:错误。 + `TRX`:交易。 + `BLOCK`:区块。 + `BLOCKHEADER`:区块头。 + + message Items {
 + enum ItemType {
 + ERR = 0;
 + TRX = 1;
 + BLOCK = 2;
 + BLOCKHEADER = 3;
 + }
 + ItemType type = 1;
 + repeated Block blocks = 2;
 + repeated BlockHeader block_headers = 3;
 + repeated Transaction transactions = 4;
 + } + + `Inventory`包含`type`和`items`。 + `type`:物品种类。 + `items`:物品清单。 + + message InventoryItems {
 + int32 type = 1;
 + repeated bytes items = 2;
 + } + + 消息体 `BlockInventory` 包含 `type`。 + `type`: 清单种类. + + 有三种类型:`SYNC`, `ADVTISE`, `FETCH`。 + + // Inventory + message BlockInventory { + enum Type { + SYNC = 0; + ADVTISE = 1; + FETCH = 2; + } + + 消息体 `BlockId` 包括 `ids` and `type`。 + `ids`: 区块身份信息。 + `type`: 区块类型。 + + `ids` 包含2种参数: + `hash`: 区块的哈希值。 + `number`: 哈希值和区块高度即为当前区块号。 + + message BlockId { + bytes hash = 1; + int64 number = 2; + } + repeated BlockId ids = 1; + Type type = 2; + } + + `ReasonCode` 有15种可能断开的原因: + `REQUESTED` + `TCP_ERROR` + `BAD_PROTOCOL` + `USELESS_PEER` + `TOO_MANY_PEERS` + `DUPLICATE_PEER` + `INCOMPATIBLE_PROTOCOL` + `NULL_IDENTITY` + `PEER_QUITING` + `UNEXPECTED_IDENTITY` + `LOCAL_IDENTITY` + `PING_TIMEOU` + `USER_REASON` + `RESET` + `UNKNOWN` + + enum ReasonCode { + REQUESTED = 0; + TCP_ERROR = 1; + BAD_PROTOCOL = 2; + USELESS_PEER = 3; + TOO_MANY_PEERS = 4; + DUPLICATE_PEER = 5; + INCOMPATIBLE_PROTOCOL = 6; + NULL_IDENTITY = 7; + PEER_QUITING = 8; + UNEXPECTED_IDENTITY = 9; + LOCAL_IDENTITY = 10; + PING_TIMEOUT = 11; + USER_REASON = 12; + RESET = 16; + UNKNOWN = 255; + } + + 消息体`DisconnectMessage`包含`reason`。 + `DisconnectMessage`:断开连接是的消息。 + `reason`:断开连接时的原因。 + + 消息体`HelloMessage`包含2个参数: + `from`请:求建立连接的节点。 + `version`:建立连接的节点。 + ++ 钱包服务RPC和区块链浏览器。 + + `Wallet`钱包服务包含多个RPC。 + __`Getbalance`__:获取`Account`的余额。 + __`CreatTransaction`__:通过`TransferContract`创建交易。 + __`BroadcastTransaction`__:广播`Transaction`。 + __`CreateAccount`__:通过`AccountCreateContract`创建账户。 + __`CreatAssetIssue`__:通过`AssetIssueContract`发布一个资产。 + __`ListAccounts`__:通过`ListAccounts`查看账户列表。 + __`UpdateAccount`__:通过`UpdateAccountContract`发布一个资产。 + __`VoteWitnessAccount`__:通过`VoteWitnessContract`发布一个资产。 + __`WitnessList`__:通过`WitnessList`查看见证节点列表。 + __`UpdateWitness`__:通过`WitnessUpdateContract`发布一个资产。 + __`CreateWitness`__:通过`WitnessCreateContract`发布一个资产。 + __`TransferAsset`__:通过`TransferAssetContract`发布一个资产。 + __`ParticipateAssetIssue`__:通过`ParticipateAssetIssueContract`发布一个资产。 + __`ListNodes`__:通过`ListNodes`查看节点列表。 + __`GetAssetIssueList`__:通过`GetAssetIssueList`查看资产发布节点列表。 + __`GetAssetIssueByAccount`__:通过`Account`获取发行资产。 + __`GetAssetIssueByName`__:通过`Name`获取发行资产。 + __`GetNowBlock`__:获取区块。 + __`GetBlockByNum`__:根据块号获取区块。 + __`TotalTransaction`__:查看总交易量。 + + service Wallet { + + rpc GetAccount (Account) returns (Account) { + + }; + + rpc CreateTransaction (TransferContract) returns (Transaction) { + + }; + + rpc BroadcastTransaction (Transaction) returns (Return) { + + }; + + rpc ListAccounts (EmptyMessage) returns (AccountList) { + + }; + + rpc UpdateAccount (AccountUpdateContract) returns (Transaction) { + + }; + + rpc CreateAccount (AccountCreateContract) returns (Transaction) { + + }; + + rpc VoteWitnessAccount (VoteWitnessContract) returns (Transaction) { + + }; + + rpc CreateAssetIssue (AssetIssueContract) returns (Transaction) { + + }; + + rpc WitnessList (EmptyMessage) returns (WitnessList) { + + }; + + rpc UpdateWitness (WitnessUpdateContract) returns (Transaction) { + + }; + + rpc CreateWitness (WitnessCreateContract) returns (Transaction) { + + }; + + rpc TransferAsset (TransferAssetContract) returns (Transaction) { + + } + + rpc ParticipateAssetIssue (ParticipateAssetIssueContract) returns (Transaction) { + + } + + rpc ListNodes (EmptyMessage) returns (NodeList) { + + } + rpc GetAssetIssueList (EmptyMessage) returns (AssetIssueList) { + + } + rpc GetAssetIssueByAccount (Account) returns (AssetIssueList) { + + } + rpc GetAssetIssueByName (BytesMessage) returns (AssetIssueContract) { + + } + rpc GetNowBlock (EmptyMessage) returns (Block) { + + } + rpc GetBlockByNum (NumberMessage) returns (Block) { + + } + rpc TotalTransaction (EmptyMessage) returns (NumberMessage) { + + } + }; + + `AccountList`: 区块链浏览器中的账户列表。 + 消息体 `AccountList` 包含1个参数: + `account`: + + message AccountList { + repeated Account accounts = 1; + } + + `WitnessList`:区块链浏览器中的见证节点列表。 + 消息体 `WitnessList` 包含1个参数: + `witnesses`: + + message WitnessList { + repeated Witness witnesses = 1; + } + + `AssetIssueList`:区块链浏览器中的发布资产列表。 + 消息体 `AssetIssueList` 包含1个参数: + `assetIssue`: + + message AssetIssueList { + repeated AssetIssueContract assetIssue = 1; + } + + + `NodeList`: 分布节点图中的节点列表。 + 消息体 `NodeList` 包含1个参数: + `nodes`: + + message NodeList { + repeated Node nodes = 1; + } + + `Address`: 节点地址。 + 消息体`Address` 包含2个参数: + `host`:节点所有者。 + `port`:节点的端口号。 + + message Address { + bytes host = 1; + int32 port = 2; + } + + + 消息体`Return`只含有一个参数: + `result`: 布尔表类型标志位。 + + message `Return` {
 + bool result = 1;
 + } + ++ 网络UDP消息结构。 + + `Endpoint`:网络中节点信息存储结构. + 消息体`Endpoint` 包含3个参数: + `address`:节点地址。 + `port`:端口号。 + `nodeId`: 节点ID信息。 + + message Endpoint { + bytes address = 1; + int32 port = 2; + bytes nodeId = 3; + } + + `PingMessage`:节点建立连接时所发送的消息。 + 消息体`PingMessage` 包含4个参数: + `from`:消息来自的节点。 + `to`: 消息发送的节点。 + `version`: 网络版本。 + `timestamp`:消息创建时的时间戳。 + + message PingMessage { + Endpoint from = 1; + Endpoint to = 2; + int32 version = 3; + int64 timestamp = 4; + } + + `PongMessage`:连接建立成功时的回复消息。 + 消息体`PongMessage` 包含3个参数: + `from`:消息来自的节点。 + `echo`: + `timestamp`:消息创建时的时间戳。 + + message PongMessage { + Endpoint from = 1; + int32 echo = 2; + int64 timestamp = 3; + } + + `FindNeighbours`:节点查询相邻节点时所发送的消息。 + 消息体`FindNeighbours` 包含3个参数: + `from`: 消息来自的节点。 + `targetId`: 目标节点的信息。 + `timestamp`: 消息创建时的时间戳。 + + message FindNeighbours { + Endpoint from = 1; + bytes targetId = 2; + int64 timestamp = 3; + } + + `Neighbour`:相邻接点回复消息。 + 消息体`Neighbours` 包含3个参数: + `from`: 消息来自的节点。 + `neighbours`: 相邻节点。 + `timestamp`: 消息创建时的时间戳。 + + message Neighbours { + Endpoint from = 1; + repeated Endpoint neighbours = 2; + int64 timestamp = 3; + } + +# 详细的协议见附属文件。详细协议随着程序的迭代随时都可能发生变化,请以最新的版本为准。 \ No newline at end of file diff --git a/English version of TRON Protocol document.md b/English version of TRON Protocol document.md new file mode 100644 index 00000000000..9e7b36f0bc9 --- /dev/null +++ b/English version of TRON Protocol document.md @@ -0,0 +1,736 @@ + +# Protobuf protocol + +## The protocol of TRON is defined by Google Protobuf and contains a range of layers, from account, block to transfer. + ++ There are 3 types of account—basic account, asset release account and contract account, and attributes included in each account are name, types, address, balance and related asset. ++ A basic account is able to apply to be a validation node, which has serval parameters, including extra attributes, public key, URL, voting statistics, history performance, etc. + + There are three different `Account types`: `Normal`, `AssetIssue`, `Contract`. + + enum AccountType {
 + Normal = 0;
 + AssetIssue = 1;
 + Contract = 2; + 
} + + An `Account` contains 7 parameters: + `account_name`: the name for this account – e.g. “_BillsAccount_”. + `type`: what type of this account is – e.g. _0_ stands for type `Normal`. + `balance`: balance of this account – e.g. _4213312_. + `votes`: received votes on this account – e.g. _{(“0x1b7w…9xj3”,323), (“0x8djq…j12m”,88),…,(“0x82nd…mx6i”,10001)}_. + `asset`: other assets expect TRX in this account – e.g. _{<“WishToken”,66666>,<”Dogie”,233>}_. + `latest_operation_time`: the latest operation time of this account. + + // Account
 + message Account {
 + message Vote {
 + bytes vote_address = 1;
 + int64 vote_count = 2;
 }
 + bytes accout_name = 1;
 + AccountType type = 2;
 + bytes address = 3;
 + int64 balance = 4;
 + repeated Vote votes = 5;
 + map asset = 6; + int64 latest_operation_time = 10;
 + } + + A `Witness` contains 8 parameters: + `address`: the address of this witness – e.g. “_0xu82h…7237_”. + `voteCount`: number of received votes on this witness – e.g. _234234_. + `pubKey`: the public key for this witness – e.g. “_0xu82h…7237_”. + `url`: the url for this witness – e.g. “_https://www.noonetrust.com_”. + `totalProduced`: the number of blocks this witness produced – e.g. _2434_. + `totalMissed`: the number of blocks this witness missed – e.g. _7_. + `latestBlockNum`: the latest height of block – e.g. _4522_. + `isjobs`: a bool flag. + + // Witness
 + message Witness{
 + bytes address = 1;
 + int64 voteCount = 2;
 + bytes pubKey = 3;
 + string url = 4;
 + int64 totalProduced = 5;
 + int64 totalMissed = 6;
 + int64 latestBlockNum = 7;
 + bool isJobs = 9; + } + ++ A block typically contains transaction data and a blockheader, which is a list of basic block information, including timestamp, signature, parent hash, root of Merkle tree and so on. + + A block contains `transactions` and a `block_header`. + `transactions`: transaction data of this block. + `block_header`: one part of a block. + + // block + 
message Block {
 + repeated Transaction transactions = 1;
 + BlockHeader block_header = 2;
 + } + + A `BlockHeader` contains `raw_data` and `witness_signature`. + `raw_data`: a `raw` message. + `witness_signature`: signature for this block header from witness node. + + A message `raw` contains 6 parameters: + `timestamp`: timestamp of this message – e.g. _14356325_. + `txTrieRoot`: the root of Merkle Tree in this block – e.g. “_7dacsa…3ed_.” + `parentHash`: the hash of last block – e.g. “_7dacsa…3ed_.” + `number`: the height of this block – e.g. _13534657_. + `witness_id`: the id of witness which packed this block – e.g. “_0xu82h…7237_”. + `witness_address`: the adresss of the witness packed this block – e.g. “_0xu82h…7237_”. + + message BlockHeader {
 + message raw {
 + int64 timestamp = 1;
 + bytes txTrieRoot = 2;
 + bytes parentHash = 3;
 + //bytes nonce = 5;
 + //bytes difficulty = 6;
 + uint64 number = 7;
 + uint64 witness_id = 8;
 + bytes witness_address = 9;
 + }
 + raw raw_data = 1;
 + bytes witness_signature = 2;
 + } + + message `ChainInventory` contains `BlockId` and `remain_num`. + `BlockId`: the identification of block. + `remain_num`:the remain number of blocks in the synchronizing process. + + A `BlockId` contains 2 parameters: + `hash`: the hash of block. + `number`: the hash and height of block. + + message ChainInventory { + message BlockId { + bytes hash = 1; + int64 number = 2; + } + repeated BlockId ids = 1; + int64 remain_num = 2; + } + ++ Transaction contracts mainly includes account create contract, account update contract transfer contract, transfer asset contract, vote asset contract, vote witness contract, witness creation contract, witness update contract, asset issue contract, participate asset issue contract and deploy contract. + + An `AccountCreateContract` contains 3 parameters: + `type`: What type this account is – e.g. _0_ stands for `Normal`. + `account_name`: the name for this account – e.g.”_Billsaccount_”. + `owner_address`: the address of contract owner – e.g. “_0xu82h…7237_”. + + message AccountCreateContract {
 + AccountType type = 1;
 + bytes account_name = 2;
 + bytes owner_address = 3;
 + } + + A `AccountUpdateContract` contains 2 paremeters: + `account_name`: the name for this account – e.g.”_Billsaccount_”. + `owner_address`: the address of contract owner – e.g. “_0xu82h…7237_”. + + message AccountUpdateContract { + bytes account_name = 1; + bytes owner_address = 2; + } + + A `TransferContract` contains 3 parameters: + `amount`: the amount of TRX – e.g. _12534_. + `to_address`: the receiver address – e.g. “_0xu82h…7237_”. + `owner_address`: the address of contract owner – e.g. “_0xu82h…7237_”. + + message TransferContract {
 + bytes owner_address = 1;
 + bytes to_address = 2;
 + int64 amount = 3; + } + + A `TransferAssetContract` contains 4 parameters: + `asset_name`: the name for asset – e.g.”_Billsaccount_”. + `to_address`: the receiver address – e.g. “_0xu82h…7237_”. + `owner_address`: the address of contract owner – e.g. “_0xu82h…7237_”. + `amount`: the amount of target asset - e.g._12353_. + + message TransferAssetContract {
 + bytes asset_name = 1;
 + bytes owner_address = 2;
 + bytes to_address = 3;
 + int64 amount = 4;
 + } + + A `VoteAssetContract` contains 4 parameters: + `vote_address`: the voted address of the asset. + `support`: is the votes supportive or not – e.g. _true_. + `owner_address`: the address of contract owner – e.g. “_0xu82h…7237_”. + `count`: the count number of votes- e.g. _2324234_. + + message VoteAssetContract {
 + bytes owner_address = 1;
 + repeated bytes vote_address = 2;
 + bool support = 3;
 + int32 count = 5;
 + } + + A `VoteWitnessContract` contains 4 parameters: + `vote_address`: the addresses of those who voted. + `support`: is the votes supportive or not - e.g. _true_. + `owner_address`: the address of contract owner – e.g. “_0xu82h…7237_”. + `count`: - e.g. the count number of vote – e.g. _32632_. + + message VoteWitnessContract {
 + bytes owner_address = 1;
 + repeated bytes vote_address = 2;
 + bool support = 3;
 + int32 count = 5; + 
} + + A `WitnessCreateContract` contains 3 parameters: + `private_key`: the private key of contract– e.g. “_0xu82h…7237_”. + `owner_address`: the address of contract owner – e.g. “_0xu82h…7237_”. + `url`: the url for the witness – e.g. “_https://www.noonetrust.com_”. + + message WitnessCreateContract {
 + bytes owner_address = 1;
 + bytes private_key = 2;
 + bytes url = 12;
 + } + + A `WitnessUpdateContract` contains 2 parameters: + `owner_address`: the address of contract owner – e.g. “_0xu82h…7237_”. + `update_url`: the url for the witness – e.g. “_https://www.noonetrust.com_”. + + message WitnessUpdateContract { + bytes owner_address = 1; + bytes update_url = 12; + } + + An `AssetIssueContract` contains 11 parameters: + `owner_address`: the address for contract owner – e.g. “_0xu82h…7237_”. + `name`: the name for this contract – e.g. “Billscontract”. + `total_supply`: the maximum supply of this asset – e.g. _1000000000_. + `trx_num`: the number of TRONIX – e.g._232241_. + `num`: number of corresponding asset. + `start_time`: the starting date of this contract – e.g._20170312_. + `end_time`: the expiring date of this contract – e.g. _20170512_. + `decay_ratio`: decay ratio. + `vote_score`: the vote score of this contract received – e.g. _12343_. + `description`: the description of this contract – e.g.”_trondada_”. + `url`: the url of this contract – e.g. “_https://www.noonetrust.com_”. + + message AssetIssueContract {
 + bytes owner_address = 1;
 + bytes name = 2;
 + int64 total_supply = 4;
 + int32 trx_num = 6;
 + int32 num = 8;
 + int64 start_time = 9;
 + int64 end_time = 10;
 + int32 decay_ratio = 15;
 + int32 vote_score = 16;
 + bytes description = 20;
 + bytes url = 21;
 + } + + A `ParticipateAssetIssueContract` contains 4 parameters: + `owner_address`: the address for contract owner – e.g. “_0xu82h…7237_”. + `to_address`: the receiver address – e.g. “_0xu82h…7237_”. + `asset_name`: the name of target asset. + `amount`: the amount of drops. + + message ParticipateAssetIssueContract { + bytes owner_address = 1; + bytes to_address = 2; + bytes asset_name = 3; + int64 amount = 4; + } + + A `DeployContract` contains 2 parameters: + `script`: the script of this contract. + `owner_address`: the address for contract owner – e.g. “_0xu82h…7237_”. + + message DeployContract {
 + bytes owner_address = 1;
 + bytes script = 2; + 
} t + ++ Each transaction contains several TXInputs, TXOutputs and other related qualities. +Input, transaction and head block all require signature. + + message `Transaction` contains `raw_data` and `signature`. + `raw_data`: message `raw`. + `signature`: signatures form all input nodes. + + `raw` contains 8 parameters: + `type`: the transaction type of `raw` message. + `vin`: input values. + `vout`: output values. + `expiration`: the expiration date of transaction – e.g._20170312_. + `data`: data. + `contract`: contracts in this transaction. + `scripts`:scripts in the transaction. + `timestamp`: timestamp of this raw data – e.g. _14356325_. + + message `Contract` contains `type` and `parameter`. + `type`: what type of the message contract. + `parameter`: It can be any form. + + There are 8 different of contract types: `AccountCreateContract`, `TransferContract`, `TransferAssetContract`, `VoteAssetContract`, `VoteWitnessContract`,`WitnessCreateContract`, `AssetIssueContract` and `DeployContract`. + `TransactionType` have two types: `UtxoType` and `ContractType`. + + message Transaction {
 + enum TranscationType {
 + UtxoType = 0;
 + ContractType = 1;
 + }
 + message Contract {
 + enum ContractType {
 + AccountCreateContract = 0;
 + TransferContract = 1;
 + TransferAssetContract = 2;
 + VoteAssetContract = 3;
 + VoteWitnessContract = 4;
 + WitnessCreateContract = 5;
 + AssetIssueContract = 6;
 + DeployContract = 7;
 + WitnessUpdateContract = 8; + ParticipateAssetIssueContract = 9 + }
 + ContractType type = 1;
 + google.protobuf.Any parameter = 2;
 + }
 + message raw {
 + TranscationType type = 2;
 + repeated TXInput vin = 5;
 + repeated TXOutput vout = 7;
 + int64 expiration = 8;
 + bytes data = 10;
 + repeated Contract contract = 11;
 + bytes scripts = 16;
 + int64 timestamp = 17; + }
 + raw raw_data = 1;
 + repeated bytes signature = 5; + 
} + + message `TXOutputs` contains `outputs`. + `outputs`: an array of `TXOutput`. + + message TXOutputs {
 + repeated TXOutput outputs = 1;
 + } + + message `TXOutput` contains `value` and `pubKeyHash`. + `value`: output value. + `pubKeyHash`: Hash of public key + + message TXOutput {
 + int64 value = 1;
 + bytes pubKeyHash = 2;
 + } + + message `TXInput` contains `raw_data` and `signature`. + `raw_data`: a message `raw`. + `signature`: signature for this `TXInput`. + + message `raw` contains `txID`, `vout` and `pubKey`. + `txID`: transaction ID. + `vout`: value of last output. + `pubKey`: public key. + + message TXInput {
 + message raw {
 + bytes txID = 1;
 + int64 vout = 2;
 + bytes pubKey = 3;
 + }
 + raw raw_data = 1;
 + bytes signature = 4; + 
} + + message `Result` contains `fee` and `ret`. + `ret`: the state of transaction. + `fee`: the fee for transaction. + + `code` is definition of `ret` and contains 2 types:`SUCCESS` and `FAILED`. + + message Result { + enum code { + SUCESS = 0; + FAILED = 1; + } + int64 fee = 1; + code ret = 2; + } + ++ Inventory is mainly used to inform peer nodes the list of items. + + `Inventory` contains `type` and `ids`. + `type`: what type this `Inventory` is. – e.g. _0_ stands for `TRX`. + `ids`: ID of things in this `Inventory`. + + Two `Inventory` types: `TRX` and `BLOCK`. + `TRX`: transaction. + `BLOCK`: block. + + // Inventory
 + message Inventory {
 + enum InventoryType {
 + TRX = 0;
 + BLOCK = 1;
 + }
 + InventoryType type = 1;
 + repeated bytes ids = 2;
 + } + + message `Items` contains 4 parameters: + `type`: type of items – e.g. _1_ stands for `TRX`. + `blocks`: blocks in `Items` if there is any. + `block_headers`: block headers if there is any. + `transactions`: transactions if there is any. + + `Items` have four types: `ERR`, `TRX`, `BLOCK` and `BLOCKHEADER`. + `ERR`: error. + `TRX`: transaction. + `BLOCK`: block. + `BLOCKHEADER`: block header. + + message Items {
 + enum ItemType {
 + ERR = 0;
 + TRX = 1;
 + BLOCK = 2;
 + BLOCKHEADER = 3;
 + }
 + ItemType type = 1;
 + repeated Block blocks = 2;
 + repeated BlockHeader + block_headers = 3;
 + repeated Transaction transactions = 4; + } + + `InventoryItems` contains `type` and `items`. + `type`: what type of item. + `items`: items in an `InventoryItems`. + + message InventoryItems {
 + int32 type = 1;
 + repeated bytes items = 2; + 
} + + message `BlockInventory` contains `type`. + `type`: what type of inventory. + + There are 3 types:`SYNC`, `ADVTISE`, `FETCH`. + + // Inventory + message BlockInventory { + enum Type { + SYNC = 0; + ADVTISE = 1; + FETCH = 2; + } + + message `BlockId` contains `ids` and `type`. + `ids`: the identification of block. + `type`: what type of the block. + + `ids` contains 2 paremeters: + `hash`: the hash of block. + `number`: the hash and height of block. + + message BlockId { + bytes hash = 1; + int64 number = 2; + } + repeated BlockId ids = 1; + Type type = 2; + } + + `ReasonCode`: the type of reason. + + `ReasonCode` contains 15 types of disconnect reasons: + `REQUESTED` + `TCP_ERROR` + `BAD_PROTOCOL` + `USELESS_PEER` + `TOO_MANY_PEERS` + `DUPLICATE_PEER` + `INCOMPATIBLE_PROTOCOL` + `NULL_IDENTITY` + `PEER_QUITING` + `UNEXPECTED_IDENTITY` + `LOCAL_IDENTITY` + `PING_TIMEOUT` + `USER_REASON` + `RESET` + `UNKNOWN` + + enum ReasonCode { + REQUESTED = 0; + TCP_ERROR = 1; + BAD_PROTOCOL = 2; + USELESS_PEER = 3; + TOO_MANY_PEERS = 4; + DUPLICATE_PEER = 5; + INCOMPATIBLE_PROTOCOL = 6; + NULL_IDENTITY = 7; + PEER_QUITING = 8; + UNEXPECTED_IDENTITY = 9; + LOCAL_IDENTITY = 10; + PING_TIMEOUT = 11; + USER_REASON = 12; + RESET = 16; + UNKNOWN = 255; + } + + message`DisconnectMessage` contains `reason`. + `DisconnectMessage`: the message when disconnection occurs. + `reason`: the reason for disconnecting. + + message`HelloMessage` contains 2 parameters: + `HelloMessage`: the message for building connection. + `from`: the nodes that request for building connection. + `version`: the version when connection is built. + + + ++ Wallet Service RPC and blockchain explorer + + `Wallet` service contains several RPCs. + __`GetBalance`__ : + Return balance of an `Account`. + __`CreateTransaction`__ : + Create a transaction by giving a `TransferContract`. A Transaction containing a transaction creation will be returned. + __`BroadcastTransaction`__ : + Broadcast a `Transaction`. A `Return` will be returned indicating if broadcast is success of not. + __`CreateAccount`__ : + Create an account by giving a `AccountCreateContract`. + __`CreatAssetIssue`__ : + Issue an asset by giving a `AssetIssueContract`. + __`ListAccounts`__: + Check out the list of accounts by giving a `ListAccounts`. + __`UpdateAccount`__: + Issue an asset by giving a `UpdateAccountContract`. + __`VoteWitnessAccount`__: + Issue an asset by giving a `VoteWitnessContract`. + __`WitnessList`__: + Check out the list of witnesses by giving a `WitnessList`. + __`UpdateWitness`__: + Issue an asset by giving a `WitnessUpdateContract`. + __`CreateWitness`__: + Issue an asset by giving a `WitnessCreateContract`. + __`TransferAsset`__: + Issue an asset by giving a `TransferAssetContract`. + __`ParticipateAssetIssue`__: + Issue an asset by giving a `ParticipateAssetIssueContract`. + __`ListNodes`__: + Check out the list of nodes by giving a `ListNodes`. + __`GetAssetIssueList`__: + Get the list of issue asset by giving a `GetAssetIssueList`. + __`GetAssetIssueByAccount`__: + Get issue asset by giving a `Account`. + __`GetAssetIssueByName`__: + Get issue asset by giving a`Name`. + __`GetNowBlock`__: + Get block. + __`GetBlockByNum`__: + Get block by block number. + __`TotalTransaction`__: + Check out the total transaction. + + service Wallet { + + rpc GetAccount (Account) returns (Account) { + + }; + + rpc CreateTransaction (TransferContract) returns (Transaction) { + + }; + + rpc BroadcastTransaction (Transaction) returns (Return) { + + }; + + rpc ListAccounts (EmptyMessage) returns (AccountList) { + + }; + + rpc UpdateAccount (AccountUpdateContract) returns (Transaction) { + + }; + + rpc CreateAccount (AccountCreateContract) returns (Transaction) { + + }; + + rpc VoteWitnessAccount (VoteWitnessContract) returns (Transaction) { + + }; + + rpc CreateAssetIssue (AssetIssueContract) returns (Transaction) { + + }; + + rpc ListWitnesses (EmptyMessage) returns (WitnessList) { + + }; + + rpc UpdateWitness (WitnessUpdateContract) returns (Transaction) { + + }; + + rpc CreateWitness (WitnessCreateContract) returns (Transaction) { + + }; + + rpc TransferAsset (TransferAssetContract) returns (Transaction) { + + } + + rpc ParticipateAssetIssue (ParticipateAssetIssueContract) returns (Transaction) { + + } + + rpc ListNodes (EmptyMessage) returns (NodeList) { + + } + rpc GetAssetIssueList (EmptyMessage) returns (AssetIssueList) { + + } + rpc GetAssetIssueByAccount (Account) returns (AssetIssueList) { + + } + rpc GetAssetIssueByName (BytesMessage) returns (AssetIssueContract) { + + } + rpc GetNowBlock (EmptyMessage) returns (Block) { + + } + rpc GetBlockByNum (NumberMessage) returns (Block) { + + } + rpc TotalTransaction (EmptyMessage) returns (NumberMessage) { + + } + }; + + `AccountList`: the list of acounts in the blockchain explorer. + message `AccountList` contains one parameter: + `account`: + + message AccountList { + repeated Account accounts = 1; + } + + `WitnessList`: the list of witnesses in the blockchain explorer. + message `WitnessList` contains one parameter: + `witnesses`: + + message WitnessList { + repeated Witness witnesses = 1; + } + + `AssetIssueList`: the list of issue asset in the blockchain explorer. + message `AssetIssueList` contains one parameter: + `assetIssue`: + + message AssetIssueList { + repeated AssetIssueContract assetIssue = 1; + } + + `NodeList`: the list of nodes in the node distribution map. + message `NodeList` contains one parameter: + `nodes`: + + message NodeList { + repeated Node nodes = 1; + } + + `Address`: the address of nodes. + message`Address` contains 2 parameters: + `host`: the host of nodes. + `port`: the port number of nodes. + + message Address { + bytes host = 1; + int32 port = 2; + } + + message `Return` has only one parameter: + `result`: a bool flag. + + message `Return` {
 + bool result = 1; + 
} + ++ The message structure of UDP. + + `Endpoint`: the storage structure of nodes' information. + message`Endpoint` contains 3 parameters: + `address`: the address of nodes. + `port`: the port number. + `nodeId`:the ID of nodes. + + + message Endpoint { + bytes address = 1; + int32 port = 2; + bytes nodeId = 3; + } + + `PingMessage`: the message sent from one node to another in the connecting process. + message`PingMessage` contains 4 parameters: + `from`: which node does the message send from. + `to`: which node will the message send to. + `version`: the version of the Internet. + `timestamp`: the timestamp of message. + + message PingMessage { + Endpoint from = 1; + Endpoint to = 2; + int32 version = 3; + int64 timestamp = 4; + } + + `PongMessage`: the message implies that nodes are connected. + message`PongMessage` contains 3 parameters: + `from`: which node does the message send from. + `echo`: + `timestamp`: the timestamp of message. + + message PongMessage { + Endpoint from = 1; + int32 echo = 2; + int64 timestamp = 3; + } + + `FindNeighbours`: the message sent from one node to find another one. + message`FindNeighbours` contains 3 parameters: + `from`: which node does the message send from. + `targetId`: the ID of targeted node. + `timestamp`: the timestamp of message. + + message FindNeighbours { + Endpoint from = 1; + bytes targetId = 2; + int64 timestamp = 3; + } + + `FindNeighbour`: the message replied by the neighbour node. + message`Neighbours` contains 3 parameters: + `from`: which node does the message send from. + `neighbours`: the neighbour node. + `timestamp`: the timestamp of message. + + message Neighbours { + Endpoint from = 1; + repeated Endpoint neighbours = 2; + int64 timestamp = 3; + } + + + +# Please check detailed protocol document that may change with the iteration of the program at any time. Please refer to the latest version. diff --git a/README.md b/README.md index c04fbf6968a..98c21fe1ad8 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,6 @@ the protocol of tron including api and message. -java-tron and wallet-cli +java-tron, wallet-cli and grpc-gateway git subtree pull --prefix src/main/protos/ protocol master diff --git a/api/api.proto b/api/api.proto index 3b47771b2c3..66aa6d53948 100644 --- a/api/api.proto +++ b/api/api.proto @@ -3,70 +3,175 @@ package protocol; import "core/Tron.proto"; import "core/Contract.proto"; +import "google/api/annotations.proto"; + option java_package = "org.tron.api"; //Specify the name of the package that generated the Java file option java_outer_classname = "GrpcAPI"; //Specify the class name of the generated Java file -option go_package = "github.com/tronprotocol/go-client-api/api"; +option go_package = "github.com/tronprotocol/grpc-gateway/api"; service Wallet { rpc GetAccount (Account) returns (Account) { + option (google.api.http) = { + post: "/wallet/getaccount" + body: "*" + }; }; rpc CreateTransaction (TransferContract) returns (Transaction) { - + option (google.api.http) = { + post: "/wallet/createtransaction" + body: "*" + }; }; rpc BroadcastTransaction (Transaction) returns (Return) { - + option (google.api.http) = { + post: "/wallet/broadcasttransaction" + body: "*" + }; }; rpc ListAccounts (EmptyMessage) returns (AccountList) { + option (google.api.http) = { + post: "/wallet/listaccount" + body: "*" + }; }; rpc UpdateAccount (AccountUpdateContract) returns (Transaction) { - + option (google.api.http) = { + post: "/wallet/updateaccount" + body: "*" + }; }; rpc CreateAccount (AccountCreateContract) returns (Transaction) { - + option (google.api.http) = { + post: "/wallet/createaccount" + body: "*" + }; }; rpc VoteWitnessAccount (VoteWitnessContract) returns (Transaction) { - + option (google.api.http) = { + post: "/wallet/votewitnessaccount" + body: "*" + }; }; rpc CreateAssetIssue (AssetIssueContract) returns (Transaction) { - + option (google.api.http) = { + post: "/wallet/createassetissue" + body: "*" + }; }; rpc ListWitnesses (EmptyMessage) returns (WitnessList) { - + option (google.api.http) = { + post: "/wallet/listwitnesses" + body: "*" + }; }; rpc UpdateWitness (WitnessUpdateContract) returns (Transaction) { - + option (google.api.http) = { + post: "/wallet/updatewitness" + body: "*" + }; }; rpc CreateWitness (WitnessCreateContract) returns (Transaction) { - + option (google.api.http) = { + post: "/wallet/createwitness" + body: "*" + }; }; rpc TransferAsset (TransferAssetContract) returns (Transaction) { - + option (google.api.http) = { + post: "/wallet/transferasset" + body: "*" + }; } rpc ParticipateAssetIssue (ParticipateAssetIssueContract) returns (Transaction) { + option (google.api.http) = { + post: "/wallet/participateassetissue" + body: "*" + }; + } + rpc ListNodes (EmptyMessage) returns (NodeList) { + option (google.api.http) = { + post: "/wallet/listnodes" + body: "*" + }; } + rpc GetAssetIssueList (EmptyMessage) returns (AssetIssueList) { + option (google.api.http) = { + post: "/wallet/getassetissuelist" + body: "*" + }; + } + rpc GetAssetIssueByAccount (Account) returns (AssetIssueList) { + option (google.api.http) = { + post: "/wallet/getassetissuebyaccount" + body: "*" + }; + } + rpc GetAssetIssueByName (BytesMessage) returns (AssetIssueContract) { + option (google.api.http) = { + post: "/wallet/getassetissuebyname" + body: "*" + }; + } + rpc GetNowBlock (EmptyMessage) returns (Block) { + option (google.api.http) = { + post: "/wallet/getnowblock" + body: "*" + }; + } + rpc GetBlockByNum (NumberMessage) returns (Block) { + option (google.api.http) = { + post: "/wallet/getblockbynum" + body: "*" + }; + } + rpc TotalTransaction (EmptyMessage) returns (NumberMessage) { + option (google.api.http) = { + post: "/wallet/totaltransaction" + body: "*" + }; + } +}; + + +service WalletSolidity { + + rpc GetAccount (Account) returns (Account) { + + }; + + rpc ListAccounts (EmptyMessage) returns (AccountList) { + + }; + + rpc ListWitnesses (EmptyMessage) returns (WitnessList) { + + }; rpc ListNodes (EmptyMessage) returns (NodeList) { } rpc GetAssetIssueList (EmptyMessage) returns (AssetIssueList) { + } + rpc GetAssetIssueListByTimestamp (NumberMessage) returns (AssetIssueList) { + } rpc GetAssetIssueByAccount (Account) returns (AssetIssueList) { @@ -80,8 +185,21 @@ service Wallet { rpc GetBlockByNum (NumberMessage) returns (Block) { } + //get transaction rpc TotalTransaction (EmptyMessage) returns (NumberMessage) { + } + rpc getTransactionById (BytesMessage) returns (Transaction) { + + } + rpc getTransactionsByTimestamp (TimeMessage) returns (TransactionList) { + + } + rpc getTransactionsFromThis (Account) returns (TransactionList) { + + } + rpc getTransactionsToThis (Account) returns (NumberMessage) { + } }; @@ -128,6 +246,12 @@ message WitnessList { message AssetIssueList { repeated AssetIssueContract assetIssue = 1; } +message BlockList { + repeated Block block = 1; +} +message TransactionList { + repeated Transaction transaction = 1; +} // Gossip node list message NodeList { @@ -152,4 +276,8 @@ message NumberMessage { } message BytesMessage { bytes value = 1; +} +message TimeMessage { + int64 beginInMilliseconds = 1; + int64 endInMilliseconds = 2; } \ No newline at end of file diff --git a/core/Contract.proto b/core/Contract.proto index a00c82eec58..37a210ecc58 100644 --- a/core/Contract.proto +++ b/core/Contract.proto @@ -19,7 +19,7 @@ package protocol; option java_package = "org.tron.protos"; //Specify the name of the package that generated the Java file option java_outer_classname = "Contract"; //Specify the class name of the generated Java file -option go_package = "github.com/tronprotocol/go-client-api/core"; +option go_package = "github.com/tronprotocol/grpc-gateway/core"; import "core/Tron.proto"; diff --git a/core/Discover.proto b/core/Discover.proto index ac45a30364a..cba982a18b1 100644 --- a/core/Discover.proto +++ b/core/Discover.proto @@ -5,7 +5,7 @@ package protocol; option java_package = "org.tron.protos"; //Specify the name of the package that generated the Java file option java_outer_classname = "Discover"; //Specify the class name of the generated Java file -option go_package = "github.com/tronprotocol/go-client-api/core"; +option go_package = "github.com/tronprotocol/grpc-gateway/core"; message Endpoint { bytes address = 1; diff --git a/core/Tron.proto b/core/Tron.proto index b5914a3d33f..d9800a4f710 100644 --- a/core/Tron.proto +++ b/core/Tron.proto @@ -8,8 +8,7 @@ package protocol; option java_package = "org.tron.protos"; //Specify the name of the package that generated the Java file option java_outer_classname = "Protocol"; //Specify the class name of the generated Java file -option go_package = "github.com/tronprotocol/go-client-api/core"; - +option go_package = "github.com/tronprotocol/grpc-gateway/core"; enum AccountType { Normal = 0; @@ -188,21 +187,21 @@ message DynamicProperties { } enum ReasonCode { - REQUESTED = 0; - TCP_ERROR = 1; - BAD_PROTOCOL = 2; - USELESS_PEER = 3; - TOO_MANY_PEERS = 4; - DUPLICATE_PEER = 5; - INCOMPATIBLE_PROTOCOL = 6; - NULL_IDENTITY = 7; - PEER_QUITING = 8; - UNEXPECTED_IDENTITY = 9; - LOCAL_IDENTITY = 10; - PING_TIMEOUT = 11; - USER_REASON = 12; - RESET = 16; - UNKNOWN = 255; + REQUESTED = 0x00; + TCP_ERROR = 0x01; + BAD_PROTOCOL = 0x02; + USELESS_PEER = 0x03; + TOO_MANY_PEERS = 0x04; + DUPLICATE_PEER = 0x05; + INCOMPATIBLE_PROTOCOL = 0x06; + NULL_IDENTITY = 0x07; + PEER_QUITING = 0x08; + UNEXPECTED_IDENTITY = 0x09; + LOCAL_IDENTITY = 0x0A; + PING_TIMEOUT = 0x0B; + USER_REASON = 0x10; + RESET = 0x11; + UNKNOWN = 0xFF; } message DisconnectMessage { diff --git a/core/TronInventoryItems.proto b/core/TronInventoryItems.proto index f630ffad598..a82d2de4552 100644 --- a/core/TronInventoryItems.proto +++ b/core/TronInventoryItems.proto @@ -4,7 +4,7 @@ package protocol; option java_package = "org.tron.protos"; //Specify the name of the package that generated the Java file option java_outer_classname = "TronInventoryItems"; //Specify the class name of the generated Java file -option go_package = "github.com/tronprotocol/go-client-api/core"; +option go_package = "github.com/tronprotocol/grpc-gateway/core"; message InventoryItems { int32 type = 1; diff --git a/install-googleapis.sh b/install-googleapis.sh new file mode 100755 index 00000000000..0d44f6108d1 --- /dev/null +++ b/install-googleapis.sh @@ -0,0 +1,14 @@ +#!/bin/sh +set -e + +go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway +go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger +go get -u github.com/golang/protobuf/protoc-gen-go + +wget http://central.maven.org/maven2/com/google/api/grpc/googleapis-common-protos/0.0.3/googleapis-common-protos-0.0.3.jar +jar xvf googleapis-common-protos-0.0.3.jar +cp -r google/ $HOME/protobuf/include/ +ls -l + + + diff --git a/install-protobuf.sh b/install-protobuf.sh index 29e5536ee6d..b3a8cb5cbb2 100755 --- a/install-protobuf.sh +++ b/install-protobuf.sh @@ -2,8 +2,8 @@ set -e # check to see if protobuf folder is empty if [ ! -d "$HOME/protobuf/lib" ]; then - wget https://github.com/google/protobuf/releases/download/v3.5.1/protobuf-java-3.5.1.tar.gz - tar -xzvf protobuf-java-3.5.1.tar.gz + wget https://github.com/google/protobuf/releases/download/v3.5.1/protobuf-all-3.5.1.tar.gz + tar -xzvf protobuf-all-3.5.1.tar.gz cd protobuf-3.5.1 && ./configure --prefix=$HOME/protobuf && make && make install else echo "Using cached directory."