LITETOKENS uses the Google protobuf protocol, which involves accounts, blocks, and multiple levels of transmission.
- There are three types of accounts: basic accounts, asset release accounts and contract accounts. An account contains 6 attributes: account name, account type, address, balance, voting, and other assets.
- Furthermore, the basic account can apply to become a verification node. The verification node has additional attributes, voting statistics, public key, URL, and historical performance parameters.
Three kinds of types:Account
, , .Normal``AssetIssue``Contract
enum AccountType {
Normal = 0;
AssetIssue = 1;
Contract = 2;
}
One Account
contains 7 kinds of parameters::
account_name
The name of the account-for example: " SicCongsAccount ".
type
: The type of the account-for example: 0 represents the type of account Normal
.
balance
: The XLT balance of the account-for example: 4213312 .
votes
: The number of votes from the account-for example: {("0x1b7w...9xj3",323),("0x8djq...j12m",88),...,("0x82nd...mx6i",10001)} .
asset
: Other assets on the account except XLT-for example: {<"WishToken",66666>,<"Dogie",233>} . latest_operation_time
: The latest active time of the account.
// Account
message Account {
message Vote {
bytes vote_address = 1;
int64 vote_count = 2;
}
bytes accout_name = 1;
AccountType type = 2;
bytes address = 3;
int64 balance = 4;
repeated Vote votes = 5;
map<string, int64> asset = 6;
int64 latest_operation_time = 10;
}
One Witness
contains 8 kinds of parameters::
address
the address of the verification node-for example: "0xu82h...7237" .
voteCount
: The number of votes obtained by the verification node-for example: 234234 .
pubKey
: The public key of the verification node-for example: "0xu82h...7237" .
url
: Verify the url link of the node.
totalProduce
: The number of blocks generated by the verification node-for example: 2434 .
totalMissed
: The number of blocks lost by the verification node-for example: 7 .
latestBlockNum
: The latest block height-for example: 4522 . isJobs
: Boolean table type flag bit.
// Witness
message Witness {
bytes address = 1;
int64 voteCount = 2;
bytes pubKey = 3;
string url = 4;
int64 totalProduced = 5;
int64 totalMissed = 6;
int64 latestBlockNum = 7;
bool isJobs = 9;
}
- A block consists of a block header and multiple transactions. The block header contains the basic information of the block such as timestamp, the root of the transaction dictionary tree, parent hash, and signature.
An block
inclusive transactions
sum block_header
.
transactions
: Transaction information in the block.
block_header
: One of the components of the block.
// block
message Block {
repeated Transaction transactions = 1;
BlockHeader block_header = 2;
}
BlockHeader
Including raw_data
and witness_signature
.
raw_data
: raw
Information.
witness_signature
: The signature from the block head to the verification node.
The message raw
contains 6 kinds of parameters::
timestamp
The timestamp of the message body-for example: 14356325 .
txTrieRoot
: The root of the Merkle Tree-for example: "7dacsa...3ed" .
parentHash
: The hash value of the previous block-for example: "7dacsa...3ed" .
number
: Block height-for example: 13534657 .
witness_id
: Verify the id of the node-for example: "0xu82h...7237" .
witness_address
: The address of the verification node-for example: "0xu82h...7237" .
message BlockHeader {
message raw {
int64 timestamp = 1;
bytes txTrieRoot = 2;
bytes parentHash = 3;
//bytes nonce = 5;
//bytes difficulty = 6;
uint64 number = 7;
uint64 witness_id = 8;
bytes witness_address = 9;
}
raw raw_data = 1;
bytes witness_signature = 2;
}
Message body ChainInventory
comprises BlockId
and remain_num
.
BlockId
: Identity information of the block.
remain_num
: The number of remaining blocks during the synchronization process.
A BlockId
contains 2 parameters::
hash
The hash value of the block.
number
: The height is the current block number.
message ChainInventory {
message BlockId {
bytes hash = 1;
int64 number = 2;
}
repeated BlockId ids = 1;
int64 remain_num = 2;
}
- There are many types of trading contracts, including account creation contract, account update contract, transfer contract, transfer assertion contract, asset voting contract, witness node voting contract, witness node creation contract, witness node update contract, asset release contract, participation in asset release and 11 types of deployment contracts.
AccountCreatContract
Contains 3 kinds of parameters::
type
account type-for example: 0 represents the account type Normal
.
account_name
: Account name-for example: "SiCongsaccount" .
owner_address
: The address of the contract holder-for example: "0xu82h...7237" .
message AccountCreateContract {
AccountType type = 1;
bytes account_name = 2;
bytes owner_address = 3;
}
AccountUpdateContract
Contains 2 kinds of parameters::
account_name
Account name-for example: "SiCongsaccount" .
owner_address
: The address of the contract holder-for example: "0xu82h...7237" .
message AccountUpdateContract {
bytes account_name = 1;
bytes owner_address = 2;
}
TransferContract
Contains 3 kinds of parameters::
amount
XLT number-for example: 12534 .
to_address
: Recipient's address-for example: "0xu82h...7237" .
owner_address
: The address of the contract holder-for example: "0xu82h...7237" .
message TransferContract {
bytes owner_address = 1;
bytes to_address = 2;
int64 amount = 3;
}
TransferAssetContract
Contains 4 kinds of parameters::
asset_name
Asset name-for example: "SiCongsaccount" .
to_address
: Recipient's address-for example: "0xu82h...7237" .
owner_address
: The address of the contract holder-for example: "0xu82h...7237" .
amount
: The number of target assets-for example: 12353 .
message TransferAssetContract {
bytes asset_name = 1;
bytes owner_address = 2;
bytes to_address = 3;
int64 amount = 4;
}
VoteAssetContract
Contains 4 kinds of parameters::
vote_address
Voter address-for example: "0xu82h...7237" .
support
: Vote for or not-for example: true .
owner_address
: The address of the contract holder-for example: "0xu82h...7237" .
count
: The number of votes-for example: 2324234 .
message VoteAssetContract {
bytes owner_address = 1;
repeated bytes vote_address = 2;
bool support = 3;
int32 count = 5;
}
VoteWitnessContract
Contains 4 kinds of parameters::
vote_address
Voter address-for example: "0xu82h...7237" .
support
: Vote for or not-for example: true .
owner_address
: The address of the contract holder-for example: "0xu82h...7237" .
count
: The number of votes-for example: 32632 .
message VoteWitnessContract {
bytes owner_address = 1;
repeated bytes vote_address = 2;
bool support = 3;
int32 count = 5;
}
WitnessCreateContract
Contains 3 kinds of parameters::
private_key
The private key of the contract-for example: "0xu82h...7237" .
owner_address
: The address of the contract holder-for example: "0xu82h...7237" .
url
: The url link of the contract.
message WitnessCreateContract {
bytes owner_address = 1;
bytes private_key = 2;
bytes url = 12;
}
WitnessUpdateContract
Contains 2 kinds of parameters:: the
owner_address
address of the contract holder-for example: "0xu82h...7237" .
update_url
: The url link of the contract.
message WitnessUpdateContract {
bytes owner_address = 1;
bytes update_url = 12;
}
AssetIssueContract
Contains 11 kinds of parameters::
name
Contract name-for example: "SiCongcontract" .
total_supply
: The total number of votes in favor of the contract-for example: 100000000 .
owner_address
: The address of the contract holder-for example: "0xu82h...7237" .
xlt_num
: Corresponding to the number of XLT-for example: 232241 .
num
: The number of corresponding custom assets.
start_time
: Start time-for example: 20170312 .
end_time
: End time-for example: 20170512 .
decav_ratio
: Decay rate.
vote_score
: The score of the contract-for example: 12343 .
description
: The description of the contract-for example: "litetokensdada" .
url
: The url address link of the contract.
message AssetIssueContract {
bytes owner_address = 1;
bytes name = 2;
int64 total_supply = 4;
int32 xlt_num = 6;
int32 num = 8;
int64 start_time = 9;
int64 end_time = 10;
int32 decay_ratio = 15;
int32 vote_score = 16;
bytes description = 20;
bytes url = 21;
}
ParticipateAssetIssueContract
Contains 4 kinds of parameters:: the
owner_address
address of the contract holder-for example: "0xu82h...7237" .
to_address
: Recipient's address-for example: "0xu82h...7237" .
asset_name
: The name of the target asset.
amount
: Small part quantity.
DeployContract
Contains 2 kinds of parameters
script
:: Script.
owner_address
: The address of the contract holder-for example: "0xu82h...7237" .
message DeployContract {
bytes owner_address = 1;
bytes script = 2;
}
Message body Result
contains fee
and ret
2 parameters.
ret
: Trading results.
fee
: The cost deducted from the transaction.
code
Is ret
the type of definition, SUCCESS
and FAILED
two types.
message Result {
enum code {
SUCESS = 0;
FAILED = 1;
}
int64 fee = 1;
code ret = 2;
}
- Each transaction also contains multiple inputs and multiple outputs, as well as other related attributes. The input in the transaction, the transaction itself, and the block header all need to be signed.
Message body Transaction
comprises raw_data
and signature
.
raw_data
: Message body raw
.
signature
: The signatures of all input nodes.
raw_data
Contains 8 kinds of parameters::
type
The transaction type of the message body raw.
vin
: input value.
vout
: output value.
expiration
: Expiration time-for example: 20170312 .
data
: Data.
contract
: The contract within the transaction.
script
: Script. timestamp
: The timestamp of the message body.
Message body Contract
comprising type
and parameter
.
type
: The type of contract.
parameter
: Any parameter.
There are eight types of account AccountCreateContract
contracts: TransferContract
, TransferAssetContract
, VoteAssetContract
, VoteWitnessContract
, WitnessCreateContract
, , AssetIssueContract
and DeployContract
.
TransactionType
Including UtxoType
and ContractType
.
message Transaction {
enum TranscationType {
UtxoType = 0;
ContractType = 1;
}
message Contract {
enum ContractType {
AccountCreateContract = 0;
TransferContract = 1;
TransferAssetContract = 2;
VoteAssetContract = 3;
VoteWitnessContract = 4;
WitnessCreateContract = 5;
AssetIssueContract = 6;
DeployContract = 7;
}
ContractType type = 1;
google.protobuf.Any parameter = 2;
}
message raw {
TranscationType type = 2;
repeated TXInput vin = 5;
repeated TXOutput vout = 7;
int64 expiration = 8;
bytes data = 10;
repeated Contract contract = 11;
bytes scripts = 16;
in64 timestamp = 17;
}
raw raw_data = 1;
repeated bytes signature = 5;
}
Message body TXOutputs
from the outputs
configuration.
outputs
: TXOutput
An array of elements .
message TXOutputs {
repeated TXOutput outputs = 1;
}
Message body TXOutput
comprises value
and pubKeyHash
.
value
:output value.
pubKeyhash
: The hash of the public key.
message TXOutput {
int64 value = 1;
bytes pubKeyHash = 2;
}
Message body TXIutput
comprises raw_data
and signature
.
raw_data
: Message body raw
.
signature
: TXInput
The signature.
Message body raw
comprising txID
, vout
and pubKey
.
txID
: Transaction ID.
Vout
: The last output value.
pubkey
: Public key.
message TXInput {
message raw {
bytes txID = 1;
int64 vout = 2;
bytes pubKey = 3;
}
raw raw_data = 1;
bytes signature = 4;
}
- Inventory, the protocol involved in the transmission, is mainly used to inform the receiver of the list of transmitted data during transmission.
Inventory
Including type
and ids
.
type
: Listing type - for example: 0 representatives XLT
.
ids
: The item ID in the list.
InventoryType
Contains XLT
and BLOCK
.
XLT
:transaction.
BLOCK
: Block.
// Inventory
message Inventory {
enum InventoryType {
XLT = 0;
BLOCK = 1;
}
InventoryType type = 1;
repeated bytes ids = 2;
}
Message body Items
contains four types of parameters:
type
: Item Type - for example: 1 representatives XLT
.
blocks
: The block in the item.
blockheaders
: Block header.
transactions
:transaction.
Items
There are four types, namely, ERR
, XLT
, BLOCK
and BLOCKHEADER
.
ERR
:error.
XLT
:transaction.
BLOCK
: Block.
BLOCKHEADER
: Block header.
message Items {
enum ItemType {
ERR = 0;
XLT = 1;
BLOCK = 2;
BLOCKHEADER = 3;
}
ItemType type = 1;
repeated Block blocks = 2;
repeated BlockHeader block_headers = 3;
repeated Transaction transactions = 4;
}
Inventory
Contains type
and items
.
type
: List type.
items
: List of lists.
message InventoryItems {
int32 type = 1;
repeated bytes items = 2;
}
Message body BlockInventory
contains type
.
type
: List type.
There are three types: SYNC
, ADVTISE
, FETCH
.
// Inventory
message BlockInventory {
enum Type {
SYNC = 0;
ADVTISE = 1;
FETCH = 2;
}
Message body BlockId
comprises ids
and type
.
ids
: Block identity information.
type
: Block type.
ids
Contains 2 kinds of parameters::
hash
The hash value of the block.
number
: The hash value and block height are the current block number.
message BlockId {
bytes hash = 1;
int64 number = 2;
}
repeated BlockId ids = 1;
Type type = 2;
}
ReasonCode
There are 15 possible reasons for disconnection:
REQUESTED
TCP_ERROR
BAD_PROTOCOL
USELESS_PEER
TOO_MANY_PEERS
DUPLICATE_PEER
INCOMPATIBLE_PROTOCOL
NULL_IDENTITY
PEER_QUITING
UNEXPECTED_IDENTITY
LOCAL_IDENTITY
PING_TIMEOU
USER_REASON
RESET
UNKNOWN
enum ReasonCode {
REQUESTED = 0;
TCP_ERROR = 1;
BAD_PROTOCOL = 2;
USELESS_PEER = 3;
TOO_MANY_PEERS = 4;
DUPLICATE_PEER = 5;
INCOMPATIBLE_PROTOCOL = 6;
NULL_IDENTITY = 7;
PEER_QUITING = 8;
UNEXPECTED_IDENTITY = 9;
LOCAL_IDENTITY = 10;
PING_TIMEOUT = 11;
USER_REASON = 12;
RESET = 16;
UNKNOWN = 255;
}
The message body DisconnectMessage
contains reason
.
DisconnectMessage
: Disconnect yes message.
reason
: The reason when disconnected.
The message body HelloMessage
contains 2 parameters:
from
Please: request the node to establish the connection.
version
: The node to establish the connection.
- Wallet service RPC and blockchain browser.
Wallet
The wallet service contains multiple RPCs.
Getbalance
: Take parameters Account
and return the object Account
.
CreatTransaction
: Take parameters TransferContract
and return the object Transaction
.
BroadcastTransaction
: Take parameters Transaction
and return the object Return
.
CreateAccount
: Take parameters AccountCreateContract
and return the object Transaction
.
CreatAssetIssue
: Take parameters AssetIssueContract
and return the object Transaction
.
ListAccounts
: Take parameters EmptyMessage
and return the object AccountList
.
UpdateAccount
: Take parameters AccountUpdateContract
and return the object Transaction
.
VoteWitnessAccount
: Take parameters VoteWitnessContract
and return the object Transaction
.
WitnessList
: Take parameters EmptyMessage
and return the object WitnessList
.
UpdateWitness
: Take parameters WitnessUpdateContract
and return the object Transaction
.
CreateWitness
: Take parameters WitnessCreateContract
and return the object Transaction
.
TransferAsset
: Take parameters TransferAssetContract
and return the object Transaction
.
ParticipateAssetIssue
: Take parameters ParticipateAssetIssueContract
and return the object Transaction
.
ListNodes
: Take parameters EmptyMessage
and return the object NodeList
.
GetAssetIssueList
: Take parameters EmptyMessage
and return the object GetIssueList
.
GetAssetIssueByAccount
: Take parameters Account
and return the object AssetIssueList
.
GetAssetIssueByName
: Adopt parametersBytesMessage
, Return the object AssetIssueContract
.
GetNowBlock
: Take parameters EmptyMessage
and return the object Block
.
GetBlockByNum
: Take parameters NumberMessage
and return the object Block
.
TotalTransaction
: Take parameters EmptyMessage
and return the object NumberMessage
.
service Wallet {
rpc GetAccount (Account) returns (Account) {
option (google.api.http) = {
post: "/wallet/getaccount"
body: "*"
};
};
rpc CreateTransaction (TransferContract) returns (Transaction) {
option (google.api.http) = {
post: "/wallet/createtransaction"
body: "*"
};
};
rpc BroadcastTransaction (Transaction) returns (Return) {
option (google.api.http) = {
post: "/wallet/broadcasttransaction"
body: "*"
};
};
rpc ListAccounts (EmptyMessage) returns (AccountList) {
option (google.api.http) = {
post: "/wallet/listaccount"
body: "*"
};
};
rpc UpdateAccount (AccountUpdateContract) returns (Transaction) {
option (google.api.http) = {
post: "/wallet/updateaccount"
body: "*"
};
};
rpc CreateAccount (AccountCreateContract) returns (Transaction) {
option (google.api.http) = {
post: "/wallet/createaccount"
body: "*"
};
};
rpc VoteWitnessAccount (VoteWitnessContract) returns (Transaction) {
option (google.api.http) = {
post: "/wallet/votewitnessaccount"
body: "*"
};
};
rpc CreateAssetIssue (AssetIssueContract) returns (Transaction) {
option (google.api.http) = {
post: "/wallet/createassetissue"
body: "*"
};
};
rpc ListWitnesses (EmptyMessage) returns (WitnessList) {
option (google.api.http) = {
post: "/wallet/listwitnesses"
body: "*"
};
};
rpc UpdateWitness (WitnessUpdateContract) returns (Transaction) {
option (google.api.http) = {
post: "/wallet/updatewitness"
body: "*"
};
};
rpc CreateWitness (WitnessCreateContract) returns (Transaction) {
option (google.api.http) = {
post: "/wallet/createwitness"
body: "*"
};
};
rpc TransferAsset (TransferAssetContract) returns (Transaction) {
option (google.api.http) = {
post: "/wallet/transferasset"
body: "*"
};
}
rpc ParticipateAssetIssue (ParticipateAssetIssueContract) returns (Transaction) {
option (google.api.http) = {
post: "/wallet/participateassetissue"
body: "*"
};
}
rpc ListNodes (EmptyMessage) returns (NodeList) {
option (google.api.http) = {
post: "/wallet/listnodes"
body: "*"
};
}
rpc GetAssetIssueList (EmptyMessage) returns (AssetIssueList) {
option (google.api.http) = {
post: "/wallet/getassetissuelist"
body: "*"
};
}
rpc GetAssetIssueByAccount (Account) returns (AssetIssueList) {
option (google.api.http) = {
post: "/wallet/getassetissuebyaccount"
body: "*"
};
}
rpc GetAssetIssueByName (BytesMessage) returns (AssetIssueContract) {
option (google.api.http) = {
post: "/wallet/getassetissuebyname"
body: "*"
};
}
rpc GetNowBlock (EmptyMessage) returns (Block) {
option (google.api.http) = {
post: "/wallet/getnowblock"
body: "*"
};
}
rpc GetBlockByNum (NumberMessage) returns (Block) {
option (google.api.http) = {
post: "/wallet/getblockbynum"
body: "*"
};
}
rpc TotalTransaction (EmptyMessage) returns (NumberMessage) {
option (google.api.http) = {
post: "/wallet/totaltransaction"
body: "*"
};
}
};
WalletSolidity
The wallet service contains multiple RPCs.
GetAccount
: Take parameters Account
and return the object Account
.
ListAccounts
: Take parameters EmptyMessage
and return the object AccountList
.
ListWitness
: Take parameters EmptyMessage
and return the object WitnessList
.
ListNodes
: Take parameters EmptyMessage
and return the object NodeList
.
GetAssetIssueList
: Take parameters EmptyMessage
and return the object AssetIssueList
.
GetAssetIssueByTimeStamp
: Take parameters NumberMessage
and return the object AssetIssueList
.
GetAssetIssueByAccount
: Using parameters Account
, return the object to AssetIssueList
obtain issued assets.
GetAssetIssueByName
: Take parameters BytesMessage
and return the object AssetIssueContract
.
GetNowBlock
: Take parameters EmptyMessage
and return the object AssetIssueList
.
GetBlockByNum
: Take parameters EmptyMessage
and return the object Block
.
TotalTransaction
: Take parameters EmptyMessage
and return the object NumberMessage
.
getTransactionById
: Take parameters EmptyMessage
and return the object Transaction
.
getTransactionInfoById
: Take parameters BytesMessage
and return the object Transaction
.
getTransactionsByTimestamp
: Take parameters TimeMessage
and return the object Transactionlist
.
getTransactionsFromThis
: Take parameters Account
and return the object Transactionlist
.
getTransactionsToThis
: Take parameters Account
and return the object NumberMessage
.
service WalletSolidity {
rpc GetAccount (Account) returns (Account) {
};
rpc ListAccounts (EmptyMessage) returns (AccountList) {
};
rpc ListWitnesses (EmptyMessage) returns (WitnessList) {
};
rpc ListNodes (EmptyMessage) returns (NodeList) {
}
rpc GetAssetIssueList (EmptyMessage) returns (AssetIssueList) {
}
rpc GetAssetIssueListByTimestamp (NumberMessage) returns (AssetIssueList) {
}
rpc GetAssetIssueByAccount (Account) returns (AssetIssueList) {
}
rpc GetAssetIssueByName (BytesMessage) returns (AssetIssueContract) {
}
rpc GetNowBlock (EmptyMessage) returns (Block) {
}
rpc GetBlockByNum (NumberMessage) returns (Block) {
}
//获取交易。
rpc TotalTransaction (EmptyMessage) returns (NumberMessage) {
}
rpc getTransactionById (BytesMessage) returns (Transaction) {
}
rpc getTransactionsByTimestamp (TimeMessage) returns (TransactionList) {
}
rpc getTransactionsFromThis (Account) returns (TransactionList) {
}
rpc getTransactionsToThis (Account) returns (NumberMessage) {
}
};
Address
: Node address.
The message body Address
contains 2 parameters
host
:: the node owner.
port
: The port number of the node.
message Address {
bytes host = 1;
int32 port = 2;
}
The message body Return
only contains one parameter
result
:: Boolean table type flag bit.
message `Return` {
bool result = 1;
}
- Network UDP message structure.
Endpoint
: Node information storage structure in the network. The
message body Endpoint
contains 3 parameters
address
:: Node address.
port
:The port number.
nodeId
: Node ID information.
message Endpoint {
bytes address = 1;
int32 port = 2;
bytes nodeId = 3;
}
PingMessage
: The message sent when the node establishes a connection.
The message body PingMessage
contains 4 parameters::
from
the node the message comes from.
to
: The node where the message is sent.
version
: Network version.
timestamp
: The timestamp when the message was created.
message PingMessage {
Endpoint from = 1;
Endpoint to = 2;
int32 version = 3;
int64 timestamp = 4;
}
PongMessage
: Reply message when the connection is established successfully.
The message body PongMessage
contains 3 parameters::
from
The node the message comes from.
echo
::
timestamp
The timestamp when the message was created.
message PongMessage {
Endpoint from = 1;
int32 echo = 2;
int64 timestamp = 3;
}
FindNeighbours
: The message sent when a node queries neighboring nodes.
The message body FindNeighbours
contains 3 parameters::
from
The node the message comes from.
targetId
: The information of the target node.
timestamp
: The timestamp when the message was created.
message FindNeighbours {
Endpoint from = 1;
bytes targetId = 2;
int64 timestamp = 3;
}
Neighbour
: Adjacent contact reply message.
The message body Neighbours
contains 3 parameters::
from
The node the message comes from.
neighbours
: Adjacent nodes.
timestamp
: The timestamp when the message was created.
message Neighbours {
Endpoint from = 1;
repeated Endpoint neighbours = 2;
int64 timestamp = 3;
}