forked from decred/dcrd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dcrdcmds.go
317 lines (267 loc) · 10.2 KB
/
dcrdcmds.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
// Copyright (c) 2015-2016 The Decred developers
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.
// NOTE: This file is intended to house the RPC commands that are supported by
// a chain server with btcd extensions.
package dcrjson
// EstimateStakeDiffCmd defines the eststakedifficulty JSON-RPC command.
type EstimateStakeDiffCmd struct {
Tickets *uint32
}
// NewEstimateStakeDiffCmd defines the eststakedifficulty JSON-RPC command.
func NewEstimateStakeDiffCmd(tickets *uint32) *EstimateStakeDiffCmd {
return &EstimateStakeDiffCmd{
Tickets: tickets,
}
}
// ExistsAddressCmd defines the existsaddress JSON-RPC command.
type ExistsAddressCmd struct {
Address string
}
// NewExistsAddressCmd returns a new instance which can be used to issue a
// existsaddress JSON-RPC command.
func NewExistsAddressCmd(address string) *ExistsAddressCmd {
return &ExistsAddressCmd{
Address: address,
}
}
// ExistsAddressesCmd defines the existsaddresses JSON-RPC command.
type ExistsAddressesCmd struct {
Addresses []string
}
// NewExistsAddressesCmd returns a new instance which can be used to issue an
// existsaddresses JSON-RPC command.
func NewExistsAddressesCmd(addresses []string) *ExistsAddressesCmd {
return &ExistsAddressesCmd{
Addresses: addresses,
}
}
// ExistsMissedTicketsCmd defines the existsmissedtickets JSON-RPC command.
type ExistsMissedTicketsCmd struct {
TxHashBlob string
}
// NewExistsMissedTicketsCmd returns a new instance which can be used to issue an
// existsmissedtickets JSON-RPC command.
func NewExistsMissedTicketsCmd(txHashBlob string) *ExistsMissedTicketsCmd {
return &ExistsMissedTicketsCmd{
TxHashBlob: txHashBlob,
}
}
// ExistsExpiredTicketsCmd defines the existsexpiredtickets JSON-RPC command.
type ExistsExpiredTicketsCmd struct {
TxHashBlob string
}
// NewExistsExpiredTicketsCmd returns a new instance which can be used to issue an
// existsexpiredtickets JSON-RPC command.
func NewExistsExpiredTicketsCmd(txHashBlob string) *ExistsExpiredTicketsCmd {
return &ExistsExpiredTicketsCmd{
TxHashBlob: txHashBlob,
}
}
// ExistsLiveTicketCmd defines the existsliveticket JSON-RPC command.
type ExistsLiveTicketCmd struct {
TxHash string
}
// NewExistsLiveTicketCmd returns a new instance which can be used to issue an
// existsliveticket JSON-RPC command.
func NewExistsLiveTicketCmd(txHash string) *ExistsLiveTicketCmd {
return &ExistsLiveTicketCmd{
TxHash: txHash,
}
}
// ExistsLiveTicketsCmd defines the existslivetickets JSON-RPC command.
type ExistsLiveTicketsCmd struct {
TxHashBlob string
}
// NewExistsLiveTicketsCmd returns a new instance which can be used to issue an
// existslivetickets JSON-RPC command.
func NewExistsLiveTicketsCmd(txHashBlob string) *ExistsLiveTicketsCmd {
return &ExistsLiveTicketsCmd{
TxHashBlob: txHashBlob,
}
}
// ExistsMempoolTxsCmd defines the existsmempooltxs JSON-RPC command.
type ExistsMempoolTxsCmd struct {
TxHashBlob string
}
// NewExistsMempoolTxsCmd returns a new instance which can be used to issue an
// existslivetickets JSON-RPC command.
func NewExistsMempoolTxsCmd(txHashBlob string) *ExistsMempoolTxsCmd {
return &ExistsMempoolTxsCmd{
TxHashBlob: txHashBlob,
}
}
// GetCoinSupplyCmd defines the getcoinsupply JSON-RPC command.
type GetCoinSupplyCmd struct{}
// NewGetCoinSupplyCmd returns a new instance which can be used to issue a
// getcoinsupply JSON-RPC command.
func NewGetCoinSupplyCmd() *GetCoinSupplyCmd {
return &GetCoinSupplyCmd{}
}
// GetStakeDifficultyCmd is a type handling custom marshaling and
// unmarshaling of getstakedifficulty JSON RPC commands.
type GetStakeDifficultyCmd struct{}
// NewGetStakeDifficultyCmd returns a new instance which can be used to
// issue a JSON-RPC getstakedifficulty command.
func NewGetStakeDifficultyCmd() *GetStakeDifficultyCmd {
return &GetStakeDifficultyCmd{}
}
// GetStakeVersionInfoCmd returns stake version info for the current interval.
// Optionally, Count indicates how many additional intervals to return.
type GetStakeVersionInfoCmd struct {
Count *int32
}
// NewGetStakeVersionInfoCmd returns a new instance which can be used to
// issue a JSON-RPC getstakeversioninfo command.
func NewGetStakeVersionInfoCmd(count int32) *GetStakeVersionInfoCmd {
return &GetStakeVersionInfoCmd{
Count: &count,
}
}
// GetStakeVersionsCmd returns stake version for a range of blocks.
// Count indicates how many blocks are walked backwards.
type GetStakeVersionsCmd struct {
Hash string
Count int32
}
// NewGetStakeVersionsCmd returns a new instance which can be used to
// issue a JSON-RPC getstakeversions command.
func NewGetStakeVersionsCmd(hash string, count int32) *GetStakeVersionsCmd {
return &GetStakeVersionsCmd{
Hash: hash,
Count: count,
}
}
// GetTicketPoolValueCmd defines the getticketpoolvalue JSON-RPC command.
type GetTicketPoolValueCmd struct{}
// NewGetTicketPoolValueCmd returns a new instance which can be used to issue a
// getticketpoolvalue JSON-RPC command.
func NewGetTicketPoolValueCmd() *GetTicketPoolValueCmd {
return &GetTicketPoolValueCmd{}
}
// GetVoteInfoCmd returns voting results over a range of blocks. Count
// indicates how many blocks are walked backwards.
type GetVoteInfoCmd struct {
Version uint32
}
// NewGetVoteInfoCmd returns a new instance which can be used to
// issue a JSON-RPC getvoteinfo command.
func NewGetVoteInfoCmd(version uint32) *GetVoteInfoCmd {
return &GetVoteInfoCmd{
Version: version,
}
}
// LiveTicketsCmd is a type handling custom marshaling and
// unmarshaling of livetickets JSON RPC commands.
type LiveTicketsCmd struct{}
// NewLiveTicketsCmd returns a new instance which can be used to issue a JSON-RPC
// livetickets command.
func NewLiveTicketsCmd() *LiveTicketsCmd {
return &LiveTicketsCmd{}
}
// MissedTicketsCmd is a type handling custom marshaling and
// unmarshaling of missedtickets JSON RPC commands.
type MissedTicketsCmd struct{}
// NewMissedTicketsCmd returns a new instance which can be used to issue a JSON-RPC
// missedtickets command.
func NewMissedTicketsCmd() *MissedTicketsCmd {
return &MissedTicketsCmd{}
}
// RebroadcastMissedCmd is a type handling custom marshaling and
// unmarshaling of rebroadcastwinners JSON RPC commands.
type RebroadcastMissedCmd struct{}
// NewRebroadcastMissedCmd returns a new instance which can be used to
// issue a JSON-RPC rebroadcastmissed command.
func NewRebroadcastMissedCmd() *RebroadcastMissedCmd {
return &RebroadcastMissedCmd{}
}
// RebroadcastWinnersCmd is a type handling custom marshaling and
// unmarshaling of rebroadcastwinners JSON RPC commands.
type RebroadcastWinnersCmd struct{}
// NewRebroadcastWinnersCmd returns a new instance which can be used to
// issue a JSON-RPC rebroadcastwinners command.
func NewRebroadcastWinnersCmd() *RebroadcastWinnersCmd {
return &RebroadcastWinnersCmd{}
}
// TicketFeeInfoCmd defines the ticketsfeeinfo JSON-RPC command.
type TicketFeeInfoCmd struct {
Blocks *uint32
Windows *uint32
}
// NewTicketFeeInfoCmd returns a new instance which can be used to issue a
// JSON-RPC ticket fee info command.
func NewTicketFeeInfoCmd(blocks *uint32, windows *uint32) *TicketFeeInfoCmd {
return &TicketFeeInfoCmd{
Blocks: blocks,
Windows: windows,
}
}
// TicketsForAddressCmd defines the ticketsforbucket JSON-RPC command.
type TicketsForAddressCmd struct {
Address string
}
// NewTicketsForAddressCmd returns a new instance which can be used to issue a
// JSON-RPC tickets for bucket command.
func NewTicketsForAddressCmd(addr string) *TicketsForAddressCmd {
return &TicketsForAddressCmd{addr}
}
// TicketVWAPCmd defines the ticketvwap JSON-RPC command.
type TicketVWAPCmd struct {
Start *uint32
End *uint32
}
// NewTicketVWAPCmd returns a new instance which can be used to issue a
// JSON-RPC ticket volume weight average price command.
func NewTicketVWAPCmd(start *uint32, end *uint32) *TicketVWAPCmd {
return &TicketVWAPCmd{
Start: start,
End: end,
}
}
// TxFeeInfoCmd defines the ticketsfeeinfo JSON-RPC command.
type TxFeeInfoCmd struct {
Blocks *uint32
RangeStart *uint32
RangeEnd *uint32
}
// NewTxFeeInfoCmd returns a new instance which can be used to issue a
// JSON-RPC ticket fee info command.
func NewTxFeeInfoCmd(blocks *uint32, start *uint32, end *uint32) *TxFeeInfoCmd {
return &TxFeeInfoCmd{
Blocks: blocks,
RangeStart: start,
RangeEnd: end,
}
}
// VersionCmd defines the version JSON-RPC command.
type VersionCmd struct{}
// NewVersionCmd returns a new instance which can be used to issue a JSON-RPC
// version command.
func NewVersionCmd() *VersionCmd { return new(VersionCmd) }
func init() {
// No special flags for commands in this file.
flags := UsageFlag(0)
MustRegisterCmd("estimatestakediff", (*EstimateStakeDiffCmd)(nil), flags)
MustRegisterCmd("existsaddress", (*ExistsAddressCmd)(nil), flags)
MustRegisterCmd("existsaddresses", (*ExistsAddressesCmd)(nil), flags)
MustRegisterCmd("existsmissedtickets", (*ExistsMissedTicketsCmd)(nil), flags)
MustRegisterCmd("existsexpiredtickets", (*ExistsExpiredTicketsCmd)(nil), flags)
MustRegisterCmd("existsliveticket", (*ExistsLiveTicketCmd)(nil), flags)
MustRegisterCmd("existslivetickets", (*ExistsLiveTicketsCmd)(nil), flags)
MustRegisterCmd("existsmempooltxs", (*ExistsMempoolTxsCmd)(nil), flags)
MustRegisterCmd("getcoinsupply", (*GetCoinSupplyCmd)(nil), flags)
MustRegisterCmd("getstakedifficulty", (*GetStakeDifficultyCmd)(nil), flags)
MustRegisterCmd("getstakeversioninfo", (*GetStakeVersionInfoCmd)(nil), flags)
MustRegisterCmd("getstakeversions", (*GetStakeVersionsCmd)(nil), flags)
MustRegisterCmd("getticketpoolvalue", (*GetTicketPoolValueCmd)(nil), flags)
MustRegisterCmd("getvoteinfo", (*GetVoteInfoCmd)(nil), flags)
MustRegisterCmd("livetickets", (*LiveTicketsCmd)(nil), flags)
MustRegisterCmd("missedtickets", (*MissedTicketsCmd)(nil), flags)
MustRegisterCmd("rebroadcastmissed", (*RebroadcastMissedCmd)(nil), flags)
MustRegisterCmd("rebroadcastwinners", (*RebroadcastWinnersCmd)(nil), flags)
MustRegisterCmd("ticketfeeinfo", (*TicketFeeInfoCmd)(nil), flags)
MustRegisterCmd("ticketsforaddress", (*TicketsForAddressCmd)(nil), flags)
MustRegisterCmd("ticketvwap", (*TicketVWAPCmd)(nil), flags)
MustRegisterCmd("txfeeinfo", (*TxFeeInfoCmd)(nil), flags)
MustRegisterCmd("version", (*VersionCmd)(nil), flags)
}