From 6910ef4d513f298769f83e782146a219cd73bee9 Mon Sep 17 00:00:00 2001 From: sasaxie Date: Mon, 12 Mar 2018 21:15:55 +0800 Subject: [PATCH 01/19] fix: add Account setter() validator --- .gitignore | 4 + .travis.yml | 19 ++++ LICENSE | 165 +++++++++++++++++++++++++++++++++ README.md | 8 ++ api/api.proto | 81 +++++++++++++++++ core/Contract.proto | 85 +++++++++++++++++ core/Tron.proto | 166 ++++++++++++++++++++++++++++++++++ core/TronInventoryItems.proto | 11 +++ install-protobuf.sh | 10 ++ 9 files changed, 549 insertions(+) create mode 100644 .gitignore create mode 100644 .travis.yml create mode 100644 LICENSE create mode 100644 README.md create mode 100644 api/api.proto create mode 100644 core/Contract.proto create mode 100644 core/Tron.proto create mode 100644 core/TronInventoryItems.proto create mode 100755 install-protobuf.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000000..1554c5edd92 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +# IDEA +.idea +*iml +.DS_Store diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000000..3f1e4c4709b --- /dev/null +++ b/.travis.yml @@ -0,0 +1,19 @@ +language: ruby + +cache: + directories: + - $HOME/protobuf + +sudo: false + +before_install: + - bash install-protobuf.sh + +# check what has been installed by listing contents of protobuf folder +before_script: + - ls -R $HOME/protobuf + +# let's use protobuf +script: + - $HOME/protobuf/bin/protoc --java_out=./ ./core/*.proto ./api/*.proto + - ls -l \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000000..65c5ca88a67 --- /dev/null +++ b/LICENSE @@ -0,0 +1,165 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. diff --git a/README.md b/README.md new file mode 100644 index 00000000000..c04fbf6968a --- /dev/null +++ b/README.md @@ -0,0 +1,8 @@ +# protocol [![Build Status](https://travis-ci.org/tronprotocol/protocol.svg?branch=master)](https://travis-ci.org/tronprotocol/protocol) + + +the protocol of tron including api and message. + +java-tron and wallet-cli + +git subtree pull --prefix src/main/protos/ protocol master diff --git a/api/api.proto b/api/api.proto new file mode 100644 index 00000000000..77e4be1938c --- /dev/null +++ b/api/api.proto @@ -0,0 +1,81 @@ +syntax = "proto3"; +package protocol; + +import "core/Tron.proto"; +import "core/Contract.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 + +service Wallet { + + rpc GetBalance (Account) returns (Account) { + + }; + rpc CreateTransaction (TransferContract) returns (Transaction) { + + }; + + rpc BroadcastTransaction (Transaction) returns (Return) { + + }; + + rpc ListAccounts (EmptyMessage) returns (AccountList) { + + }; + + rpc CreateAccount (AccountCreateContract) returns (Transaction) { + + }; + + rpc VoteWitnessAccount (VoteWitnessContract) returns (Transaction) { + + }; + + rpc CreateAssetIssue (AssetIssueContract) returns (Transaction) { + + }; + + rpc ListWitnesses (EmptyMessage) returns (WitnessList) { + + }; + + rpc CreateWitness (WitnessCreateContract) returns (Transaction) { + + }; + + rpc ListNodes (EmptyMessage) returns (NodeList) { + + } +}; + +message Return { + bool result = 1; +} + +message AccountList { + repeated Account accounts = 1; +} + +message WitnessList { + repeated Witness witnesses = 1; +} + +// Gossip node list +message NodeList { + repeated Node nodes = 1; +} + +// Gossip node +message Node { + Address address = 1; +} + +// Gossip node address +message Address { + bytes host = 1; + int32 port = 2; +} + +message EmptyMessage { +} diff --git a/core/Contract.proto b/core/Contract.proto new file mode 100644 index 00000000000..8b3fff1167f --- /dev/null +++ b/core/Contract.proto @@ -0,0 +1,85 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +syntax = "proto3"; + +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 + +import "core/Tron.proto"; + +message AccountCreateContract { + AccountType type = 1; + bytes account_name = 2; + bytes owner_address = 3; +} + +message TransferContract { + bytes owner_address = 1; + bytes to_address = 2; + int64 amount = 3; +} + +message TransferAssertContract { + bytes assert_name = 1; + bytes owner_address = 2; + bytes to_address = 3; + int64 amount = 4; +} + + +message VoteAssetContract { + bytes owner_address = 1; + repeated bytes vote_address = 2; + bool support = 3; + int32 count = 5; +} + +message VoteWitnessContract { + message Vote { + bytes vote_address = 1; + int64 vote_count = 2; + } + bytes owner_address = 1; + repeated Vote votes = 2; + bool support = 3; +} + +message WitnessCreateContract { + bytes owner_address = 1; + bytes url = 12; +} + +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; +} + +message DeployContract { + bytes owner_address = 1; + bytes script = 2; +} + diff --git a/core/Tron.proto b/core/Tron.proto new file mode 100644 index 00000000000..4b5d5446c7e --- /dev/null +++ b/core/Tron.proto @@ -0,0 +1,166 @@ +syntax = "proto3"; + +import "google/protobuf/any.proto"; + +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 + + +enum AccountType { + Normal = 0; + AssetIssue = 1; + Contract = 2; +} + +// Account +message Account { + message Vote { + bytes vote_address = 1; + int64 vote_count = 2; + } + bytes account_name = 1; + AccountType type = 2; + bytes address = 3; + int64 balance = 4; + repeated Vote votes = 5; + map asset = 6; + +} + +// Witness +message Witness { + bytes address = 1; + int64 voteCount = 2; + bytes pubKey = 3; + string url = 4; + int64 totalProduced = 5; + int64 totalMissed = 6; + int64 latestBlockNum = 7; + int64 latestSlotNum = 8; + bool isJobs = 9; +} + +// Transcation + +message TXOutput { + int64 value = 1; + bytes pubKeyHash = 2; +} + +message TXInput { + message raw { + bytes txID = 1; + int64 vout = 2; + bytes pubKey = 3; + } + raw raw_data = 1; + bytes signature = 4; +} + +message TXOutputs { + repeated TXOutput outputs = 1; +} + +message Transaction { + enum TransactionType { + UtxoType = 0; + ContractType = 1; + } + message Contract { + enum ContractType { + AccountCreateContract = 0; + TransferContract = 1; + TransferAssertContract = 2; + VoteAssetContract = 3; + VoteWitnessContract = 4; + WitnessCreateContract = 5; + AssetIssueContract = 6; + DeployContract = 7; + } + ContractType type = 1; + google.protobuf.Any parameter = 2; + } + message raw { + TransactionType type = 2; + repeated TXInput vin = 5; + repeated TXOutput vout = 7; + int64 expiration = 8; + bytes data = 10; + repeated Contract contract = 11; + bytes scripts = 16; + } + raw raw_data = 1; + repeated bytes signature = 5; +} + +message BlockHeader { + message raw { + int64 timestamp = 1; + bytes txTrieRoot = 2; + bytes parentHash = 3; + //bytes nonce = 5; + //bytes difficulty = 6; + int64 number = 7; + int64 witness_id = 8; + bytes witness_address = 9; + } + raw raw_data = 1; + bytes witness_signature = 2; +} + +// block +message Block { + repeated Transaction transactions = 1; + BlockHeader block_header = 2; +} + +message ChainInventory { + message BlockId { + bytes hash = 1; + int64 number = 2; + } + repeated BlockId ids = 1; + int64 remain_num = 2; +} + +// Inventory +message BlockInventory { + enum Type { + SYNC = 0; + ADVTISE = 1; + FETCH = 2; + } + + message BlockId { + bytes hash = 1; + int64 number = 2; + } + repeated BlockId ids = 1; + Type type = 2; +} + +message Inventory { + enum InventoryType { + TRX = 0; + BLOCK = 1; + } + InventoryType type = 1; + repeated bytes ids = 2; +} + +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; +} diff --git a/core/TronInventoryItems.proto b/core/TronInventoryItems.proto new file mode 100644 index 00000000000..fb16f1d5431 --- /dev/null +++ b/core/TronInventoryItems.proto @@ -0,0 +1,11 @@ +syntax = "proto3"; + +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 + +message InventoryItems { + int32 type = 1; + repeated bytes items = 2; +} \ No newline at end of file diff --git a/install-protobuf.sh b/install-protobuf.sh new file mode 100755 index 00000000000..29e5536ee6d --- /dev/null +++ b/install-protobuf.sh @@ -0,0 +1,10 @@ +#!/bin/sh +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 + cd protobuf-3.5.1 && ./configure --prefix=$HOME/protobuf && make && make install +else + echo "Using cached directory." +fi From bb3a5787144ab455f70576971fc07588a03c9982 Mon Sep 17 00:00:00 2001 From: Matt Yue Date: Wed, 14 Mar 2018 18:41:43 +0800 Subject: [PATCH 02/19] improve code readability --- .gitignore | 4 + .travis.yml | 19 ++++ LICENSE | 165 +++++++++++++++++++++++++++++++ README.md | 8 ++ api/api.proto | 81 ++++++++++++++++ core/Contract.proto | 85 ++++++++++++++++ core/Tron.proto | 178 ++++++++++++++++++++++++++++++++++ core/TronInventoryItems.proto | 11 +++ install-protobuf.sh | 10 ++ 9 files changed, 561 insertions(+) create mode 100644 .gitignore create mode 100644 .travis.yml create mode 100644 LICENSE create mode 100644 README.md create mode 100644 api/api.proto create mode 100644 core/Contract.proto create mode 100644 core/Tron.proto create mode 100644 core/TronInventoryItems.proto create mode 100755 install-protobuf.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000000..1554c5edd92 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +# IDEA +.idea +*iml +.DS_Store diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000000..3f1e4c4709b --- /dev/null +++ b/.travis.yml @@ -0,0 +1,19 @@ +language: ruby + +cache: + directories: + - $HOME/protobuf + +sudo: false + +before_install: + - bash install-protobuf.sh + +# check what has been installed by listing contents of protobuf folder +before_script: + - ls -R $HOME/protobuf + +# let's use protobuf +script: + - $HOME/protobuf/bin/protoc --java_out=./ ./core/*.proto ./api/*.proto + - ls -l \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000000..65c5ca88a67 --- /dev/null +++ b/LICENSE @@ -0,0 +1,165 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. diff --git a/README.md b/README.md new file mode 100644 index 00000000000..c04fbf6968a --- /dev/null +++ b/README.md @@ -0,0 +1,8 @@ +# protocol [![Build Status](https://travis-ci.org/tronprotocol/protocol.svg?branch=master)](https://travis-ci.org/tronprotocol/protocol) + + +the protocol of tron including api and message. + +java-tron and wallet-cli + +git subtree pull --prefix src/main/protos/ protocol master diff --git a/api/api.proto b/api/api.proto new file mode 100644 index 00000000000..77e4be1938c --- /dev/null +++ b/api/api.proto @@ -0,0 +1,81 @@ +syntax = "proto3"; +package protocol; + +import "core/Tron.proto"; +import "core/Contract.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 + +service Wallet { + + rpc GetBalance (Account) returns (Account) { + + }; + rpc CreateTransaction (TransferContract) returns (Transaction) { + + }; + + rpc BroadcastTransaction (Transaction) returns (Return) { + + }; + + rpc ListAccounts (EmptyMessage) returns (AccountList) { + + }; + + rpc CreateAccount (AccountCreateContract) returns (Transaction) { + + }; + + rpc VoteWitnessAccount (VoteWitnessContract) returns (Transaction) { + + }; + + rpc CreateAssetIssue (AssetIssueContract) returns (Transaction) { + + }; + + rpc ListWitnesses (EmptyMessage) returns (WitnessList) { + + }; + + rpc CreateWitness (WitnessCreateContract) returns (Transaction) { + + }; + + rpc ListNodes (EmptyMessage) returns (NodeList) { + + } +}; + +message Return { + bool result = 1; +} + +message AccountList { + repeated Account accounts = 1; +} + +message WitnessList { + repeated Witness witnesses = 1; +} + +// Gossip node list +message NodeList { + repeated Node nodes = 1; +} + +// Gossip node +message Node { + Address address = 1; +} + +// Gossip node address +message Address { + bytes host = 1; + int32 port = 2; +} + +message EmptyMessage { +} diff --git a/core/Contract.proto b/core/Contract.proto new file mode 100644 index 00000000000..8b3fff1167f --- /dev/null +++ b/core/Contract.proto @@ -0,0 +1,85 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +syntax = "proto3"; + +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 + +import "core/Tron.proto"; + +message AccountCreateContract { + AccountType type = 1; + bytes account_name = 2; + bytes owner_address = 3; +} + +message TransferContract { + bytes owner_address = 1; + bytes to_address = 2; + int64 amount = 3; +} + +message TransferAssertContract { + bytes assert_name = 1; + bytes owner_address = 2; + bytes to_address = 3; + int64 amount = 4; +} + + +message VoteAssetContract { + bytes owner_address = 1; + repeated bytes vote_address = 2; + bool support = 3; + int32 count = 5; +} + +message VoteWitnessContract { + message Vote { + bytes vote_address = 1; + int64 vote_count = 2; + } + bytes owner_address = 1; + repeated Vote votes = 2; + bool support = 3; +} + +message WitnessCreateContract { + bytes owner_address = 1; + bytes url = 12; +} + +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; +} + +message DeployContract { + bytes owner_address = 1; + bytes script = 2; +} + diff --git a/core/Tron.proto b/core/Tron.proto new file mode 100644 index 00000000000..a5b3698489c --- /dev/null +++ b/core/Tron.proto @@ -0,0 +1,178 @@ +syntax = "proto3"; + +import "google/protobuf/any.proto"; + +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 + + +enum AccountType { + Normal = 0; + AssetIssue = 1; + Contract = 2; +} + +// Account +message Account { + message Vote { + bytes vote_address = 1; + int64 vote_count = 2; + } + bytes account_name = 1; + AccountType type = 2; + bytes address = 3; + int64 balance = 4; + repeated Vote votes = 5; + map asset = 6; + +} + +// Witness +message Witness { + bytes address = 1; + int64 voteCount = 2; + bytes pubKey = 3; + string url = 4; + int64 totalProduced = 5; + int64 totalMissed = 6; + int64 latestBlockNum = 7; + int64 latestSlotNum = 8; + bool isJobs = 9; +} + +// Transcation + +message TXOutput { + int64 value = 1; + bytes pubKeyHash = 2; +} + +message TXInput { + message raw { + bytes txID = 1; + int64 vout = 2; + bytes pubKey = 3; + } + raw raw_data = 1; + bytes signature = 4; +} + +message TXOutputs { + repeated TXOutput outputs = 1; +} + +message Transaction { + enum TransactionType { + UtxoType = 0; + ContractType = 1; + } + message Contract { + enum ContractType { + AccountCreateContract = 0; + TransferContract = 1; + TransferAssertContract = 2; + VoteAssetContract = 3; + VoteWitnessContract = 4; + WitnessCreateContract = 5; + AssetIssueContract = 6; + DeployContract = 7; + } + ContractType type = 1; + google.protobuf.Any parameter = 2; + } + + message Result { + enum code { + SUCESS = 0; + FAILED = 1; + } + int64 fee = 1; + code ret = 2; + } + + message raw { + TransactionType type = 2; + repeated TXInput vin = 5; + repeated TXOutput vout = 7; + int64 expiration = 8; + bytes data = 10; + repeated Contract contract = 11; + bytes scripts = 16; + } + + raw raw_data = 1; + repeated bytes signature = 2; + repeated Result ret = 5; +} + +message BlockHeader { + message raw { + int64 timestamp = 1; + bytes txTrieRoot = 2; + bytes parentHash = 3; + //bytes nonce = 5; + //bytes difficulty = 6; + int64 number = 7; + int64 witness_id = 8; + bytes witness_address = 9; + } + raw raw_data = 1; + bytes witness_signature = 2; +} + +// block +message Block { + repeated Transaction transactions = 1; + BlockHeader block_header = 2; +} + +message ChainInventory { + message BlockId { + bytes hash = 1; + int64 number = 2; + } + repeated BlockId ids = 1; + int64 remain_num = 2; +} + +// Inventory +message BlockInventory { + enum Type { + SYNC = 0; + ADVTISE = 1; + FETCH = 2; + } + + message BlockId { + bytes hash = 1; + int64 number = 2; + } + repeated BlockId ids = 1; + Type type = 2; +} + +message Inventory { + enum InventoryType { + TRX = 0; + BLOCK = 1; + } + InventoryType type = 1; + repeated bytes ids = 2; +} + +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; +} diff --git a/core/TronInventoryItems.proto b/core/TronInventoryItems.proto new file mode 100644 index 00000000000..fb16f1d5431 --- /dev/null +++ b/core/TronInventoryItems.proto @@ -0,0 +1,11 @@ +syntax = "proto3"; + +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 + +message InventoryItems { + int32 type = 1; + repeated bytes items = 2; +} \ No newline at end of file diff --git a/install-protobuf.sh b/install-protobuf.sh new file mode 100755 index 00000000000..29e5536ee6d --- /dev/null +++ b/install-protobuf.sh @@ -0,0 +1,10 @@ +#!/bin/sh +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 + cd protobuf-3.5.1 && ./configure --prefix=$HOME/protobuf && make && make install +else + echo "Using cached directory." +fi From a58bf8eaec25d18afd4ce29c18aee270e02c1b29 Mon Sep 17 00:00:00 2001 From: sasaxie Date: Wed, 14 Mar 2018 18:42:59 +0800 Subject: [PATCH 03/19] Merge branch 'develop' into junit/config --- core/Tron.proto | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/core/Tron.proto b/core/Tron.proto index 4b5d5446c7e..a5b3698489c 100644 --- a/core/Tron.proto +++ b/core/Tron.proto @@ -83,6 +83,16 @@ message Transaction { ContractType type = 1; google.protobuf.Any parameter = 2; } + + message Result { + enum code { + SUCESS = 0; + FAILED = 1; + } + int64 fee = 1; + code ret = 2; + } + message raw { TransactionType type = 2; repeated TXInput vin = 5; @@ -92,8 +102,10 @@ message Transaction { repeated Contract contract = 11; bytes scripts = 16; } + raw raw_data = 1; - repeated bytes signature = 5; + repeated bytes signature = 2; + repeated Result ret = 5; } message BlockHeader { From 164d8bde8a767ea4959d5be3371e9f777f54a894 Mon Sep 17 00:00:00 2001 From: olivier Date: Wed, 14 Mar 2018 22:21:04 +0800 Subject: [PATCH 04/19] remove dupicated number refresh --- .gitignore | 4 + .travis.yml | 19 ++++ LICENSE | 165 +++++++++++++++++++++++++++++++ README.md | 8 ++ api/api.proto | 81 ++++++++++++++++ core/Contract.proto | 85 ++++++++++++++++ core/Tron.proto | 178 ++++++++++++++++++++++++++++++++++ core/TronInventoryItems.proto | 11 +++ install-protobuf.sh | 10 ++ 9 files changed, 561 insertions(+) create mode 100644 .gitignore create mode 100644 .travis.yml create mode 100644 LICENSE create mode 100644 README.md create mode 100644 api/api.proto create mode 100644 core/Contract.proto create mode 100644 core/Tron.proto create mode 100644 core/TronInventoryItems.proto create mode 100755 install-protobuf.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000000..1554c5edd92 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +# IDEA +.idea +*iml +.DS_Store diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000000..3f1e4c4709b --- /dev/null +++ b/.travis.yml @@ -0,0 +1,19 @@ +language: ruby + +cache: + directories: + - $HOME/protobuf + +sudo: false + +before_install: + - bash install-protobuf.sh + +# check what has been installed by listing contents of protobuf folder +before_script: + - ls -R $HOME/protobuf + +# let's use protobuf +script: + - $HOME/protobuf/bin/protoc --java_out=./ ./core/*.proto ./api/*.proto + - ls -l \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000000..65c5ca88a67 --- /dev/null +++ b/LICENSE @@ -0,0 +1,165 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. diff --git a/README.md b/README.md new file mode 100644 index 00000000000..c04fbf6968a --- /dev/null +++ b/README.md @@ -0,0 +1,8 @@ +# protocol [![Build Status](https://travis-ci.org/tronprotocol/protocol.svg?branch=master)](https://travis-ci.org/tronprotocol/protocol) + + +the protocol of tron including api and message. + +java-tron and wallet-cli + +git subtree pull --prefix src/main/protos/ protocol master diff --git a/api/api.proto b/api/api.proto new file mode 100644 index 00000000000..77e4be1938c --- /dev/null +++ b/api/api.proto @@ -0,0 +1,81 @@ +syntax = "proto3"; +package protocol; + +import "core/Tron.proto"; +import "core/Contract.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 + +service Wallet { + + rpc GetBalance (Account) returns (Account) { + + }; + rpc CreateTransaction (TransferContract) returns (Transaction) { + + }; + + rpc BroadcastTransaction (Transaction) returns (Return) { + + }; + + rpc ListAccounts (EmptyMessage) returns (AccountList) { + + }; + + rpc CreateAccount (AccountCreateContract) returns (Transaction) { + + }; + + rpc VoteWitnessAccount (VoteWitnessContract) returns (Transaction) { + + }; + + rpc CreateAssetIssue (AssetIssueContract) returns (Transaction) { + + }; + + rpc ListWitnesses (EmptyMessage) returns (WitnessList) { + + }; + + rpc CreateWitness (WitnessCreateContract) returns (Transaction) { + + }; + + rpc ListNodes (EmptyMessage) returns (NodeList) { + + } +}; + +message Return { + bool result = 1; +} + +message AccountList { + repeated Account accounts = 1; +} + +message WitnessList { + repeated Witness witnesses = 1; +} + +// Gossip node list +message NodeList { + repeated Node nodes = 1; +} + +// Gossip node +message Node { + Address address = 1; +} + +// Gossip node address +message Address { + bytes host = 1; + int32 port = 2; +} + +message EmptyMessage { +} diff --git a/core/Contract.proto b/core/Contract.proto new file mode 100644 index 00000000000..8b3fff1167f --- /dev/null +++ b/core/Contract.proto @@ -0,0 +1,85 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +syntax = "proto3"; + +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 + +import "core/Tron.proto"; + +message AccountCreateContract { + AccountType type = 1; + bytes account_name = 2; + bytes owner_address = 3; +} + +message TransferContract { + bytes owner_address = 1; + bytes to_address = 2; + int64 amount = 3; +} + +message TransferAssertContract { + bytes assert_name = 1; + bytes owner_address = 2; + bytes to_address = 3; + int64 amount = 4; +} + + +message VoteAssetContract { + bytes owner_address = 1; + repeated bytes vote_address = 2; + bool support = 3; + int32 count = 5; +} + +message VoteWitnessContract { + message Vote { + bytes vote_address = 1; + int64 vote_count = 2; + } + bytes owner_address = 1; + repeated Vote votes = 2; + bool support = 3; +} + +message WitnessCreateContract { + bytes owner_address = 1; + bytes url = 12; +} + +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; +} + +message DeployContract { + bytes owner_address = 1; + bytes script = 2; +} + diff --git a/core/Tron.proto b/core/Tron.proto new file mode 100644 index 00000000000..a5b3698489c --- /dev/null +++ b/core/Tron.proto @@ -0,0 +1,178 @@ +syntax = "proto3"; + +import "google/protobuf/any.proto"; + +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 + + +enum AccountType { + Normal = 0; + AssetIssue = 1; + Contract = 2; +} + +// Account +message Account { + message Vote { + bytes vote_address = 1; + int64 vote_count = 2; + } + bytes account_name = 1; + AccountType type = 2; + bytes address = 3; + int64 balance = 4; + repeated Vote votes = 5; + map asset = 6; + +} + +// Witness +message Witness { + bytes address = 1; + int64 voteCount = 2; + bytes pubKey = 3; + string url = 4; + int64 totalProduced = 5; + int64 totalMissed = 6; + int64 latestBlockNum = 7; + int64 latestSlotNum = 8; + bool isJobs = 9; +} + +// Transcation + +message TXOutput { + int64 value = 1; + bytes pubKeyHash = 2; +} + +message TXInput { + message raw { + bytes txID = 1; + int64 vout = 2; + bytes pubKey = 3; + } + raw raw_data = 1; + bytes signature = 4; +} + +message TXOutputs { + repeated TXOutput outputs = 1; +} + +message Transaction { + enum TransactionType { + UtxoType = 0; + ContractType = 1; + } + message Contract { + enum ContractType { + AccountCreateContract = 0; + TransferContract = 1; + TransferAssertContract = 2; + VoteAssetContract = 3; + VoteWitnessContract = 4; + WitnessCreateContract = 5; + AssetIssueContract = 6; + DeployContract = 7; + } + ContractType type = 1; + google.protobuf.Any parameter = 2; + } + + message Result { + enum code { + SUCESS = 0; + FAILED = 1; + } + int64 fee = 1; + code ret = 2; + } + + message raw { + TransactionType type = 2; + repeated TXInput vin = 5; + repeated TXOutput vout = 7; + int64 expiration = 8; + bytes data = 10; + repeated Contract contract = 11; + bytes scripts = 16; + } + + raw raw_data = 1; + repeated bytes signature = 2; + repeated Result ret = 5; +} + +message BlockHeader { + message raw { + int64 timestamp = 1; + bytes txTrieRoot = 2; + bytes parentHash = 3; + //bytes nonce = 5; + //bytes difficulty = 6; + int64 number = 7; + int64 witness_id = 8; + bytes witness_address = 9; + } + raw raw_data = 1; + bytes witness_signature = 2; +} + +// block +message Block { + repeated Transaction transactions = 1; + BlockHeader block_header = 2; +} + +message ChainInventory { + message BlockId { + bytes hash = 1; + int64 number = 2; + } + repeated BlockId ids = 1; + int64 remain_num = 2; +} + +// Inventory +message BlockInventory { + enum Type { + SYNC = 0; + ADVTISE = 1; + FETCH = 2; + } + + message BlockId { + bytes hash = 1; + int64 number = 2; + } + repeated BlockId ids = 1; + Type type = 2; +} + +message Inventory { + enum InventoryType { + TRX = 0; + BLOCK = 1; + } + InventoryType type = 1; + repeated bytes ids = 2; +} + +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; +} diff --git a/core/TronInventoryItems.proto b/core/TronInventoryItems.proto new file mode 100644 index 00000000000..fb16f1d5431 --- /dev/null +++ b/core/TronInventoryItems.proto @@ -0,0 +1,11 @@ +syntax = "proto3"; + +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 + +message InventoryItems { + int32 type = 1; + repeated bytes items = 2; +} \ No newline at end of file diff --git a/install-protobuf.sh b/install-protobuf.sh new file mode 100755 index 00000000000..29e5536ee6d --- /dev/null +++ b/install-protobuf.sh @@ -0,0 +1,10 @@ +#!/bin/sh +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 + cd protobuf-3.5.1 && ./configure --prefix=$HOME/protobuf && make && make install +else + echo "Using cached directory." +fi From 7f4f3027ecee8eeed856a626816f4271cb305853 Mon Sep 17 00:00:00 2001 From: sean-liu55 Date: Thu, 15 Mar 2018 10:54:02 +0800 Subject: [PATCH 05/19] rm duplicate instance --- .gitignore | 4 + .travis.yml | 19 ++++ LICENSE | 165 +++++++++++++++++++++++++++++++ README.md | 8 ++ api/api.proto | 81 ++++++++++++++++ core/Contract.proto | 85 ++++++++++++++++ core/Tron.proto | 178 ++++++++++++++++++++++++++++++++++ core/TronInventoryItems.proto | 11 +++ install-protobuf.sh | 10 ++ 9 files changed, 561 insertions(+) create mode 100644 .gitignore create mode 100644 .travis.yml create mode 100644 LICENSE create mode 100644 README.md create mode 100644 api/api.proto create mode 100644 core/Contract.proto create mode 100644 core/Tron.proto create mode 100644 core/TronInventoryItems.proto create mode 100755 install-protobuf.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000000..1554c5edd92 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +# IDEA +.idea +*iml +.DS_Store diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000000..3f1e4c4709b --- /dev/null +++ b/.travis.yml @@ -0,0 +1,19 @@ +language: ruby + +cache: + directories: + - $HOME/protobuf + +sudo: false + +before_install: + - bash install-protobuf.sh + +# check what has been installed by listing contents of protobuf folder +before_script: + - ls -R $HOME/protobuf + +# let's use protobuf +script: + - $HOME/protobuf/bin/protoc --java_out=./ ./core/*.proto ./api/*.proto + - ls -l \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000000..65c5ca88a67 --- /dev/null +++ b/LICENSE @@ -0,0 +1,165 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. diff --git a/README.md b/README.md new file mode 100644 index 00000000000..c04fbf6968a --- /dev/null +++ b/README.md @@ -0,0 +1,8 @@ +# protocol [![Build Status](https://travis-ci.org/tronprotocol/protocol.svg?branch=master)](https://travis-ci.org/tronprotocol/protocol) + + +the protocol of tron including api and message. + +java-tron and wallet-cli + +git subtree pull --prefix src/main/protos/ protocol master diff --git a/api/api.proto b/api/api.proto new file mode 100644 index 00000000000..77e4be1938c --- /dev/null +++ b/api/api.proto @@ -0,0 +1,81 @@ +syntax = "proto3"; +package protocol; + +import "core/Tron.proto"; +import "core/Contract.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 + +service Wallet { + + rpc GetBalance (Account) returns (Account) { + + }; + rpc CreateTransaction (TransferContract) returns (Transaction) { + + }; + + rpc BroadcastTransaction (Transaction) returns (Return) { + + }; + + rpc ListAccounts (EmptyMessage) returns (AccountList) { + + }; + + rpc CreateAccount (AccountCreateContract) returns (Transaction) { + + }; + + rpc VoteWitnessAccount (VoteWitnessContract) returns (Transaction) { + + }; + + rpc CreateAssetIssue (AssetIssueContract) returns (Transaction) { + + }; + + rpc ListWitnesses (EmptyMessage) returns (WitnessList) { + + }; + + rpc CreateWitness (WitnessCreateContract) returns (Transaction) { + + }; + + rpc ListNodes (EmptyMessage) returns (NodeList) { + + } +}; + +message Return { + bool result = 1; +} + +message AccountList { + repeated Account accounts = 1; +} + +message WitnessList { + repeated Witness witnesses = 1; +} + +// Gossip node list +message NodeList { + repeated Node nodes = 1; +} + +// Gossip node +message Node { + Address address = 1; +} + +// Gossip node address +message Address { + bytes host = 1; + int32 port = 2; +} + +message EmptyMessage { +} diff --git a/core/Contract.proto b/core/Contract.proto new file mode 100644 index 00000000000..8b3fff1167f --- /dev/null +++ b/core/Contract.proto @@ -0,0 +1,85 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +syntax = "proto3"; + +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 + +import "core/Tron.proto"; + +message AccountCreateContract { + AccountType type = 1; + bytes account_name = 2; + bytes owner_address = 3; +} + +message TransferContract { + bytes owner_address = 1; + bytes to_address = 2; + int64 amount = 3; +} + +message TransferAssertContract { + bytes assert_name = 1; + bytes owner_address = 2; + bytes to_address = 3; + int64 amount = 4; +} + + +message VoteAssetContract { + bytes owner_address = 1; + repeated bytes vote_address = 2; + bool support = 3; + int32 count = 5; +} + +message VoteWitnessContract { + message Vote { + bytes vote_address = 1; + int64 vote_count = 2; + } + bytes owner_address = 1; + repeated Vote votes = 2; + bool support = 3; +} + +message WitnessCreateContract { + bytes owner_address = 1; + bytes url = 12; +} + +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; +} + +message DeployContract { + bytes owner_address = 1; + bytes script = 2; +} + diff --git a/core/Tron.proto b/core/Tron.proto new file mode 100644 index 00000000000..a5b3698489c --- /dev/null +++ b/core/Tron.proto @@ -0,0 +1,178 @@ +syntax = "proto3"; + +import "google/protobuf/any.proto"; + +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 + + +enum AccountType { + Normal = 0; + AssetIssue = 1; + Contract = 2; +} + +// Account +message Account { + message Vote { + bytes vote_address = 1; + int64 vote_count = 2; + } + bytes account_name = 1; + AccountType type = 2; + bytes address = 3; + int64 balance = 4; + repeated Vote votes = 5; + map asset = 6; + +} + +// Witness +message Witness { + bytes address = 1; + int64 voteCount = 2; + bytes pubKey = 3; + string url = 4; + int64 totalProduced = 5; + int64 totalMissed = 6; + int64 latestBlockNum = 7; + int64 latestSlotNum = 8; + bool isJobs = 9; +} + +// Transcation + +message TXOutput { + int64 value = 1; + bytes pubKeyHash = 2; +} + +message TXInput { + message raw { + bytes txID = 1; + int64 vout = 2; + bytes pubKey = 3; + } + raw raw_data = 1; + bytes signature = 4; +} + +message TXOutputs { + repeated TXOutput outputs = 1; +} + +message Transaction { + enum TransactionType { + UtxoType = 0; + ContractType = 1; + } + message Contract { + enum ContractType { + AccountCreateContract = 0; + TransferContract = 1; + TransferAssertContract = 2; + VoteAssetContract = 3; + VoteWitnessContract = 4; + WitnessCreateContract = 5; + AssetIssueContract = 6; + DeployContract = 7; + } + ContractType type = 1; + google.protobuf.Any parameter = 2; + } + + message Result { + enum code { + SUCESS = 0; + FAILED = 1; + } + int64 fee = 1; + code ret = 2; + } + + message raw { + TransactionType type = 2; + repeated TXInput vin = 5; + repeated TXOutput vout = 7; + int64 expiration = 8; + bytes data = 10; + repeated Contract contract = 11; + bytes scripts = 16; + } + + raw raw_data = 1; + repeated bytes signature = 2; + repeated Result ret = 5; +} + +message BlockHeader { + message raw { + int64 timestamp = 1; + bytes txTrieRoot = 2; + bytes parentHash = 3; + //bytes nonce = 5; + //bytes difficulty = 6; + int64 number = 7; + int64 witness_id = 8; + bytes witness_address = 9; + } + raw raw_data = 1; + bytes witness_signature = 2; +} + +// block +message Block { + repeated Transaction transactions = 1; + BlockHeader block_header = 2; +} + +message ChainInventory { + message BlockId { + bytes hash = 1; + int64 number = 2; + } + repeated BlockId ids = 1; + int64 remain_num = 2; +} + +// Inventory +message BlockInventory { + enum Type { + SYNC = 0; + ADVTISE = 1; + FETCH = 2; + } + + message BlockId { + bytes hash = 1; + int64 number = 2; + } + repeated BlockId ids = 1; + Type type = 2; +} + +message Inventory { + enum InventoryType { + TRX = 0; + BLOCK = 1; + } + InventoryType type = 1; + repeated bytes ids = 2; +} + +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; +} diff --git a/core/TronInventoryItems.proto b/core/TronInventoryItems.proto new file mode 100644 index 00000000000..fb16f1d5431 --- /dev/null +++ b/core/TronInventoryItems.proto @@ -0,0 +1,11 @@ +syntax = "proto3"; + +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 + +message InventoryItems { + int32 type = 1; + repeated bytes items = 2; +} \ No newline at end of file diff --git a/install-protobuf.sh b/install-protobuf.sh new file mode 100755 index 00000000000..29e5536ee6d --- /dev/null +++ b/install-protobuf.sh @@ -0,0 +1,10 @@ +#!/bin/sh +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 + cd protobuf-3.5.1 && ./configure --prefix=$HOME/protobuf && make && make install +else + echo "Using cached directory." +fi From c9410d823e77b729eb106aaca7d91e35ffc7747d Mon Sep 17 00:00:00 2001 From: Sheip Date: Fri, 16 Mar 2018 18:51:10 +0100 Subject: [PATCH 06/19] refactoring --- .gitignore | 4 + .travis.yml | 19 ++++ LICENSE | 165 +++++++++++++++++++++++++++++++++ README.md | 8 ++ api/api.proto | 81 +++++++++++++++++ core/Contract.proto | 85 +++++++++++++++++ core/Tron.proto | 166 ++++++++++++++++++++++++++++++++++ core/TronInventoryItems.proto | 11 +++ install-protobuf.sh | 10 ++ 9 files changed, 549 insertions(+) create mode 100644 .gitignore create mode 100644 .travis.yml create mode 100644 LICENSE create mode 100644 README.md create mode 100644 api/api.proto create mode 100644 core/Contract.proto create mode 100644 core/Tron.proto create mode 100644 core/TronInventoryItems.proto create mode 100755 install-protobuf.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000000..1554c5edd92 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +# IDEA +.idea +*iml +.DS_Store diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000000..3f1e4c4709b --- /dev/null +++ b/.travis.yml @@ -0,0 +1,19 @@ +language: ruby + +cache: + directories: + - $HOME/protobuf + +sudo: false + +before_install: + - bash install-protobuf.sh + +# check what has been installed by listing contents of protobuf folder +before_script: + - ls -R $HOME/protobuf + +# let's use protobuf +script: + - $HOME/protobuf/bin/protoc --java_out=./ ./core/*.proto ./api/*.proto + - ls -l \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 00000000000..65c5ca88a67 --- /dev/null +++ b/LICENSE @@ -0,0 +1,165 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. diff --git a/README.md b/README.md new file mode 100644 index 00000000000..c04fbf6968a --- /dev/null +++ b/README.md @@ -0,0 +1,8 @@ +# protocol [![Build Status](https://travis-ci.org/tronprotocol/protocol.svg?branch=master)](https://travis-ci.org/tronprotocol/protocol) + + +the protocol of tron including api and message. + +java-tron and wallet-cli + +git subtree pull --prefix src/main/protos/ protocol master diff --git a/api/api.proto b/api/api.proto new file mode 100644 index 00000000000..77e4be1938c --- /dev/null +++ b/api/api.proto @@ -0,0 +1,81 @@ +syntax = "proto3"; +package protocol; + +import "core/Tron.proto"; +import "core/Contract.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 + +service Wallet { + + rpc GetBalance (Account) returns (Account) { + + }; + rpc CreateTransaction (TransferContract) returns (Transaction) { + + }; + + rpc BroadcastTransaction (Transaction) returns (Return) { + + }; + + rpc ListAccounts (EmptyMessage) returns (AccountList) { + + }; + + rpc CreateAccount (AccountCreateContract) returns (Transaction) { + + }; + + rpc VoteWitnessAccount (VoteWitnessContract) returns (Transaction) { + + }; + + rpc CreateAssetIssue (AssetIssueContract) returns (Transaction) { + + }; + + rpc ListWitnesses (EmptyMessage) returns (WitnessList) { + + }; + + rpc CreateWitness (WitnessCreateContract) returns (Transaction) { + + }; + + rpc ListNodes (EmptyMessage) returns (NodeList) { + + } +}; + +message Return { + bool result = 1; +} + +message AccountList { + repeated Account accounts = 1; +} + +message WitnessList { + repeated Witness witnesses = 1; +} + +// Gossip node list +message NodeList { + repeated Node nodes = 1; +} + +// Gossip node +message Node { + Address address = 1; +} + +// Gossip node address +message Address { + bytes host = 1; + int32 port = 2; +} + +message EmptyMessage { +} diff --git a/core/Contract.proto b/core/Contract.proto new file mode 100644 index 00000000000..8b3fff1167f --- /dev/null +++ b/core/Contract.proto @@ -0,0 +1,85 @@ +/* + * java-tron is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * java-tron is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +syntax = "proto3"; + +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 + +import "core/Tron.proto"; + +message AccountCreateContract { + AccountType type = 1; + bytes account_name = 2; + bytes owner_address = 3; +} + +message TransferContract { + bytes owner_address = 1; + bytes to_address = 2; + int64 amount = 3; +} + +message TransferAssertContract { + bytes assert_name = 1; + bytes owner_address = 2; + bytes to_address = 3; + int64 amount = 4; +} + + +message VoteAssetContract { + bytes owner_address = 1; + repeated bytes vote_address = 2; + bool support = 3; + int32 count = 5; +} + +message VoteWitnessContract { + message Vote { + bytes vote_address = 1; + int64 vote_count = 2; + } + bytes owner_address = 1; + repeated Vote votes = 2; + bool support = 3; +} + +message WitnessCreateContract { + bytes owner_address = 1; + bytes url = 12; +} + +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; +} + +message DeployContract { + bytes owner_address = 1; + bytes script = 2; +} + diff --git a/core/Tron.proto b/core/Tron.proto new file mode 100644 index 00000000000..4b5d5446c7e --- /dev/null +++ b/core/Tron.proto @@ -0,0 +1,166 @@ +syntax = "proto3"; + +import "google/protobuf/any.proto"; + +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 + + +enum AccountType { + Normal = 0; + AssetIssue = 1; + Contract = 2; +} + +// Account +message Account { + message Vote { + bytes vote_address = 1; + int64 vote_count = 2; + } + bytes account_name = 1; + AccountType type = 2; + bytes address = 3; + int64 balance = 4; + repeated Vote votes = 5; + map asset = 6; + +} + +// Witness +message Witness { + bytes address = 1; + int64 voteCount = 2; + bytes pubKey = 3; + string url = 4; + int64 totalProduced = 5; + int64 totalMissed = 6; + int64 latestBlockNum = 7; + int64 latestSlotNum = 8; + bool isJobs = 9; +} + +// Transcation + +message TXOutput { + int64 value = 1; + bytes pubKeyHash = 2; +} + +message TXInput { + message raw { + bytes txID = 1; + int64 vout = 2; + bytes pubKey = 3; + } + raw raw_data = 1; + bytes signature = 4; +} + +message TXOutputs { + repeated TXOutput outputs = 1; +} + +message Transaction { + enum TransactionType { + UtxoType = 0; + ContractType = 1; + } + message Contract { + enum ContractType { + AccountCreateContract = 0; + TransferContract = 1; + TransferAssertContract = 2; + VoteAssetContract = 3; + VoteWitnessContract = 4; + WitnessCreateContract = 5; + AssetIssueContract = 6; + DeployContract = 7; + } + ContractType type = 1; + google.protobuf.Any parameter = 2; + } + message raw { + TransactionType type = 2; + repeated TXInput vin = 5; + repeated TXOutput vout = 7; + int64 expiration = 8; + bytes data = 10; + repeated Contract contract = 11; + bytes scripts = 16; + } + raw raw_data = 1; + repeated bytes signature = 5; +} + +message BlockHeader { + message raw { + int64 timestamp = 1; + bytes txTrieRoot = 2; + bytes parentHash = 3; + //bytes nonce = 5; + //bytes difficulty = 6; + int64 number = 7; + int64 witness_id = 8; + bytes witness_address = 9; + } + raw raw_data = 1; + bytes witness_signature = 2; +} + +// block +message Block { + repeated Transaction transactions = 1; + BlockHeader block_header = 2; +} + +message ChainInventory { + message BlockId { + bytes hash = 1; + int64 number = 2; + } + repeated BlockId ids = 1; + int64 remain_num = 2; +} + +// Inventory +message BlockInventory { + enum Type { + SYNC = 0; + ADVTISE = 1; + FETCH = 2; + } + + message BlockId { + bytes hash = 1; + int64 number = 2; + } + repeated BlockId ids = 1; + Type type = 2; +} + +message Inventory { + enum InventoryType { + TRX = 0; + BLOCK = 1; + } + InventoryType type = 1; + repeated bytes ids = 2; +} + +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; +} diff --git a/core/TronInventoryItems.proto b/core/TronInventoryItems.proto new file mode 100644 index 00000000000..fb16f1d5431 --- /dev/null +++ b/core/TronInventoryItems.proto @@ -0,0 +1,11 @@ +syntax = "proto3"; + +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 + +message InventoryItems { + int32 type = 1; + repeated bytes items = 2; +} \ No newline at end of file diff --git a/install-protobuf.sh b/install-protobuf.sh new file mode 100755 index 00000000000..29e5536ee6d --- /dev/null +++ b/install-protobuf.sh @@ -0,0 +1,10 @@ +#!/bin/sh +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 + cd protobuf-3.5.1 && ./configure --prefix=$HOME/protobuf && make && make install +else + echo "Using cached directory." +fi From 0aaff3d650d5930da88d8f3d32a0a70534f617db Mon Sep 17 00:00:00 2001 From: wubin01 Date: Tue, 20 Mar 2018 14:51:48 +0800 Subject: [PATCH 07/19] mdf discover msg --- core/{Message.proto => Discover.proto} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename core/{Message.proto => Discover.proto} (100%) diff --git a/core/Message.proto b/core/Discover.proto similarity index 100% rename from core/Message.proto rename to core/Discover.proto From fcc01febb0bf1174d848d685b1c4ae80ce2ff8c6 Mon Sep 17 00:00:00 2001 From: Marcus Date: Thu, 22 Mar 2018 22:48:38 +0800 Subject: [PATCH 08/19] Revert "Feature/devfor evan" --- api/api.proto | 4 ---- core/Discover.proto | 38 ++++++++++++++++++++++++++++++++++++++ core/Tron.proto | 28 ---------------------------- 3 files changed, 38 insertions(+), 32 deletions(-) diff --git a/api/api.proto b/api/api.proto index 6619c5c3a26..aa50632d1b4 100644 --- a/api/api.proto +++ b/api/api.proto @@ -52,7 +52,6 @@ service Wallet { rpc TransferAsset (TransferAssetContract) returns (Transaction) { } - rpc ParticipateAssetIssue (ParticipateAssetIssueContract) returns (Transaction) { } @@ -62,9 +61,6 @@ service Wallet { } rpc GetAssetIssueList (EmptyMessage) returns (AssetIssueList) { - } - rpc GetAssetIssueByAccount (Account) returns (AssetIssueList) { - } rpc GetNowBlock (EmptyMessage) returns (Block) { diff --git a/core/Discover.proto b/core/Discover.proto index cc795db63ff..ed8d00cb0d0 100644 --- a/core/Discover.proto +++ b/core/Discover.proto @@ -6,6 +6,44 @@ 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 +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; + UNKNOWN = 13; +} + +message Peer { + bytes address = 1; + int32 port = 2; + string peerId = 3; +} + +message DisconnectMessage { + ReasonCode reason = 1; +} + +message HelloMessage { + int32 p2pVersion = 1; + string clientId = 2; + int32 listenPort = 4; + string peerId = 5; +} + +message PeersMessage { + repeated Peer peers = 1; +} + message Endpoint { bytes address = 1; int32 port = 2; diff --git a/core/Tron.proto b/core/Tron.proto index 8a86eebcce9..83c46358491 100644 --- a/core/Tron.proto +++ b/core/Tron.proto @@ -179,31 +179,3 @@ message Items { repeated BlockHeader block_headers = 3; repeated Transaction transactions = 4; } - -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; - UNKNOWN = 13; -} - -message DisconnectMessage { - ReasonCode reason = 1; -} - -message HelloMessage { - int32 p2pVersion = 1; - string clientId = 2; - int32 listenPort = 4; - string peerId = 5; -} From 192b1df6ede6f79deb79108a00996e3362d30265 Mon Sep 17 00:00:00 2001 From: Heng Zhang Date: Fri, 23 Mar 2018 14:48:31 +0800 Subject: [PATCH 09/19] Revert "Revert "Feature/devfor evan"" --- api/api.proto | 4 ++++ core/Discover.proto | 38 -------------------------------------- core/Tron.proto | 28 ++++++++++++++++++++++++++++ 3 files changed, 32 insertions(+), 38 deletions(-) diff --git a/api/api.proto b/api/api.proto index aa50632d1b4..6619c5c3a26 100644 --- a/api/api.proto +++ b/api/api.proto @@ -52,6 +52,7 @@ service Wallet { rpc TransferAsset (TransferAssetContract) returns (Transaction) { } + rpc ParticipateAssetIssue (ParticipateAssetIssueContract) returns (Transaction) { } @@ -61,6 +62,9 @@ service Wallet { } rpc GetAssetIssueList (EmptyMessage) returns (AssetIssueList) { + } + rpc GetAssetIssueByAccount (Account) returns (AssetIssueList) { + } rpc GetNowBlock (EmptyMessage) returns (Block) { diff --git a/core/Discover.proto b/core/Discover.proto index ed8d00cb0d0..cc795db63ff 100644 --- a/core/Discover.proto +++ b/core/Discover.proto @@ -6,44 +6,6 @@ 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 -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; - UNKNOWN = 13; -} - -message Peer { - bytes address = 1; - int32 port = 2; - string peerId = 3; -} - -message DisconnectMessage { - ReasonCode reason = 1; -} - -message HelloMessage { - int32 p2pVersion = 1; - string clientId = 2; - int32 listenPort = 4; - string peerId = 5; -} - -message PeersMessage { - repeated Peer peers = 1; -} - message Endpoint { bytes address = 1; int32 port = 2; diff --git a/core/Tron.proto b/core/Tron.proto index 83c46358491..8a86eebcce9 100644 --- a/core/Tron.proto +++ b/core/Tron.proto @@ -179,3 +179,31 @@ message Items { repeated BlockHeader block_headers = 3; repeated Transaction transactions = 4; } + +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; + UNKNOWN = 13; +} + +message DisconnectMessage { + ReasonCode reason = 1; +} + +message HelloMessage { + int32 p2pVersion = 1; + string clientId = 2; + int32 listenPort = 4; + string peerId = 5; +} From ac5eed97d011da2100991bd5723127091aede9c6 Mon Sep 17 00:00:00 2001 From: zhaohong Date: Mon, 2 Apr 2018 10:58:15 +0800 Subject: [PATCH 10/19] add comments about ParticipateAssetIssueContract. --- core/Contract.proto | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/Contract.proto b/core/Contract.proto index 9d0870973c6..b334f7709b0 100644 --- a/core/Contract.proto +++ b/core/Contract.proto @@ -29,7 +29,7 @@ message AccountCreateContract { } // update account name if the account has no name. -message AccountUpdateContract{ +message AccountUpdateContract { bytes account_name = 1; bytes owner_address = 2; } @@ -92,8 +92,8 @@ message AssetIssueContract { message ParticipateAssetIssueContract { bytes owner_address = 1; bytes to_address = 2; - bytes asset_name = 3; - int64 amount = 4; + bytes asset_name = 3; // the name of target asset + int64 amount = 4; // the amount of drops } message DeployContract { From c7f7d3ec13f19769cc49233972e344c08122f5f3 Mon Sep 17 00:00:00 2001 From: zhaohong Date: Mon, 2 Apr 2018 19:59:04 +0800 Subject: [PATCH 11/19] feat: remove utxo support from protocol. --- core/Tron.proto | 2 -- 1 file changed, 2 deletions(-) diff --git a/core/Tron.proto b/core/Tron.proto index 481fdf60f34..f4d46dc8e53 100644 --- a/core/Tron.proto +++ b/core/Tron.proto @@ -98,8 +98,6 @@ message Transaction { message raw { TransactionType type = 2; - repeated TXInput vin = 5; - repeated TXOutput vout = 7; int64 expiration = 8; bytes data = 10; repeated Contract contract = 11; From 7acdfaf991af56967732a2724361f20844f00c51 Mon Sep 17 00:00:00 2001 From: zhaohong Date: Tue, 10 Apr 2018 16:54:22 +0800 Subject: [PATCH 12/19] improve: add ref_block_num and ref_block_hash --- core/Tron.proto | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/Tron.proto b/core/Tron.proto index f4d46dc8e53..d6df9a2029d 100644 --- a/core/Tron.proto +++ b/core/Tron.proto @@ -97,7 +97,9 @@ message Transaction { } message raw { - TransactionType type = 2; + TransactionType type = 1 + int64 ref_block_num = 3; + bytes ref_block_hash = 4; int64 expiration = 8; bytes data = 10; repeated Contract contract = 11; From d4a93ed78b54a40d2bcea31d4bab7fa38242de4a Mon Sep 17 00:00:00 2001 From: zhaohong Date: Tue, 10 Apr 2018 17:01:20 +0800 Subject: [PATCH 13/19] improve: modified the seq num and fix build error --- core/Tron.proto | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/Tron.proto b/core/Tron.proto index d6df9a2029d..8aa587249eb 100644 --- a/core/Tron.proto +++ b/core/Tron.proto @@ -97,14 +97,14 @@ message Transaction { } message raw { - TransactionType type = 1 + TransactionType type = 1; int64 ref_block_num = 3; bytes ref_block_hash = 4; int64 expiration = 8; bytes data = 10; repeated Contract contract = 11; - bytes scripts = 16; - int64 timestamp = 17; + bytes scripts = 12; + int64 timestamp = 14; } raw raw_data = 1; From 303dd5dcb3bf1d5776fbddf5f871249053554b7f Mon Sep 17 00:00:00 2001 From: zhaohong Date: Tue, 10 Apr 2018 21:45:16 +0800 Subject: [PATCH 14/19] feat: add BlockReference api --- api/api.proto | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/api/api.proto b/api/api.proto index d01979ee993..fd08b73019f 100644 --- a/api/api.proto +++ b/api/api.proto @@ -85,9 +85,17 @@ service Wallet { }; // the api of tron's db service Database { + // for tapos + rpc getBlockReference (EmptyMessage) returns (BlockReference) { + } }; +message BlockReference { + int64 block_num = 1; + bytes block_hash = 2; +} + // the api of tron's network such as node list. service Network { From 7f1d31a4f4582c0ce7143070f2b07ad7b8c62ef2 Mon Sep 17 00:00:00 2001 From: sasaxie Date: Tue, 10 Apr 2018 16:29:35 +0800 Subject: [PATCH 15/19] add go package setting --- api/api.proto | 1 + core/Discover.proto | 1 + core/Tron.proto | 1 + core/TronInventoryItems.proto | 1 + 4 files changed, 4 insertions(+) diff --git a/api/api.proto b/api/api.proto index fd08b73019f..8e179a20e65 100644 --- a/api/api.proto +++ b/api/api.proto @@ -6,6 +6,7 @@ import "core/Contract.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 = "go-client-api/api"; service Wallet { diff --git a/core/Discover.proto b/core/Discover.proto index 2a9668ba75c..e85174bbb1a 100644 --- a/core/Discover.proto +++ b/core/Discover.proto @@ -5,6 +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 = "go-client-api/core"; message Endpoint { bytes address = 1; diff --git a/core/Tron.proto b/core/Tron.proto index 8aa587249eb..c5427b812c7 100644 --- a/core/Tron.proto +++ b/core/Tron.proto @@ -8,6 +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 = "go-client-api/core"; enum AccountType { diff --git a/core/TronInventoryItems.proto b/core/TronInventoryItems.proto index fb16f1d5431..c13676921bc 100644 --- a/core/TronInventoryItems.proto +++ b/core/TronInventoryItems.proto @@ -4,6 +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 = "go-client-api/core"; message InventoryItems { int32 type = 1; From f549760ac4871858704c413577f53c9123a4f688 Mon Sep 17 00:00:00 2001 From: sasaxie Date: Tue, 10 Apr 2018 16:41:16 +0800 Subject: [PATCH 16/19] add go package setting --- api/api.proto | 2 +- core/Discover.proto | 2 +- core/Tron.proto | 2 +- core/TronInventoryItems.proto | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/api/api.proto b/api/api.proto index 8e179a20e65..a571e0bdb4c 100644 --- a/api/api.proto +++ b/api/api.proto @@ -6,7 +6,7 @@ import "core/Contract.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 = "go-client-api/api"; +option go_package = "github.com/tronprotocol/go-client-api/api"; service Wallet { diff --git a/core/Discover.proto b/core/Discover.proto index e85174bbb1a..ac45a30364a 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 = "go-client-api/core"; +option go_package = "github.com/tronprotocol/go-client-api/core"; message Endpoint { bytes address = 1; diff --git a/core/Tron.proto b/core/Tron.proto index c5427b812c7..7339733487a 100644 --- a/core/Tron.proto +++ b/core/Tron.proto @@ -8,7 +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 = "go-client-api/core"; +option go_package = "github.com/tronprotocol/go-client-api/core"; enum AccountType { diff --git a/core/TronInventoryItems.proto b/core/TronInventoryItems.proto index c13676921bc..f630ffad598 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 = "go-client-api/core"; +option go_package = "github.com/tronprotocol/go-client-api/core"; message InventoryItems { int32 type = 1; From c56402e1417c5ad1e55318c7852fa71eef005d07 Mon Sep 17 00:00:00 2001 From: huzhenyuan Date: Thu, 12 Apr 2018 15:37:41 +0800 Subject: [PATCH 17/19] add solidity node impl --- api/api.proto | 10 ++++++++++ core/Contract.proto | 1 + core/Tron.proto | 5 +++++ 3 files changed, 16 insertions(+) diff --git a/api/api.proto b/api/api.proto index a571e0bdb4c..3b47771b2c3 100644 --- a/api/api.proto +++ b/api/api.proto @@ -84,11 +84,21 @@ service Wallet { } }; + // the api of tron's db service Database { // for tapos rpc getBlockReference (EmptyMessage) returns (BlockReference) { + } + rpc GetDynamicProperties (EmptyMessage) returns (DynamicProperties) { + + } + rpc GetNowBlock (EmptyMessage) returns (Block) { + + } + rpc GetBlockByNum (NumberMessage) returns (Block) { + } }; diff --git a/core/Contract.proto b/core/Contract.proto index b334f7709b0..a00c82eec58 100644 --- a/core/Contract.proto +++ b/core/Contract.proto @@ -19,6 +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"; import "core/Tron.proto"; diff --git a/core/Tron.proto b/core/Tron.proto index 7339733487a..b5914a3d33f 100644 --- a/core/Tron.proto +++ b/core/Tron.proto @@ -182,6 +182,11 @@ message Items { repeated Transaction transactions = 4; } +// DynamicProperties +message DynamicProperties { + int64 last_solidity_block_num = 1; +} + enum ReasonCode { REQUESTED = 0; TCP_ERROR = 1; From d1395973333fd8a90276705e58a478a8db8ee5d0 Mon Sep 17 00:00:00 2001 From: liangzhiyan Date: Thu, 19 Apr 2018 20:54:44 +0800 Subject: [PATCH 18/19] modify use LatestBlockHeaderNumber compare --- core/Tron.proto | 1 + 1 file changed, 1 insertion(+) diff --git a/core/Tron.proto b/core/Tron.proto index d9800a4f710..87a0b6ca70b 100644 --- a/core/Tron.proto +++ b/core/Tron.proto @@ -201,6 +201,7 @@ enum ReasonCode { PING_TIMEOUT = 0x0B; USER_REASON = 0x10; RESET = 0x11; + SYNC_FAIL = 0x12; UNKNOWN = 0xFF; } From 3868626b0195ebfb4ca9d7e8da83904d3a383a7f Mon Sep 17 00:00:00 2001 From: ashu Date: Tue, 24 Apr 2018 14:42:07 +0800 Subject: [PATCH 19/19] merge develop --- core/Tron.proto | 1 + 1 file changed, 1 insertion(+) diff --git a/core/Tron.proto b/core/Tron.proto index 87a0b6ca70b..10cbcbfa0c5 100644 --- a/core/Tron.proto +++ b/core/Tron.proto @@ -82,6 +82,7 @@ message Transaction { DeployContract = 7; WitnessUpdateContract = 8; ParticipateAssetIssueContract = 9; + AccountUpdateContract = 10; } ContractType type = 1; google.protobuf.Any parameter = 2;