/
models.go
581 lines (519 loc) · 24.4 KB
/
models.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
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
package openwsdk
import (
"encoding/base64"
"encoding/json"
"fmt"
"github.com/nbit99/openwallet/v2/crypto"
"github.com/nbit99/openwallet/v2/hdkeystore"
"github.com/nbit99/openwallet/v2/openwallet"
"github.com/tidwall/gjson"
"time"
)
type BlockHeader struct {
Hash string `json:"hash"`
Confirmations uint64 `json:"confirmations"`
Merkleroot string `json:"merkleroot"`
Previousblockhash string `json:"previousblockhash"`
Height uint64 `json:"height"`
Version uint64 `json:"version"`
Time uint64 `json:"time"`
Fork bool `json:"fork"`
Symbol string `json:"symbol"`
}
func NewBlockHeader(result gjson.Result) *BlockHeader {
obj := &BlockHeader{
Hash: result.Get("hash").String(),
Confirmations: result.Get("confirmations").Uint(),
Merkleroot: result.Get("merkleroot").String(),
Previousblockhash: result.Get("previousblockhash").String(),
Height: result.Get("height").Uint(),
Version: result.Get("version").Uint(),
Time: result.Get("time").Uint(),
Fork: result.Get("fork").Bool(),
Symbol: result.Get("symbol").String(),
}
return obj
}
type CallbackNode struct {
NodeID string `json:"nodeID"` //@required 节点ID
Address string `json:"address"` //@required 连接IP地址
ConnectType string `json:"connectType"` //@required 连接方式
EnableKeyAgreement bool `json:"enableKeyAgreement"` //是否开启owtp协议协商密码
EnableSSL bool `json:"enableSSL"` //是否开启链接SSL,https,wss
EnableSignature bool `json:"enableSignature"` //是否开启owtp协议内签名,防重放
notifierNodeID string `json:"notifierNodeID"` //通知者节点ID
}
func NewCallbackNode(result gjson.Result) *CallbackNode {
obj := &CallbackNode{
NodeID: result.Get("nodeID").String(),
Address: result.Get("address").String(),
ConnectType: result.Get("connectType").String(),
EnableKeyAgreement: result.Get("enableKeyAgreement").Bool(),
EnableSSL: result.Get("enableSSL").Bool(),
}
return obj
}
type TrustNodeInfo struct {
NodeID string `json:"nodeID"` //@required 节点ID
NodeName string `json:"nodeName"`
ConnectType string `json:"connectType"`
Version string `json:"version"`
GitRev string `json:"gitRev"`
BuildTime string `json:"buildTime"`
}
//SummarySetting 汇总设置信息
type SummarySetting struct {
WalletID string `json:"walletID"`
AccountID string `json:"accountID" storm:"id"`
SumAddress string `json:"sumAddress"`
Threshold string `json:"threshold"`
MinTransfer string `json:"minTransfer"`
RetainedBalance string `json:"retainedBalance"`
Confirms uint64 `json:"confirms"`
AddressLimit uint64 `json:"addressLimit"`
ReserveAddress string `json:"reserveAddress"`
SumToReserve bool `json:"summarizeToReserve"`
}
func NewSummarySetting(result gjson.Result) *SummarySetting {
obj := &SummarySetting{
WalletID: result.Get("walletID").String(),
AccountID: result.Get("accountID").String(),
SumAddress: result.Get("sumAddress").String(),
ReserveAddress: result.Get("reserveAddress").String(),
Threshold: result.Get("threshold").String(),
MinTransfer: result.Get("minTransfer").String(),
RetainedBalance: result.Get("retainedBalance").String(),
Confirms: result.Get("confirms").Uint(),
SumToReserve: result.Get("summarizeToReserve").Bool(),
}
return obj
}
type Wallet struct {
AppID string `json:"appID" bson:"appID"`
WalletID string `json:"walletID" bson:"walletID"`
Alias string `json:"alias" bson:"alias"`
IsTrust int64 `json:"isTrust" bson:"isTrust"`
PasswordType int64 `json:"passwordType" bson:"passwordType"`
Password string `json:"password" bson:"password"`
AuthKey string `json:"authKey" bson:"authKey"`
RootPath string `json:"rootPath" bson:"rootPath"`
AccountIndex int64 `json:"accountIndex" bson:"accountIndex"`
Keystore string `json:"keystore" bson:"keystore"`
Applytime int64 `json:"applytime" bson:"applytime"`
Dealstate int64 `json:"dealstate" bson:"dealstate"`
}
type Symbol struct {
Name string `json:"name" bson:"name" storm:"id"`
Coin string `json:"coin" bson:"coin"`
Curve int64 `json:"curve" bson:"curve"`
Orderno int64 `json:"orderno" bson:"orderno"`
Confirm int64 `json:"confirm" bson:"confirm"`
Decimals int64 `json:"decimals" bson:"decimals"`
BalanceMode uint64 `json:"balanceMode" bson:"balanceMode"`
Icon string `json:"icon"`
SupportMemo uint64 `json:"supportMemo"` //交易是否支持memo, 0: false, 1: true
OnlyContract uint64 `json:"onlyContract"` //支持合约代币, 0: false, 1: true
WithdrawStop int64 `json:"withdrawStop"`
BlockStop int64 `json:"blockStop"`
}
type Account struct {
AppID string `json:"appID" bson:"appID"`
WalletID string `json:"walletID" bson:"walletID"`
AccountID string `json:"accountID" bson:"accountID"`
Alias string `json:"alias" bson:"alias"`
Symbol string `json:"symbol" bson:"symbol"`
OtherOwnerKeys []string `json:"otherOwnerKeys" bson:"otherOwnerKeys"`
ReqSigs int64 `json:"reqSigs" bson:"reqSigs"`
IsTrust int64 `json:"isTrust" bson:"isTrust"`
Password string `json:"password" bson:"password"`
PublicKey string `json:"publicKey" bson:"publicKey"`
HdPath string `json:"hdPath" bson:"hdPath"`
ContractAddress string `json:"contractAddress" bson:"contractAddress"`
AccountIndex int64 `json:"accountIndex" bson:"accountIndex"`
Balance string `json:"balance" bson:"balance"`
ConfirmBalance string `json:"confirmBalance" bson:"confirmBalance"`
UnconfirmBalance string `json:"unconfirmBalance" bson:"unconfirmBalance"`
ExtInfo string `json:"extInfo" bson:"extInfo"`
AddressIndex int64 `json:"addressIndex" bson:"addressIndex"`
Applytime int64 `json:"applytime" bson:"applytime"`
Dealstate int64 `json:"dealstate" bson:"dealstate"`
ReuseIndex int64 `json:"reuseIndex" bson:"reuseIndex"`
}
type Address struct {
AppID string `json:"appID" bson:"appID"`
WalletID string `json:"walletID" bson:"walletID"`
AccountID string `json:"accountID" bson:"accountID"`
Alias string `json:"alias" bson:"alias"`
Symbol string `json:"symbol" bson:"symbol"`
AddrIndex int64 `json:"addrIndex" bson:"addrIndex"`
Address string `json:"address" bson:"address"`
Balance string `json:"balance" bson:"balance"`
ConfirmBalance string `json:"confirmBalance" bson:"confirmBalance"`
UnconfirmBalance string `json:"unconfirmBalance" bson:"unconfirmBalance"`
IsMemo int64 `json:"isMemo" bson:"isMemo"`
Memo string `json:"memo" bson:"memo"`
WatchOnly int64 `json:"watchOnly" bson:"watchOnly"`
PublicKey string `json:"publicKey" bson:"publicKey"`
CreatedAt int64 `json:"createdAt" bson:"createdAt"`
Num int64 `json:"num" bson:"num"`
Tag string `json:"tag" bson:"tag"`
HdPath string `json:"hdPath" bson:"hdPath"`
IsChange int64 `json:"isChange" bson:"isChange"`
Applytime int64 `json:"applytime" bson:"applytime"`
Dealstate int64 `json:"dealstate" bson:"dealstate"`
}
type TokenContract struct {
ContractID string `json:"contractID" bson:"contractID" storm:"id"`
Symbol string `json:"symbol" bson:"symbol"` //主链标记
Name string `json:"name" bson:"name"`
Decimals int64 `json:"decimals" bson:"decimals"`
Address string `json:"address" bson:"address"`
Token string `json:"token" bson:"token"` //token标记
Protocol string `json:"protocol" bson:"protocol"`
}
type Coin struct {
Symbol string `json:"symbol"`
IsContract bool `json:"isContract"`
ContractID string `json:"contractID"`
ContractAddress string `json:"contractAddress"`
ContractABI string `json:"contractABI"`
}
func NewCoin(result gjson.Result) *Coin {
obj := &Coin{
Symbol: result.Get("symbol").String(),
IsContract: result.Get("isContract").Bool(),
ContractID: result.Get("contractID").String(),
}
return obj
}
type RawTransaction struct {
Coin Coin `json:"coin"` //@required 区块链类型标识
TxID string `json:"txID"` //交易单ID,广播后会生成
Sid string `json:"sid"` //业务订单号,保证业务不重复交易而用
RawHex string `json:"rawHex"` //区块链协议构造的交易原生数据
FeeRate string `json:"feeRate"` //自定义费率
To map[string]string `json:"to"` //@required 目的地址:转账数量
AccountID string `json:"accountID"` //@required 创建交易单的账户
Signatures map[string][]*KeySignature `json:"sigParts"` //拥有者accountID: []未花签名
Required uint64 `json:"reqSigs"` //必要签名
Fees string `json:"fees"` //手续费
ErrorMsg *ErrorMsg `json:"errorMsg"`
ExtParam string `json:"extParam"`
}
type ErrorMsg struct {
Code uint64 `json:"code"`
Err string `json:"err"`
}
type KeySignature struct {
EccType uint32 `json:"eccType"` //曲线类型
RSV bool `json:"rsv"` //签名是否需要拼接V
Nonce string `json:"nonce"` //nonce
Address string `json:"address"` //提供签名的地址
Signature string `json:"signed"` //未花签名
Message string `json:"msg"` //被签消息
DerivedPath string `json:"derivedPath"` //密钥路径
WalletID string `json:"walletID"` //钱包ID
InputIndex uint32 `json:"inputIndex"` //input索引位
}
type Transaction struct {
AppID string `json:"appID" bson:"appID"`
WalletID string `json:"walletID" bson:"walletID"`
AccountID string `json:"accountID" bson:"accountID"`
Sid string `json:"sid" bson:"sid"`
Txid string `json:"txid" bson:"txid"`
Wxid string `json:"wxid" bson:"wxid"`
FromAddress []string `json:"fromAddress" bson:"fromAddress"`
FromAddressV []string `json:"fromAddressV" bson:"fromAddressV"`
ToAddress []string `json:"toAddress" bson:"toAddress"`
ToAddressV []string `json:"toAddressV" bson:"toAddressV"`
Amount string `json:"amount" bson:"amount"`
Fees string `json:"fees" bson:"fees"`
Type int64 `json:"type" bson:"type"`
Symbol string `json:"symbol" bson:"symbol"`
ContractID string `json:"contractID" bson:"contractID"`
IsContract int64 `json:"isContract" bson:"isContract"`
Confirm int64 `json:"confirm" bson:"confirm"`
BlockHash string `json:"blockHash" bson:"blockHash"`
BlockHeight int64 `json:"blockHeight" bson:"blockHeight"`
IsMemo int64 `json:"isMemo" bson:"isMemo"`
IsMain int64 `json:"isMain" bson:"isMain"`
Memo string `json:"memo" bson:"memo"`
Applytime int64 `json:"applytime" bson:"applytime"`
SubmitTime int64 `json:"submitTime" bson:"submitTime"`
ConfirmTime int64 `json:"confirmTime" bson:"confirmTime"`
Decimals int64 `json:"decimals" bson:"decimals"`
Succtime int64 `json:"succtime" bson:"succtime"`
Dealstate int64 `json:"dealstate" bson:"dealstate"`
Notifystate int64 `json:"notifystate" bson:"notifystate"`
ContractID2 string `json:"contractID2" bson:"contractID2"`
ContractName string `json:"contractName" bson:"contractName"`
ContractAddr string `json:"contractAddr" bson:"contractAddr"`
Contract map[string]interface{} `json:"contract" bson:"contract"`
Success string `json:"success"` //用于判断交易单链上的真实状态,0:失败,1:成功
TxType int64 `json:"txType"` //0:转账, 1:合约调用(发生于主链), >100: 自定义
TxAction string `json:"txAction"` //执行事件, 例如:合约的Transfer事
BalanceMode uint64 `json:"balanceMode" bson:"balanceMode"` //余额模型 0.地址 1.账户
}
func (tx *Transaction) FromSID(n int) string {
return openwallet.GenTxInputSID(tx.Txid, tx.Symbol, tx.ContractID, uint64(n))
}
func (tx *Transaction) ToSID(n int) string {
return openwallet.GenTxOutPutSID(tx.Txid, tx.Symbol, tx.ContractID, uint64(n))
}
type FailedRawTransaction struct {
RawTx *RawTransaction `json:"rawTx"`
Reason string `json:"error"`
}
type SummaryTask struct {
Wallets []*SummaryWalletTask `json:"wallets"`
}
func NewSummaryTask(result gjson.Result) *SummaryTask {
var obj SummaryTask
json.Unmarshal([]byte(result.Raw), &obj)
return &obj
}
type SummaryAccountTask struct {
AccountID string `json:"accountID"`
Contracts map[string]*SummaryContractTask `json:"contracts"`
FeeRate string `json:"feeRate"`
OnlyContracts bool `json:"onlyContracts"`
FeesSupportAccount *FeesSupportAccount `json:"feesSupportAccount"`
SwitchSymbol string `json:"switchSymbol"`
Memo string `json:"memo"`
*SummarySetting
}
type SummaryContractTask struct {
*SummarySetting
}
type SummaryWalletTask struct {
WalletID string `json:"walletID"`
Password string `json:"password,omitempty"`
Accounts []*SummaryAccountTask `json:"accounts"`
Wallet *Wallet `json:"wallet,omitempty"`
}
func NewSummaryWalletTask(result gjson.Result) *SummaryWalletTask {
var obj SummaryWalletTask
json.Unmarshal([]byte(result.Raw), &obj)
return &obj
}
/*
{
"wallets": [
{
"walletID": "1234qwer",
"password": "12345678",
"accounts": [
{
"accountID": "123",
"feeRate": "0.0001"
"contracts":[
"all", //全部合约
"0x1234567890abcdef", //指定的合约地址
]
},
],
},
]
}
*/
type SummaryTaskLog struct {
Sid string `json:"sid" storm:"id"` //汇总执行批次号
WalletID string `json:"walletID"` //汇总钱包ID
AccountID string `json:"accountID"` //汇总资产账户ID
StartAddrIndex int `json:"startAddrIndex"` //账户汇总起始的地址索引位
EndAddrIndex int `json:"endAddrIndex"` //账户汇总结束的地址索引位
Coin Coin `json:"coin"` //汇总的币种信息
SuccessCount int `json:"successCount"` //汇总交易发送的成功个数
FailCount int `json:"failCount"` //汇总交易发送的失败个数
TxIDs []string `json:"txIDs"` //汇总交易成功的txid
Sids []string `json:"sids"` //汇总交易成功批次号
TotalSumAmount string `json:"sumAmount"` //这次汇总总数
TotalCostFees string `json:"sumFees"` //这次汇总总消费手续费
CreateTime int64 `json:"createTime" storm:"index"` //汇总时间
}
func (wallet *Wallet) CreateAccountWithIndex(alias string, symbol *Symbol, key *hdkeystore.HDKey, accountIndex int64) (*Account, error) {
var (
account = &Account{}
)
account.Alias = alias
account.Symbol = symbol.Coin
account.ReqSigs = 1
newAccIndex := accountIndex
// root/n' , 使用强化方案
account.HdPath = fmt.Sprintf("%s/%d'", wallet.RootPath, newAccIndex)
childKey, err := key.DerivedKeyWithPath(account.HdPath, uint32(symbol.Curve))
if err != nil {
return nil, err
}
account.PublicKey = childKey.GetPublicKey().OWEncode()
account.AccountIndex = newAccIndex
account.AccountID = alias + ":" + openwallet.GenAccountID(account.PublicKey)
account.AddressIndex = -1
account.WalletID = wallet.WalletID
return account, nil
}
func (wallet *Wallet) CreateAccount(alias string, symbol *Symbol, key *hdkeystore.HDKey) (*Account, error) {
var (
account = &Account{}
)
account.Alias = alias
account.Symbol = symbol.Coin
account.ReqSigs = 1
newAccIndex := wallet.AccountIndex + 1
// root/n' , 使用强化方案
account.HdPath = fmt.Sprintf("%s/%d'", wallet.RootPath, newAccIndex)
childKey, err := key.DerivedKeyWithPath(account.HdPath, uint32(symbol.Curve))
if err != nil {
return nil, err
}
account.PublicKey = childKey.GetPublicKey().OWEncode()
account.AccountIndex = newAccIndex
account.AccountID = openwallet.GenAccountID(account.PublicKey)
account.AddressIndex = -1
account.WalletID = wallet.WalletID
return account, nil
}
type Balance struct {
Symbol string `json:"symbol" bson:"symbol"`
AccountID string `json:"accountID" bson:"accountID"`
Address string `json:"address" bson:"address"`
BalanceType int64 `json:"type" bson:"type"`
Balance string `json:"balance" bson:"balance"`
ConfirmBalance string `json:"confirmBalance" bson:"confirmBalance"`
UnconfirmBalance string `json:"unconfirmBalance" bson:"unconfirmBalance"`
}
func NewBalance(result gjson.Result) *Balance {
b := Balance{
Symbol: result.Get("symbol").String(),
AccountID: result.Get("accountID").String(),
Address: result.Get("address").String(),
BalanceType: result.Get("type").Int(),
Balance: result.Get("balance").String(),
ConfirmBalance: result.Get("confirmBalance").String(),
UnconfirmBalance: result.Get("unconfirmBalance").String(),
}
return &b
}
type TokenBalance struct {
ContractID string
Token string
Address string
Balance Balance
IsContract int64
}
func NewTokenBalance(result gjson.Result) *TokenBalance {
b := TokenBalance{
IsContract: result.Get("isContract").Int(),
ContractID: result.Get("contractID").String(),
Token: result.Get("token").String(),
Address: result.Get("contractAddress").String(),
Balance: Balance{
//Symbol: symbol,
AccountID: result.Get("accountID").String(),
Balance: result.Get("balance").String(),
},
}
return &b
}
// FeesSupportAccount 主币余额不足时,可选择一个账户提供手续费
type FeesSupportAccount struct {
AccountID string `json:"accountID"` //手续费账户ID
LowBalanceWarning string `json:"lowBalanceWarning"` //余额过低报警值
LowBalanceStop string `json:"lowBalanceStop"` //余额过低停止手续费支持
FixSupportAmount string `json:"fixSupportAmount"`
FeesScale string `json:"feesScale"`
IsTokenContract bool `json:"isTokenContract"` //手续费是否合约代币
ContractAddress string `json:"contractAddress"` //合约地址
}
// support feeRate
type SupportFeeRate struct {
FeeRate string
Symbol string
Unit string
}
// 白名单地址
type TrustAddress struct {
ID string `json:"id" storm:"id"`
Address string `json:"address"`
Symbol string `json:"symbol"`
Memo string `json:"memo"`
CreateTime int64 `json:"createTime"`
}
func NewTrustAddress(address, symbol, memo string) *TrustAddress {
addr := &TrustAddress{
Address: address,
Symbol: symbol,
Memo: memo,
CreateTime: time.Now().Unix(),
}
addr.ID = GenTrustAddressID(address, symbol)
return addr
}
func GenTrustAddressID(address, symbol string) string {
plain := fmt.Sprintf("trustaddress_%s_%s", symbol, address)
id := base64.StdEncoding.EncodeToString(crypto.SHA256([]byte(plain)))
return id
}
// SmartContractCallResult 调用结果,不产生交易
type SmartContractCallResult struct {
Method string `json:"method"` //调用方法
Value string `json:"value"` //json结果
RawHex string `json:"rawHex"` //16进制字符串结果
Status uint64 `json:"status"` //0:成功,1:失败
Exception string `json:"exception"` //异常错误
}
// SmartContractRawTransaction 智能合约原始交易单
type SmartContractRawTransaction struct {
Coin Coin `json:"coin"` //@required 区块链类型标识
TxID string `json:"txID"` //交易单ID,广播后会生成
Sid string `json:"sid"` //@required 业务订单号,保证业务不重复交易而用
AccountID string `json:"accountID"` //@required 创建交易单的账户
Signatures map[string][]*KeySignature `json:"sigParts"` //拥有者accountID: []未花签名
Raw string `json:"raw"` //交易单调用参数,根据RawType填充数据
RawType uint64 `json:"rawType"` // 0:hex字符串,1:json字符串,2:base64字符串
ABIParam []string `json:"abiParam"` //abi调用参数,[method, arg1, arg2, args...]
Value string `json:"value"` //主币数量
FeeRate string `json:"feeRate"` //自定义费率
Fees string `json:"fees"` //手续费
AwaitResult bool `json:"awaitResult"` //是否广播后同时等待结果
AwaitTimeout uint64 `json:"awaitTimeout"` //广播后等待超时秒,0 = 默认超时90秒
}
type SmartContractReceipt struct {
WxID string `json:"wxid" storm:"id"` //@required 通过GenTransactionWxID计算
TxID string `json:"txid"` //@required
FromAddress string `json:"fromAddress"` //@required 调用者
ToAddress string `json:"toAddress"` //@required 调用地址,与合约地址一致
Value string `json:"value"` //主币数量
Fees string `json:"fees"` //手续费
Symbol string `json:"symbol"` //主链标识
ContractID string `json:"contractID"` //合约ID
ContractName string `json:"contractName"` //合约名字
ContractAddr string `json:"contractAddr"` //合约地址
BlockHash string `json:"blockHash"` //@required
BlockHeight uint64 `json:"blockHeight"` //@required
IsMain int64 `json:"isMain"` //1.区块数据正常 2.重扫或分叉状态
Applytime int64 `json:"applytime"` //订单申请时间
SubmitTime int64 `json:"submitTime"` //订单提交时间
Succtime int64 `json:"succtime"` //订单处理成功时间
Dealstate int64 `json:"dealstate"` //处理状态 1.未成功 2.已成功 3.已确认
Notifystate int64 `json:"notifystate"` //通知状态 1.未通知 2.已通知
ConfirmTime int64 `json:"confirmTime"` //订单确认时间
Status string `json:"status"` //@required 链上状态,0:失败,1:成功
Success string `json:"success"` //用于判断交易单链上的真实状态,0:失败,1:成功
RawReceipt string `json:"rawReceipt"` //@required 原始交易回执,一般为json
Events []*SmartContractEvent `json:"events"` //@required 执行事件, 例如:event Transfer
}
// SmartContractEvent 事件记录
type SmartContractEvent struct {
Symbol string `json:"symbol"` //主币类型
ContractID string `json:"contractID"` //合约ID
ContractName string `json:"contractName"` //合约名称
ContractAddr string `json:"contractAddr"` //合约地址
Event string `json:"event"` //记录事件
Value string `json:"value"` //结果参数,json字符串
}
// FailureSmartContractLog 广播失败的交易单
type FailureSmartContractLog struct {
RawTx *SmartContractRawTransaction `json:"rawTx"`
Reason string `json:"error"`
}