/
wormholeresults.go
277 lines (239 loc) · 8.68 KB
/
wormholeresults.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
// Copyright (c) 2018 The copernet developers
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.
package btcjson
import (
"encoding/json"
"github.com/shopspring/decimal"
"strconv"
)
type WhcGetInfoResultResult struct {
VersionInt int32 `json:"wormholeversion_int"`
Version string `json:"wormholeversion"`
BitcoinVersion string `json:"bitcoincoreversion"`
Block int `json:"block"`
BlockTime int64 `json:"blocktime"`
Txs int `json:"blocktransactions"`
TotalTrades int `json:"totaltrades"`
TotalTxs int `json:"totaltransactions"`
Alerts []AlertInfo `json:"alerts"`
}
type AlertInfo struct {
TypeInt uint64 `json:"alerttypeint"`
TypeStr string `json:"alerttype"`
Expire string `json:"alertexpiry"`
Message string `json:"alertmessage"`
}
type WhcActiveCrowdResult struct {
PropertyID int `json:"propertyid"`
Name string `json:"name"`
Category string `json:"category"`
Subcategory string `json:"subcategory"`
Data string `json:"data"`
Url string `json:"url"`
Precision int8 `json:"property precision"`
Issuer string `json:"issuer"`
Txid string `json:"creationtxid"`
TotalTokens float64 `json:"totaltokens"`
}
type WhcGetAllBalanceForAddressResult struct {
PropertyID uint64 `json:"propertyid"`
Balance string `json:"balance"`
Reserved string `json:"reserved"`
}
type WhcGetAllBalanceForIDResult struct {
Address string `json:"address"`
Balance string `json:"balance"`
Reserved string `json:"reserved"`
}
type WhcGetBalanceResult struct {
Balance string `json:"balance"`
Reserved string `json:"reserved"`
}
type WhcGetBalanceHashResult struct {
Block uint32 `json:"block"`
BlockHash string `json:"blockhash"`
PropertyID uint64 `json:"propertyid"`
BalanceHash string `json:"balanceshash"`
}
type ParticipantTransactions struct {
TxID string `json:"txid"`
Amount string `json:"amountsent"`
ParticipantTokens string `json:"participanttokens"`
}
type WhcGetCrowdSaleResult struct {
PropertyId uint64 `json:"propertyid"`
Name string `json:"name"`
Active bool `json:"active"`
Issuer string `json:"issuer"`
PropertyIdDesired uint64 `json:"propertyiddesired"`
Precision string `json:"precision"`
TokensPerUnit string `json:"tokensperunit"`
EarlyBonus uint8 `json:"earlybonus"`
StartTime int64 `json:"starttime"`
DeadLine int64 `json:"deadline"`
AmountRaised string `json:"amountraised"`
TokensIssued string `json:"tokensissued"`
AddedIssuerTokens string `json:"addedissuertokens"`
CloseDearly *bool `json:"closedearly,omitempty"`
MaxTokens *bool `json:"omitempty,omniempty"`
EndedTime int64 `json:"omitempty,omitempty"`
TxidClosed *string `json:"closetx,omniempty"`
ParticipantTxs []ParticipantTransactions `json:"participanttransactions,omniempty"`
}
type WhcGetCurrentConsensusHashResult struct {
Block uint32 `json:"block"`
BlockHash string `json:"blockhash"`
ConsensusHash string `json:"consensushash"`
}
type WhcGetFeeShareResult struct {
Address string `json:"address"`
FeeShare string `json:"feeshare"`
}
type IssuanceTxs struct {
TxID string `json:"txid"`
Grant string `json:"grant"`
Revoke string `json:"revoke"`
}
func (i *IssuanceTxs) MarshalJSON() ([]byte, error) {
var grant, revoke int
var err error
if i.Grant != "" {
grant, err = strconv.Atoi(i.Grant)
if err != nil {
return nil, err
}
}
if i.Revoke != "" {
revoke, err = strconv.Atoi(i.Revoke)
if err != nil {
return nil, err
}
}
if grant > 0 {
grantResult := struct {
TxID string `json:"txid"`
Grant string `json:"grant"`
}{
TxID: i.TxID,
Grant: i.Grant,
}
return json.Marshal(grantResult)
}
if revoke > 0 {
revokeResult := struct {
TxID string `json:"txid"`
Revoke string `json:"revoke"`
}{
TxID: i.TxID,
Revoke: i.Revoke,
}
return json.Marshal(revokeResult)
}
return nil, nil
}
type WhcGetGrantsResult struct {
PropertyID uint64 `json:"propertyid"`
Name string `json:"name"`
Issuer string `json:"issuer"`
CreateTxID string `json:"creationtxid"`
TotalTokens string `json:"totaltokens"`
Issuance []IssuanceTxs `json:"issuances"`
}
type WhcGetPayloadResult struct {
Payload string `json:"payload"`
PayloadSize int `json:"payloadsize"`
}
type WhcGetPropertyResult struct {
PropertyID uint64 `json:"propertyid"`
Name string `json:"name"`
Category string `json:"category"`
Subcategory string `json:"subcategory"`
Data string `json:"data"`
Url string `json:"url"`
Precision int `json:"precision"`
Issuer string `json:"issuer"`
CreateTxID string `json:"creationtxid"`
FixedIssuance bool `json:"fixedissuance"`
ManagedIssuance bool `json:"managedissuance"`
FreezingEnabled *bool `json:"freezingenabled"`
TotalTokens string `json:"totaltokens"`
}
type PurchasesDetails struct {
Vout uint64 `json:"vout"`
AmountPaid string `json:"amountpaid"`
IsMine bool `json:"ismine"`
ReferenceAddress string `json:"referenceaddress"`
PropertyID uint64 `json:"propertyid"`
AmountBought string `json:"amountbought"`
Valid bool `json:"valid"`
}
type WhcListPropertiesResult struct {
PropertyID uint64 `json:"propertyid"`
Name string `json:"name"`
Category string `json:"category"`
SubCategory string `json:"subcategory"`
Data string `json:"data"`
Url string `json:"url"`
Precision int `json:"precision"`
}
type GenerateTransactionResult struct {
// --------- required fields
TxID string `json:"txid"`
Fee string `json:"fee"`
SendingAddress string `json:"sendingaddress"`
ReferenceAddress string `json:"referenceaddress,omitempty"`
IsMine bool `json:"ismine"`
Version uint64 `json:"version"`
TypeInt uint64 `json:"type_int"`
Type string `json:"type,omitempty"`
BlockHeight uint32 `json:"block,omitempty"`
Confirmations int `json:"confirmations,omitempty"`
Valid bool `json:"valid,omitempty"`
InvalidReason string `json:"invalidreason,omitempty"`
BlockHash string `json:"blockhash,omitempty"`
BlockTime int64 `json:"blocktime,omitempty"`
PositionBlock int `json:"positionblock,omitempty"`
// ----------
PropertyID int64 `json:"propertyid,omitempty"`
Precision string `json:"precision,omitempty"`
Amount string `json:"amount,omitempty"`
TotalStoFee string `json:"totalstofee,omitempty"`
Recipients []Recipient `json:"recipients,omitempty"`
Ecosystem string `json:"ecosystem,omitempty"`
SubSends []SubSend `json:"subsends,omitemtpy"`
Mature bool `json:"mature,omitempty"`
Enough string `json:"Enough,omitempty"`
Burn string `json:"burns,omitempty"`
ActualInvested string `json:"actualinvested,omitempty"`
PurchasedPropertyID int64 `json:"purchasedpropertyid,omitempty"`
PurchasedPropertyName string `json:"purchasedpropertyname,omitempty"`
PurchasedPropertyPrecision string `json:"purchasedpropertyprecision,omitempty"`
PurchasedTokens string `json:"purchasedtokens,omitempty"`
IssuerTokens string `json:"issuertokens,omitempty"`
Category string `json:"category,omitempty"`
Subcategory string `json:"subcategory,omitempty"`
PropertyName string `json:"propertyname,omitempty"`
Data string `json:"data,omitempty"`
Url string `json:"url,omitempty"`
PropertyIDDesired int64 `json:"propertyiddesired,omitempty"`
TokensPerUnit string `json:"tokensperunit,omitempty"`
Deadline int64 `json:"deadline,omitempty"`
EarlyBonus uint8 `json:"earlybonus,omitempty"`
FeeRate *decimal.Decimal `json:"fee_rate"`
}
type Recipient struct {
Address string `json:"address"`
Amount string `json:"amount"`
}
type SubSend struct {
PropertyID int64 `json:"propertyid,omitempty"`
Precision string `json:"precision,omitempty"`
Amount string `json:"amount,omitempty"`
}
type FrozenBalanceResult struct {
Frozen *bool `json:"frozen"`
Balance string `json:"balance"`
Address *string `json:"address"`
PropertyID *int64 `json:"propertyid,omitempty"`
}