-
Notifications
You must be signed in to change notification settings - Fork 203
/
Copy pathrpc.proto
672 lines (523 loc) · 15.2 KB
/
rpc.proto
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
// Copyright (C) 2017 go-nebulas authors
//
// This file is part of the go-nebulas library.
//
// the go-nebulas library 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.
//
// the go-nebulas library 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 the go-nebulas library. If not, see <http://www.gnu.org/licenses/>.
//
//The protobuf golang code is generated with protoc-gen-gogo v1.0.0
syntax = "proto3";
import "google/api/annotations.proto";
import "github.com/nebulasio/go-nebulas/consensus/pb/state.proto";
import "github.com/nebulasio/go-nebulas/core/pb/block.proto";
import "github.com/nebulasio/go-nebulas/neblet/pb/config.proto";
package rpcpb;
// RPC API interface.
service ApiService {
// Return the state of the neb.
rpc GetNebState (NonParamsRequest) returns (GetNebStateResponse) {
option (google.api.http) = {
get: "/v1/user/nebstate"
};
}
// Return the latest irreversible block.
rpc LatestIrreversibleBlock (NonParamsRequest) returns (BlockResponse) {
option (google.api.http) = {
get: "/v1/user/lib"
};
}
// Return the state of the account.
rpc GetAccountState (GetAccountStateRequest) returns (GetAccountStateResponse) {
option (google.api.http) = {
post: "/v1/user/accountstate"
body: "*"
};
}
// Call transaction
rpc Call (TransactionRequest) returns (CallResponse) {
option (google.api.http) = {
post: "/v1/user/call"
body: "*"
};
}
// Submit the signed transaction.
rpc SendRawTransaction (SendRawTransactionRequest) returns (SendTransactionResponse) {
option (google.api.http) = {
post: "/v1/user/rawtransaction"
body: "*"
};
}
// Get block info by the block hash.
rpc GetBlockByHash (GetBlockByHashRequest) returns (BlockResponse) {
option (google.api.http) = {
post: "/v1/user/getBlockByHash"
body: "*"
};
}
// Get block info by the block height.
rpc GetBlockByHeight (GetBlockByHeightRequest) returns (BlockResponse) {
option (google.api.http) = {
post: "/v1/user/getBlockByHeight"
body: "*"
};
}
// Get transactionReceipt info by tansaction hash.
rpc GetTransactionReceipt (GetTransactionByHashRequest) returns (TransactionResponse) {
option (google.api.http) = {
post: "/v1/user/getTransactionReceipt"
body: "*"
};
}
// Get transactionReceipt info by tansaction hash.
rpc GetTransactionByContract (GetTransactionByContractRequest) returns (TransactionResponse) {
option (google.api.http) = {
post: "/v1/user/getTransactionByContract"
body: "*"
};
}
// Subscribe message
rpc Subscribe(SubscribeRequest) returns (stream SubscribeResponse) {
option (google.api.http) = {
post: "/v1/user/subscribe"
body: "*"
};
}
// Get GasPrice
rpc GetGasPrice(NonParamsRequest) returns (GasPriceResponse) {
option (google.api.http) = {
get: "/v1/user/getGasPrice"
};
}
// EstimateGas
rpc EstimateGas(TransactionRequest) returns (GasResponse) {
option (google.api.http) = {
post: "/v1/user/estimateGas"
body: "*"
};
}
rpc GetEventsByHash(HashRequest) returns (EventsResponse) {
option (google.api.http) = {
post: "/v1/user/getEventsByHash"
body: "*"
};
}
rpc GetDynasty (ByBlockHeightRequest) returns (GetDynastyResponse) {
option (google.api.http) = {
post: "/v1/user/dynasty"
body: "*"
};
}
// Verify Signature.
rpc VerifySignature (VerifySignatureRequest) returns (VerifySignatureResponse) {
option (google.api.http) = {
post: "/v1/user/verifySignature"
body: "*"
};
}
}
service AdminService {
// Accounts return account list.
rpc Accounts (NonParamsRequest) returns (AccountsResponse) {
option (google.api.http) = {
get: "/v1/admin/accounts"
};
}
// NewAccount create a new account with passphrase
rpc NewAccount(NewAccountRequest) returns (NewAccountResponse) {
option (google.api.http) = {
post: "/v1/admin/account/new"
body: "*"
};
}
// UnlockAccount unlock account with passphrase
rpc UnlockAccount(UnlockAccountRequest) returns (UnlockAccountResponse) {
option (google.api.http) = {
post: "/v1/admin/account/unlock"
body: "*"
};
}
// LockAccount lock account
rpc LockAccount(LockAccountRequest) returns (LockAccountResponse) {
option (google.api.http) = {
post: "/v1/admin/account/lock"
body: "*"
};
}
// Verify, sign, and send the transaction.
rpc SendTransaction (TransactionRequest) returns (SendTransactionResponse) {
option (google.api.http) = {
post: "/v1/admin/transaction"
body: "*"
};
}
// Sign sign msg
rpc SignHash(SignHashRequest) returns (SignHashResponse) {
option (google.api.http) = {
post: "/v1/admin/sign/hash"
body: "*"
};
}
rpc GenerateRandomSeed(GenerateRandomSeedRequest) returns (GenerateRandomSeedResponse) {
option (google.api.http) = {
post: "/v1/admin/generateRandomSeed"
body: "*"
};
}
// Sign sign transaction
rpc SignTransactionWithPassphrase(SignTransactionPassphraseRequest) returns (SignTransactionPassphraseResponse) {
option (google.api.http) = {
post: "/v1/admin/sign"
body: "*"
};
}
// SendTransactionWithPassphrase send transaction with passphrase
rpc SendTransactionWithPassphrase(SendTransactionPassphraseRequest) returns (SendTransactionResponse) {
option (google.api.http) = {
post: "/v1/admin/transactionWithPassphrase"
body: "*"
};
}
rpc StartPprof (PprofRequest) returns (PprofResponse) {
option (google.api.http) = {
post: "/v1/admin/pprof"
body: "*"
};
}
//Get Config
rpc GetConfig (NonParamsRequest) returns (GetConfigResponse) {
option (google.api.http) = {
get: "/v1/admin/getConfig"
};
}
// Return the p2p node info.
rpc NodeInfo (NonParamsRequest) returns (NodeInfoResponse) {
option (google.api.http) = {
get: "/v1/admin/nodeinfo"
};
}
}
// Request message of Subscribe rpc
message SubscribeRequest {
repeated string topics = 1;
}
// Request message of Subscribe rpc
message SubscribeResponse {
string topic = 1;
string data = 2;
}
// Request message of non params.
message NonParamsRequest {
}
// Response message of node info.
message NodeInfoResponse {
// the node ID.
string id = 1;
// the block chainID.
uint32 chain_id = 2;
// coinbase
string coinbase = 3;
// Number of peers currenly connected.
uint32 peer_count = 4;
// the node synchronized status.
bool synchronized = 5;
// the node route table bucket size.
int32 bucket_size = 6;
// the network protocol version.
string protocol_version = 10;
repeated RouteTable route_table = 11;
}
message RouteTable {
string id = 1;
repeated string address = 2;
}
// Response message of GetNebState rpc.
message GetNebStateResponse {
// Block chain id
uint32 chain_id = 1;
// Current neb tail hash
string tail = 2;
// Current neb lib hash
string lib = 3;
// Current neb tail block height
uint64 height = 4;
// The current neb protocol version.
string protocol_version = 6;
// The peer sync status.
bool synchronized = 7;
// neb version
string version = 8;
}
// Response message of Accounts rpc.
message AccountsResponse {
// Account list
repeated string addresses = 1;
}
// Request message of GetAccountState rpc.
message GetAccountStateRequest {
// Hex string of the account addresss.
string address = 1;
// block account state with height. If not specified, use 0 as tail height.
uint64 height = 2;
}
// Response message of GetAccountState rpc.
message GetAccountStateResponse {
// Current balance in unit of 1/(10^18) nas.
string balance = 1; // uint128, len=16
// Current transaction count.
uint64 nonce = 2;
// Account type
uint32 type = 3;
}
// Response message of Call rpc.
message CallResponse {
// result of smart contract method call.
string result = 1;
//execute error
string execute_err = 2;
//estimate gas used
string estimate_gas = 3;
}
// ByBlockHeightRequest message
message ByBlockHeightRequest {
uint64 height = 1;
}
// Response message of GetDynastyRequest rpc
message GetDynastyResponse {
repeated string miners = 1;
}
// Request message of SendTransaction rpc.
message TransactionRequest {
// Hex string of the sender account addresss.
string from = 1;
// Hex string of the receiver account addresss.
string to = 2;
// Amount of value sending with this transaction.
string value = 3; // uint128, len=16
// Transaction nonce.
uint64 nonce = 4;
// gasPrice sending with this transaction.
string gas_price = 5; // uint128, len=16
// gasLimit sending with this transaction.
string gas_limit = 6; // uint128, len=16
// contract sending with this transaction
ContractRequest contract = 7;
// binary data for transaction
bytes binary = 10;
// transaction payload type, enum:binary, deploy, call
string type = 20;
}
message ContractRequest {
// contract source code.
string source = 1;
// contract source type, support javascript and typescript
string source_type = 2;
// call contract function name
string function = 3;
// the params of contract.
string args = 4;
}
// Request message of SendRawTransactionRequest rpc.
message SendRawTransactionRequest {
// Signed data of transaction
bytes data = 1;
}
// Response message of SendTransaction rpc.
message SendTransactionResponse {
// Hex string of transaction hash.
string txhash = 1;
// Hex string of contract address if transaction is deploy type
string contract_address = 2;
}
// Request message of GetBlockByHash rpc.
message GetBlockByHashRequest {
// Hex string of block hash.
string hash = 1;
// If true it returns the full transaction objects, if false only the hashes of the transactions.
bool full_fill_transaction = 2;
}
// Request message of GetBlockByHeight rpc.
message GetBlockByHeightRequest {
// block height.
uint64 height = 1;
// If true it returns the full transaction objects, if false only the hashes of the transactions.
bool full_fill_transaction = 2;
}
// Request message of GetTransactionByHash rpc.
message GetTransactionByHashRequest {
// Hex string of transaction hash.
string hash = 1;
}
// Request message of GetTransactionByContract rpc.
message GetTransactionByContractRequest {
// string of contract address.
string address = 1;
}
// Response message of Block.
message BlockResponse {
// Hex string of block hash.
string hash = 1;
// Hex string of block parent hash.
string parent_hash = 2;
// block height
uint64 height = 3;
// block nonce
uint64 nonce = 4;
// Hex string of coinbase address.
string coinbase = 5;
// block timestamp.
int64 timestamp = 6;
// block chain id
uint32 chain_id = 7;
// Hex string of state root.
string state_root = 8;
// Hex string of txs root.
string txs_root = 9;
// Hex string of event root.
string events_root = 10;
// Hex string of consensus root.
consensuspb.ConsensusRoot consensus_root = 11;
// Miner
string miner = 12;
// Random seed
string randomSeed = 13;
// Random proof
string randomProof = 14;
// is finaliy
bool is_finality = 15;
// transaction slice
repeated TransactionResponse transactions = 100;
}
// Response message of TransactionReceipt.
message TransactionResponse {
// Hex string of tx hash.
string hash = 1;
uint32 chainId = 2;
// Hex string of the sender account addresss.
string from = 3;
// Hex string of the receiver account addresss.
string to = 4;
string value = 5;
// Transaction nonce.
uint64 nonce = 6;
int64 timestamp = 7;
string type = 8;
bytes data = 9;
string gas_price = 10;
string gas_limit = 11;
string contract_address = 12;
// transaction status 0 failed, 1 success, 2 pending
int32 status = 13;
// transaction gas used
string gas_used = 14;
// contract execute error
string execute_error = 15;
// contract execute result
string execute_result = 16;
}
message NewAccountRequest {
string passphrase = 1;
}
message NewAccountResponse {
string address = 1;
}
message UnlockAccountRequest {
string address = 1;
string passphrase = 2;
uint64 duration = 3;
}
message UnlockAccountResponse {
bool result = 1;
}
message LockAccountRequest {
string address = 1;
}
message LockAccountResponse {
bool result = 1;
}
message SignHashRequest {
// sign address
string address = 1;
// sign msg
bytes hash = 2;
// sign algorithm
uint32 alg = 3;
}
message SignHashResponse {
bytes data = 1;
}
message GenerateRandomSeedRequest {
// miner address
string address = 1;
// parent seed of new block
bytes parent_seed = 2;
// hash of new block's ancestor
bytes ancestor_hash = 3;
}
message GenerateRandomSeedResponse {
bytes vrf_seed = 1;
bytes vrf_proof = 2;
}
message SignTransactionPassphraseRequest {
// transaction struct
TransactionRequest transaction = 1;
// from account passphrase
string passphrase = 2;
}
message SignTransactionPassphraseResponse {
bytes data = 1;
}
message SendTransactionPassphraseRequest {
// transaction struct
TransactionRequest transaction = 1;
// from account passphrase
string passphrase = 2;
}
message GasPriceResponse {
string gas_price = 1;
}
// Request message of GetTransactionByHash rpc.
message HashRequest {
// Hex string of block/transaction hash.
string hash = 1;
}
message GasResponse {
string gas = 1;
string err = 2;
}
message EventsResponse {
repeated Event events = 1;
}
message Event {
string topic = 1;
string data = 2;
}
message PprofRequest {
string listen = 1;
}
message PprofResponse {
bool result = 1;
}
message GetConfigResponse {
// Config
nebletpb.Config config = 1;
}
message VerifySignatureRequest {
string msg = 1;
string signature = 2;
string address = 3;
uint32 alg = 4;
}
message VerifySignatureResponse {
bool result = 1;
string address = 2;
}