forked from elastos/Elastos.ELA
/
common.go
224 lines (193 loc) · 7.32 KB
/
common.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
// Copyright (c) 2017-2019 The Elastos Foundation
// Use of this source code is governed by an MIT
// license that can be found in the LICENSE file.
//
package servers
import (
"github.com/elastos/Elastos.ELA/common"
. "github.com/elastos/Elastos.ELA/core/types"
"github.com/elastos/Elastos.ELA/core/types/outputpayload"
"github.com/elastos/Elastos.ELA/core/types/payload"
)
const TlsPort = 443
type AttributeInfo struct {
Usage AttributeUsage `json:"usage"`
Data string `json:"data"`
}
type InputInfo struct {
TxID string `json:"txid"`
VOut uint16 `json:"vout"`
Sequence uint32 `json:"sequence"`
}
type OutputInfo struct {
Value string `json:"value"`
Index uint32 `json:"n"`
Address string `json:"address"`
AssetID string `json:"assetid"`
OutputLock uint32 `json:"outputlock"`
OutputType uint32 `json:"type"`
OutputPayload OutputPayloadInfo `json:"payload"`
}
type OutputPayloadInfo interface{}
type DefaultOutputInfo struct{}
type CandidateVotes struct {
Candidate string `json:"candidate"`
Votes string `json:"votes"`
}
type VoteContentInfo struct {
VoteType outputpayload.VoteType `json:"votetype"`
CandidatesInfo []CandidateVotes `json:"candidates"`
}
type VoteOutputInfo struct {
Version byte `json:"version"`
Contents []VoteContentInfo `json:"contents"`
}
type ProgramInfo struct {
Code string `json:"code"`
Parameter string `json:"parameter"`
}
type TransactionInfo struct {
TxID string `json:"txid"`
Hash string `json:"hash"`
Size uint32 `json:"size"`
VSize uint32 `json:"vsize"`
Version TransactionVersion `json:"version"`
TxType TxType `json:"type"`
PayloadVersion byte `json:"payloadversion"`
Payload PayloadInfo `json:"payload"`
Attributes []AttributeInfo `json:"attributes"`
Inputs []InputInfo `json:"vin"`
Outputs []OutputInfo `json:"vout"`
LockTime uint32 `json:"locktime"`
Programs []ProgramInfo `json:"programs"`
}
type TransactionContextInfo struct {
*TransactionInfo
BlockHash string `json:"blockhash"`
Confirmations uint32 `json:"confirmations"`
Time uint32 `json:"time"`
BlockTime uint32 `json:"blocktime"`
}
type BlockInfo struct {
Hash string `json:"hash"`
Confirmations uint32 `json:"confirmations"`
StrippedSize uint32 `json:"strippedsize"`
Size uint32 `json:"size"`
Weight uint32 `json:"weight"`
Height uint32 `json:"height"`
Version uint32 `json:"version"`
VersionHex string `json:"versionhex"`
MerkleRoot string `json:"merkleroot"`
Tx []interface{} `json:"tx"`
Time uint32 `json:"time"`
MedianTime uint32 `json:"mediantime"`
Nonce uint32 `json:"nonce"`
Bits uint32 `json:"bits"`
Difficulty string `json:"difficulty"`
ChainWork string `json:"chainwork"`
PreviousBlockHash string `json:"previousblockhash"`
NextBlockHash string `json:"nextblockhash"`
AuxPow string `json:"auxpow"`
MinerInfo string `json:"minerinfo"`
}
type VoteInfo struct {
Signer string `json:"signer"`
Accept bool `json:"accept"`
}
type ConfirmInfo struct {
BlockHash string `json:"blockhash"`
Sponsor string `json:"sponsor"`
ViewOffset uint32 `json:"viewoffset"`
Votes []VoteInfo `json:"votes"`
}
type ServerInfo struct {
Compile string `json:"compile"` // The compile version of this server node
Height uint32 `json:"height"` // The ServerNode latest block height
Version uint32 `json:"version"` // The network protocol the ServerNode used
Services string `json:"services"` // The services the server supports
Port uint16 `json:"port"` // The nodes's port
RPCPort uint16 `json:"rpcport"` // The RPC service port
RestPort uint16 `json:"restport"` // The RESTful service port
WSPort uint16 `json:"wsport"` // The webservcie port
Neighbors []*PeerInfo `json:"neighbors"` // The connected neighbor peers.
}
type PeerInfo struct {
NetAddress string `json:"netaddress"`
Services string `json:"services"`
RelayTx bool `json:"relaytx"`
LastSend string `json:"lastsend"`
LastRecv string `json:"lastrecv"`
ConnTime string `json:"conntime"`
TimeOffset int64 `json:"timeoffset"`
Version uint32 `json:"version"`
Inbound bool `json:"inbound"`
StartingHeight uint32 `json:"startingheight"`
LastBlock uint32 `json:"lastblock"`
LastPingTime string `json:"lastpingtime"`
LastPingMicros int64 `json:"lastpingmicros"`
}
type ArbitratorGroupInfo struct {
OnDutyArbitratorIndex int `json:"ondutyarbitratorindex"`
Arbitrators []string `json:"arbitrators"`
}
type PayloadInfo interface{}
type CoinbaseInfo struct {
CoinbaseData string `json:"coinbasedata"`
}
type RegisterAssetInfo struct {
Asset payload.Asset `json:"asset"`
Amount string `json:"amount"`
Controller string `json:"controller"`
}
type SideChainPowInfo struct {
BlockHeight uint32 `json:"blockheight"`
SideBlockHash string `json:"sideblockhash"`
SideGenesisHash string `json:"sidegenesishash"`
Signature string `json:"signature"`
}
type TransferCrossChainAssetInfo struct {
CrossChainAddresses []string `json:"crosschainaddresses"`
OutputIndexes []uint64 `json:"outputindexes"`
CrossChainAmounts []common.Fixed64 `json:"crosschainamounts"`
}
type WithdrawFromSideChainInfo struct {
BlockHeight uint32 `json:"blockheight"`
GenesisBlockAddress string `json:"genesisblockaddress"`
SideChainTransactionHashes []string `json:"sidechaintransactionhashes"`
}
type ProducerInfo struct {
OwnerPublicKey string `json:"ownerpublickey"`
NodePublicKey string `json:"nodepublickey"`
NickName string `json:"nickname"`
Url string `json:"url"`
Location uint64 `json:"location"`
NetAddress string `json:"netaddress"`
Signature string `json:"signature"`
}
type CancelProducerInfo struct {
OwnerPublicKey string `json:"ownerpublickey"`
Signature string `json:"signature"`
}
type ActivateProducerInfo struct {
NodePublicKey string `json:"nodepublickey"`
Signature string `json:"signature"`
}
type UTXOInfo struct {
TxType byte `json:"txtype"`
TxID string `json:"txid"`
AssetID string `json:"assetid"`
VOut uint32 `json:"vout"`
Address string `json:"address"`
Amount string `json:"amount"`
OutputLock uint32 `json:"outputlock"`
Confirmations uint32 `json:"confirmations"`
}
type SidechainIllegalDataInfo struct {
IllegalType uint8 `json:"illegaltype"`
Height uint32 `json:"height"`
IllegalSigner string `json:"illegalsigner"`
Evidence string `json:"evidence"`
CompareEvidence string `json:"compareevidence"`
GenesisBlockAddress string `json:"genesisblockaddress"`
Signs []string `json:"signs"`
}