-
Notifications
You must be signed in to change notification settings - Fork 3
/
types.go
483 lines (418 loc) · 13.1 KB
/
types.go
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
// Copyright Fuzamei Corp. 2018 All Rights Reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Package types rpc相关的一些结构体定义以及转化函数
package types
import (
"encoding/json"
_ "github.com/assetcloud/chain/system/address" // init address
)
// TransParm transport parameter
type TransParm struct {
Execer string `json:"execer"`
Payload string `json:"payload"`
Signature *Signature `json:"signature"`
Fee int64 `json:"fee"`
}
// SignedTx signature tx
type SignedTx struct {
Unsign string `json:"unsignTx"`
Sign string `json:"sign"`
Pubkey string `json:"pubkey"`
Ty int32 `json:"ty"`
}
// RawParm defines raw parameter command
type RawParm struct {
Token string `json:"token"`
Data string `json:"data"`
}
// QueryParm Query parameter
type QueryParm struct {
Hash string `json:"hash"`
}
// BlockParam block parameter
type BlockParam struct {
Start int64 `json:"start"`
End int64 `json:"end"`
Isdetail bool `json:"isDetail"`
}
// Header header parameter
type Header struct {
Version int64 `json:"version"`
ParentHash string `json:"parentHash"`
TxHash string `json:"txHash"`
StateHash string `json:"stateHash"`
Height int64 `json:"height"`
BlockTime int64 `json:"blockTime"`
TxCount int64 `json:"txCount"`
Hash string `json:"hash"`
Difficulty uint32 `json:"difficulty"`
Signature *Signature `json:"signature,omitempty"`
}
// Signature parameter
type Signature struct {
Ty int32 `json:"ty"`
Pubkey string `json:"pubkey"`
Signature string `json:"signature"`
}
// Transaction parameter
type Transaction struct {
Execer string `json:"execer"`
Payload json.RawMessage `json:"payload"`
RawPayload string `json:"rawPayload"`
Signature *Signature `json:"signature"`
Fee int64 `json:"fee"`
FeeFmt string `json:"feefmt"`
Expire int64 `json:"expire"`
Nonce int64 `json:"nonce"`
From string `json:"from,omitempty"`
To string `json:"to"`
Amount int64 `json:"amount,omitempty"`
AmountFmt string `json:"amountfmt,omitempty"`
GroupCount int32 `json:"groupCount,omitempty"`
Header string `json:"header,omitempty"`
Next string `json:"next,omitempty"`
Hash string `json:"hash,omitempty"`
ChainID int32 `json:"chainID,omitempty"`
}
// ReceiptLog defines receipt log command
type ReceiptLog struct {
Ty int32 `json:"ty"`
Log string `json:"log"`
}
// ReceiptData defines receipt data rpc command
type ReceiptData struct {
Ty int32 `json:"ty"`
Logs []*ReceiptLog `json:"logs"`
}
// ReceiptDataResult receipt data result
type ReceiptDataResult struct {
Ty int32 `json:"ty"`
TyName string `json:"tyName"`
Logs []*ReceiptLogResult `json:"logs"`
}
// ReceiptLogResult receipt log result
type ReceiptLogResult struct {
Ty int32 `json:"ty"`
TyName string `json:"tyName"`
Log json.RawMessage `json:"log"`
RawLog string `json:"rawLog"`
}
// Block block information
type Block struct {
Version int64 `json:"version"`
ParentHash string `json:"parentHash"`
TxHash string `json:"txHash"`
StateHash string `json:"stateHash"`
Height int64 `json:"height"`
BlockTime int64 `json:"blockTime"`
Txs []*Transaction `json:"txs"`
Difficulty uint32 ` json:"difficulty,omitempty"`
MainHash string ` json:"mainHash,omitempty"`
MainHeight int64 `json:"mainHeight,omitempty"`
Signature *Signature `json:"signature,omitempty"`
}
// BlockDetail block detail
type BlockDetail struct {
Block *Block `json:"block"`
Receipts []*ReceiptDataResult `json:"recipts"`
}
// BlockDetails block details
type BlockDetails struct {
Items []*BlockDetail `json:"items"`
}
// Asset asset
type Asset struct {
Exec string `json:"exec"`
Symbol string `json:"symbol"`
Amount int64 `json:"amount"`
}
// TransactionDetail transaction detail
type TransactionDetail struct {
Tx *Transaction `json:"tx"`
Receipt *ReceiptDataResult `json:"receipt"`
Proofs []string `json:"proofs"`
Height int64 `json:"height"`
Index int64 `json:"index"`
Blocktime int64 `json:"blockTime"`
Amount int64 `json:"amount"`
Fromaddr string `json:"fromAddr"`
ActionName string `json:"actionName"`
Assets []*Asset `json:"assets"`
TxProofs []*TxProof `json:"txProofs"`
FullHash string `json:"fullHash"`
}
// TxProof :
type TxProof struct {
Proofs []string `json:"proofs"`
Index uint32 `json:"index"`
RootHash string `json:"rootHash"`
}
// ReplyTxInfos reply tx infos
type ReplyTxInfos struct {
TxInfos []*ReplyTxInfo `json:"txInfos"`
}
// ReplyTxInfo reply tx information
type ReplyTxInfo struct {
Hash string `json:"hash"`
Height int64 `json:"height"`
Index int64 `json:"index"`
Assets []*Asset `json:"assets"`
}
// TransactionDetails transaction details
type TransactionDetails struct {
//Txs []*Transaction `json:"txs"`
Txs []*TransactionDetail `json:"txs"`
}
// ReplyTxList reply tx list
type ReplyTxList struct {
Txs []*Transaction `json:"txs"`
}
// ReplyProperFee reply proper fee
type ReplyProperFee struct {
ProperFee int64 `json:"properFee"`
}
// ReplyHash reply hash string json
type ReplyHash struct {
Hash string `json:"hash"`
}
// ReplyHashes reply hashes
type ReplyHashes struct {
Hashes []string `json:"hashes"`
}
// PeerList peer list
type PeerList struct {
Peers []*Peer `json:"peers"`
}
// Peer information
type Peer struct {
Addr string `json:"addr"`
Port int32 `json:"port"`
Name string `json:"name"`
MempoolSize int32 `json:"mempoolSize"`
Self bool `json:"self"`
Header *Header `json:"header"`
Version string `json:"version,omitempty"`
LocalDBVersion string `json:"localDBVersion,omitempty"`
StoreDBVersion string `json:"storeDBVersion,omitempty"`
RunningTime string `json:"runningTime,omitempty"`
FullNode bool `json:"fullNode,omitempty"`
Blocked bool `json:"blocked,omitempty"`
}
// WalletAccounts Wallet Module
type WalletAccounts struct {
Wallets []*WalletAccount `json:"wallets"`
}
// WalletAccount wallet account
type WalletAccount struct {
Acc *Account `json:"acc"`
Label string `json:"label"`
}
// Account account information
type Account struct {
Currency int32 `json:"currency"`
Balance int64 `json:"balance"`
Frozen int64 `json:"frozen"`
Addr string `json:"addr"`
}
// Reply info
type Reply struct {
IsOk bool `json:"isOK"`
Msg string `json:"msg"`
}
// Headers defines headers rpc command
type Headers struct {
Items []*Header `json:"items"`
}
// ReqAddr require address
type ReqAddr struct {
Addr string `json:"addr"`
}
// ReqStrings require strings
type ReqStrings struct {
Datas []string `json:"datas"`
}
// ReqHashes require hashes
type ReqHashes struct {
Hashes []string `json:"hashes"`
DisableDetail bool `json:"disableDetail"`
}
// ReqWalletTransactionList require wallet transaction list
type ReqWalletTransactionList struct {
FromTx string `json:"fromTx"`
Count int32 `json:"count"`
Direction int32 `json:"direction"`
}
// WalletTxDetails wallet tx details
type WalletTxDetails struct {
TxDetails []*WalletTxDetail `json:"txDetails"`
}
// WalletTxDetail wallet tx detail
type WalletTxDetail struct {
Tx *Transaction `json:"tx"`
Receipt *ReceiptDataResult `json:"receipt"`
Height int64 `json:"height"`
Index int64 `json:"index"`
BlockTime int64 `json:"blockTime"`
Amount int64 `json:"amount"`
FromAddr string `json:"fromAddr"`
TxHash string `json:"txHash"`
ActionName string `json:"actionName"`
}
// BlockOverview block overview
type BlockOverview struct {
Head *Header `json:"head"`
TxCount int64 `json:"txCount"`
TxHashes []string `json:"txHashes"`
}
// Query4Jrpc query jrpc
type Query4Jrpc struct {
Execer string `json:"execer"`
FuncName string `json:"funcName"`
Payload json.RawMessage `json:"payload"`
}
// ChainExecutor chain executor
type ChainExecutor struct {
Driver string `json:"execer"`
FuncName string `json:"funcName"`
StateHash string `json:"stateHash"`
Payload json.RawMessage `json:"payload"`
}
// WalletStatus wallet status
type WalletStatus struct {
IsWalletLock bool `json:"isWalletLock"`
IsAutoMining bool `json:"isAutoMining"`
IsHasSeed bool `json:"isHasSeed"`
IsTicketLock bool `json:"isTicketLock"`
}
// NodeNetinfo node net info
type NodeNetinfo struct {
Externaladdr string `json:"externalAddr"`
Localaddr string `json:"localAddr"`
Service bool `json:"service"`
Outbounds int32 `json:"outbounds"`
Inbounds int32 `json:"inbounds"`
Routingtable int32 `json:"routingtable"`
Peerstore int32 `json:"peerstore"`
Ratein string `json:"ratein"`
Rateout string `json:"rateout"`
Ratetotal string `json:"ratetotal"`
}
// ReplyCacheTxList reply cache tx list
type ReplyCacheTxList struct {
Txs []*Transaction `json:"txs,omitempty"`
}
// TimeStatus time status
type TimeStatus struct {
NtpTime string `json:"ntpTime"`
LocalTime string `json:"localTime"`
Diff int64 `json:"diff"`
}
// ReplyBlkSeqs reply block sequences
type ReplyBlkSeqs struct {
BlkSeqInfos []*ReplyBlkSeq `json:"blkseqInfos"`
}
// ReplyBlkSeq reply block sequece
type ReplyBlkSeq struct {
Hash string `json:"hash"`
Type int64 `json:"type"`
}
// CreateTxIn create tx input
type CreateTxIn struct {
Execer string `json:"execer"`
ActionName string `json:"actionName"`
Payload json.RawMessage `json:"payload"`
}
// AllExecBalance all exec balance
type AllExecBalance struct {
Addr string `json:"addr"`
ExecAccount []*ExecAccount `json:"execAccount"`
}
// ExecAccount exec account
type ExecAccount struct {
Execer string `json:"execer"`
Account *Account `json:"account"`
}
// ExecNameParm exec name parameter
type ExecNameParm struct {
ExecName string `json:"execname"`
}
// CreateTx 为了简化Note 的创建过程,在json rpc 中,note 采用string 格式
type CreateTx struct {
To string `json:"to,omitempty"`
Amount int64 `json:"amount,omitempty"`
Fee int64 `json:"fee,omitempty"`
Note string `json:"note,omitempty"`
IsWithdraw bool `json:"isWithdraw,omitempty"`
IsToken bool `json:"isToken,omitempty"`
TokenSymbol string `json:"tokenSymbol,omitempty"`
ExecName string `json:"execName,omitempty"` //TransferToExec and Withdraw 的执行器
Execer string `json:"execer,omitempty"` //执行器名称
}
// ReWriteRawTx parameter
type ReWriteRawTx struct {
Tx string `json:"tx"`
To string `json:"to"`
Fee int64 `json:"fee"`
Expire string `json:"expire"`
Index int32 `json:"index"`
}
// BlockSeq parameter
type BlockSeq struct {
Num int64 `json:"num,omitempty"`
Seq *BlockSequence `json:"seq,omitempty"`
Detail *BlockDetail `json:"detail,omitempty"`
}
// BlockSequence parameter
type BlockSequence struct {
Hash string `json:"hash,omitempty"`
Type int64 `json:"type,omitempty"`
}
// ParaTxDetails parameter
type ParaTxDetails struct {
Items []*ParaTxDetail `json:"paraTxDetail"`
}
// ParaTxDetail parameter
type ParaTxDetail struct {
Type int64 `json:"type,omitempty"`
Header *Header `json:"header,omitempty"`
TxDetails []*TxDetail `json:"txDetail,omitempty"`
ChildHash string `json:"childHash,omitempty"`
Index uint32 `json:"index,omitempty"`
Proofs []string `json:"proofs,omitempty"`
}
// TxDetail parameter
type TxDetail struct {
Index uint32 `json:"index,omitempty"`
Tx *Transaction `json:"tx,omitempty"`
Receipt *ReceiptData `json:"receipt,omitempty"`
Proofs []string `json:"proofs,omitempty"`
}
// ReplyHeightByTitle parameter
type ReplyHeightByTitle struct {
Title string `json:"title,omitempty"`
Items []*BlockInfo `json:"items,omitempty"`
}
// BlockInfo parameter
type BlockInfo struct {
Height int64 `json:"height,omitempty"`
Hash string `json:"hash,omitempty"`
}
// ChainIDInfo parameter
type ChainIDInfo struct {
ChainID int32 `json:"chainID"`
}
// ChainConfigInfo parameter
type ChainConfigInfo struct {
Title string `json:"title,omitempty"`
CoinExec string `json:"coinExec,omitempty"`
CoinSymbol string `json:"coinSymbol,omitempty"`
CoinPrecision int64 `json:"coinPrecision,omitempty"`
TokenPrecision int64 `json:"tokenPrecision,omitempty"`
ChainID int32 `json:"chainID,omitempty"`
MaxTxFee int64 `json:"maxTxFee,omitempty"`
MinTxFeeRate int64 `json:"minTxFeeRate,omitempty"`
MaxTxFeeRate int64 `json:"maxTxFeeRate,omitempty"`
IsPara bool `json:"isPara,omitempty"`
DefaultAddressID int32 `json:"defaultAddressID"`
}