forked from decred/dcrd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dcrwalletextcmds.go
518 lines (450 loc) · 15.8 KB
/
dcrwalletextcmds.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
// Copyright (c) 2015 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 wallet server with btcwallet extensions.
package dcrjson
// ConsolidateCmd is a type handling custom marshaling and
// unmarshaling of consolidate JSON wallet extension
// commands.
type ConsolidateCmd struct {
Inputs int `json:"inputs"`
Account *string
}
// NewConsolidateCmd creates a new ConsolidateCmd.
func NewConsolidateCmd(inputs int, acct *string) *ConsolidateCmd {
return &ConsolidateCmd{Inputs: inputs, Account: acct}
}
// SStxInput represents the inputs to an SStx transaction. Specifically a
// transactionsha and output number pair, along with the output amounts.
type SStxInput struct {
Txid string `json:"txid"`
Vout uint32 `json:"vout"`
Tree int8 `json:"tree"`
Amt int64 `json:"amt"`
}
// SStxCommitOut represents the output to an SStx transaction. Specifically a
// a commitment address and amount, and a change address and amount.
type SStxCommitOut struct {
Addr string `json:"addr"`
CommitAmt int64 `json:"commitamt"`
ChangeAddr string `json:"changeaddr"`
ChangeAmt int64 `json:"changeamt"`
}
// CreateRawSStxCmd is a type handling custom marshaling and
// unmarshaling of createrawsstx JSON RPC commands.
type CreateRawSStxCmd struct {
Inputs []SStxInput
Amount map[string]int64
COuts []SStxCommitOut
}
// NewCreateRawSStxCmd creates a new CreateRawSStxCmd.
func NewCreateRawSStxCmd(inputs []SStxInput, amount map[string]int64,
couts []SStxCommitOut) *CreateRawSStxCmd {
return &CreateRawSStxCmd{
Inputs: inputs,
Amount: amount,
COuts: couts,
}
}
// CreateRawSSGenTxCmd is a type handling custom marshaling and
// unmarshaling of createrawssgentxcmd JSON RPC commands.
type CreateRawSSGenTxCmd struct {
Inputs []TransactionInput
VoteBits uint16
}
// NewCreateRawSSGenTxCmd creates a new CreateRawSSGenTxCmd.
func NewCreateRawSSGenTxCmd(inputs []TransactionInput,
vb uint16) *CreateRawSSGenTxCmd {
return &CreateRawSSGenTxCmd{
Inputs: inputs,
VoteBits: vb,
}
}
// CreateRawSSRtxCmd is a type handling custom marshaling and
// unmarshaling of createrawssrtx JSON RPC commands.
type CreateRawSSRtxCmd struct {
Inputs []TransactionInput
}
// NewCreateRawSSRtxCmd creates a new CreateRawSSRtxCmd.
func NewCreateRawSSRtxCmd(inputs []TransactionInput) *CreateRawSSRtxCmd {
return &CreateRawSSRtxCmd{
Inputs: inputs,
}
}
// GetMultisigOutInfoCmd is a type handling custom marshaling and
// unmarshaling of getmultisigoutinfo JSON websocket extension
// commands.
type GetMultisigOutInfoCmd struct {
Hash string
Index uint32
}
// NewGetMultisigOutInfoCmd creates a new GetMultisigOutInfoCmd.
func NewGetMultisigOutInfoCmd(hash string, index uint32) *GetMultisigOutInfoCmd {
return &GetMultisigOutInfoCmd{hash, index}
}
// GetMasterPubkeyCmd is a type handling custom marshaling and unmarshaling of
// getmasterpubkey JSON wallet extension commands.
type GetMasterPubkeyCmd struct {
}
// NewGetMasterPubkeyCmd creates a new GetMasterPubkeyCmd.
func NewGetMasterPubkeyCmd() *GetMasterPubkeyCmd {
return &GetMasterPubkeyCmd{}
}
// GetSeedCmd is a type handling custom marshaling and
// unmarshaling of getseed JSON wallet extension
// commands.
type GetSeedCmd struct {
}
// NewGetSeedCmd creates a new GetSeedCmd.
func NewGetSeedCmd() *GetSeedCmd {
return &GetSeedCmd{}
}
// GetStakeInfoCmd is a type handling custom marshaling and
// unmarshaling of getstakeinfo JSON wallet extension commands.
type GetStakeInfoCmd struct {
}
// NewGetStakeInfoCmd creates a new GetStakeInfoCmd.
func NewGetStakeInfoCmd() *GetStakeInfoCmd {
return &GetStakeInfoCmd{}
}
// GetTicketFeeCmd is a type handling custom marshaling and
// unmarshaling of getticketfee JSON wallet extension
// commands.
type GetTicketFeeCmd struct {
}
// NewGetTicketFeeCmd creates a new GetTicketFeeCmd.
func NewGetTicketFeeCmd() *GetTicketFeeCmd {
return &GetTicketFeeCmd{}
}
// GetTicketMaxPriceCmd is a type handling custom marshaling and
// unmarshaling of getticketmaxprice JSON wallet extension
// commands.
type GetTicketMaxPriceCmd struct {
}
// NewGetTicketMaxPriceCmd creates a new GetTicketMaxPriceCmd.
func NewGetTicketMaxPriceCmd() *GetTicketMaxPriceCmd {
return &GetTicketMaxPriceCmd{}
}
// GetTicketsCmd is a type handling custom marshaling and
// unmarshaling of gettickets JSON wallet extension
// commands.
type GetTicketsCmd struct {
IncludeImmature bool
}
// NewGetTicketsCmd returns a new instance which can be used to issue a
// gettickets JSON-RPC command.
func NewGetTicketsCmd(includeImmature bool) *GetTicketsCmd {
return &GetTicketsCmd{includeImmature}
}
// GetTicketVoteBitsCmd defines the getticketvotebits JSON-RPC command.
type GetTicketVoteBitsCmd struct {
TxHash string
}
// NewGetTicketVoteBitsCmd returns a new instance which can be used to issue
// a getticketvotebits JSON-RPC command.
func NewGetTicketVoteBitsCmd(txHash string) *GetTicketVoteBitsCmd {
return &GetTicketVoteBitsCmd{TxHash: txHash}
}
// GetTicketsVoteBitsCmd defines the getticketsvotebits JSON-RPC command.
type GetTicketsVoteBitsCmd struct {
TxHashes []string
}
// NewGetTicketsVoteBitsCmd returns a new instance which can be used to issue
// a getticketsvotebits JSON-RPC command.
func NewGetTicketsVoteBitsCmd(txHashes []string) *GetTicketsVoteBitsCmd {
return &GetTicketsVoteBitsCmd{TxHashes: txHashes}
}
// GetWalletFeeCmd defines the getwalletfee JSON-RPC command.
type GetWalletFeeCmd struct{}
// NewGetWalletFeeCmd returns a new instance which can be used to issue a
// getwalletfee JSON-RPC command.
//
func NewGetWalletFeeCmd() *GetWalletFeeCmd {
return &GetWalletFeeCmd{}
}
// ImportScriptCmd is a type for handling custom marshaling and
// unmarshaling of importscript JSON wallet extension commands.
type ImportScriptCmd struct {
Hex string
}
// NewImportScriptCmd creates a new GetImportScriptCmd.
func NewImportScriptCmd(hex string) *ImportScriptCmd {
return &ImportScriptCmd{hex}
}
// ListScriptsCmd is a type for handling custom marshaling and
// unmarshaling of listscripts JSON wallet extension commands.
type ListScriptsCmd struct {
}
// NewListScriptsCmd returns a new instance which can be used to issue a
// listscripts JSON-RPC command.
func NewListScriptsCmd() *ListScriptsCmd {
return &ListScriptsCmd{}
}
// NotifyWinningTicketsCmd is a type handling custom marshaling and
// unmarshaling of notifywinningtickets JSON websocket extension
// commands.
type NotifyWinningTicketsCmd struct {
}
// NewNotifyWinningTicketsCmd creates a new NotifyWinningTicketsCmd.
func NewNotifyWinningTicketsCmd() *NotifyWinningTicketsCmd {
return &NotifyWinningTicketsCmd{}
}
// NotifySpentAndMissedTicketsCmd is a type handling custom marshaling and
// unmarshaling of notifyspentandmissedtickets JSON websocket extension
// commands.
type NotifySpentAndMissedTicketsCmd struct {
}
// NewNotifySpentAndMissedTicketsCmd creates a new NotifySpentAndMissedTicketsCmd.
func NewNotifySpentAndMissedTicketsCmd() *NotifySpentAndMissedTicketsCmd {
return &NotifySpentAndMissedTicketsCmd{}
}
// NotifyNewTicketsCmd is a type handling custom marshaling and
// unmarshaling of notifynewtickets JSON websocket extension
// commands.
type NotifyNewTicketsCmd struct {
}
// NewNotifyNewTicketsCmd creates a new NotifyNewTicketsCmd.
func NewNotifyNewTicketsCmd() *NotifyNewTicketsCmd {
return &NotifyNewTicketsCmd{}
}
// NotifyStakeDifficultyCmd is a type handling custom marshaling and
// unmarshaling of notifystakedifficulty JSON websocket extension
// commands.
type NotifyStakeDifficultyCmd struct {
}
// NewNotifyStakeDifficultyCmd creates a new NotifyStakeDifficultyCmd.
func NewNotifyStakeDifficultyCmd() *NotifyStakeDifficultyCmd {
return &NotifyStakeDifficultyCmd{}
}
// PurchaseTicketCmd is a type handling custom marshaling and
// unmarshaling of purchaseticket JSON RPC commands.
type PurchaseTicketCmd struct {
FromAccount string
SpendLimit float64 // In Coins
MinConf *int `jsonrpcdefault:"1"`
TicketAddress *string
Comment *string
}
// NewPurchaseTicketCmd creates a new PurchaseTicketCmd.
func NewPurchaseTicketCmd(fromAccount string, spendLimit float64, minConf *int,
ticketAddress *string, comment *string) *PurchaseTicketCmd {
return &PurchaseTicketCmd{
FromAccount: fromAccount,
SpendLimit: spendLimit,
MinConf: minConf,
TicketAddress: ticketAddress,
Comment: comment,
}
}
// RedeemMultiSigOutCmd is a type handling custom marshaling and
// unmarshaling of redeemmultisigout JSON RPC commands.
type RedeemMultiSigOutCmd struct {
Hash string
Index uint32
Tree int8
Address *string
}
// NewRedeemMultiSigOutCmd creates a new RedeemMultiSigOutCmd.
func NewRedeemMultiSigOutCmd(hash string, index uint32, tree int8,
address *string) *RedeemMultiSigOutCmd {
return &RedeemMultiSigOutCmd{
Hash: hash,
Index: index,
Tree: tree,
Address: address,
}
}
// RedeemMultiSigOutsCmd is a type handling custom marshaling and
// unmarshaling of redeemmultisigout JSON RPC commands.
type RedeemMultiSigOutsCmd struct {
FromScrAddress string
ToAddress *string
Number *int
}
// NewRedeemMultiSigOutsCmd creates a new RedeemMultiSigOutsCmd.
func NewRedeemMultiSigOutsCmd(from string, to *string,
number *int) *RedeemMultiSigOutsCmd {
return &RedeemMultiSigOutsCmd{
FromScrAddress: from,
ToAddress: to,
Number: number,
}
}
// SendToMultiSigCmd is a type handling custom marshaling and
// unmarshaling of sendtomultisig JSON RPC commands.
type SendToMultiSigCmd struct {
FromAccount string
Amount float64
Pubkeys []string
NRequired *int `jsonrpcdefault:"1"`
MinConf *int `jsonrpcdefault:"1"`
Comment *string
}
// NewSendToMultiSigCmd creates a new SendToMultiSigCmd.
func NewSendToMultiSigCmd(fromaccount string, amount float64, pubkeys []string,
nrequired *int, minConf *int, comment *string) *SendToMultiSigCmd {
return &SendToMultiSigCmd{
FromAccount: fromaccount,
Amount: amount,
Pubkeys: pubkeys,
NRequired: nrequired,
MinConf: minConf,
Comment: comment,
}
}
// SendToSStxCmd is a type handling custom marshaling and
// unmarshaling of sendtosstx JSON RPC commands.
type SendToSStxCmd struct {
FromAccount string
Amounts map[string]int64
Inputs []SStxInput
COuts []SStxCommitOut
MinConf *int `jsonrpcdefault:"1"`
Comment *string
}
// NewSendToSStxCmd creates a new SendToSStxCmd. Optionally a
// pointer to a TemplateRequest may be provided.
func NewSendToSStxCmd(fromaccount string, amounts map[string]int64,
inputs []SStxInput, couts []SStxCommitOut, minConf *int,
comment *string) *SendToSStxCmd {
return &SendToSStxCmd{
FromAccount: fromaccount,
Amounts: amounts,
Inputs: inputs,
COuts: couts,
MinConf: minConf,
Comment: comment,
}
}
// SendToSSGenCmd models the data needed for sendtossgen.
type SendToSSGenCmd struct {
FromAccount string
TicketHash string
BlockHash string
Height int64
VoteBits uint16
Comment *string
}
// NewSendToSSGenCmd creates a new SendToSSGenCmd. Optionally a
// pointer to a TemplateRequest may be provided.
func NewSendToSSGenCmd(fromaccount string, tickethash string, blockhash string,
height int64, votebits uint16, comment *string) *SendToSSGenCmd {
return &SendToSSGenCmd{
FromAccount: fromaccount,
TicketHash: tickethash,
BlockHash: blockhash,
Height: height,
VoteBits: votebits,
Comment: comment,
}
}
// SendToSSRtxCmd is a type handling custom marshaling and
// unmarshaling of sendtossrtx JSON RPC commands.
type SendToSSRtxCmd struct {
FromAccount string
TicketHash string
Comment *string
}
// NewSendToSSRtxCmd creates a new SendToSSRtxCmd. Optionally a
// pointer to a TemplateRequest may be provided.
func NewSendToSSRtxCmd(fromaccount string, tickethash string,
comment *string) *SendToSSRtxCmd {
return &SendToSSRtxCmd{
FromAccount: fromaccount,
TicketHash: tickethash,
Comment: comment,
}
}
// SetTicketFeeCmd is a type handling custom marshaling and
// unmarshaling of setticketfee JSON RPC commands.
type SetTicketFeeCmd struct {
Fee float64
}
// NewSetTicketFeeCmd creates a new instance of the setticketfee
// command.
func NewSetTicketFeeCmd(fee float64) *SetTicketFeeCmd {
return &SetTicketFeeCmd{
Fee: fee,
}
}
// SetTicketMaxPriceCmd is a type handling custom marshaling and
// unmarshaling of setticketmaxprice JSON RPC commands.
type SetTicketMaxPriceCmd struct {
Max float64
}
// NewSetTicketMaxPriceCmd creates a new instance of the setticketmaxprice
// command.
func NewSetTicketMaxPriceCmd(max float64) *SetTicketMaxPriceCmd {
return &SetTicketMaxPriceCmd{
Max: max,
}
}
// SetTicketVoteBitsCmd is a type handling custom marshaling and
// unmarshaling of setticketvotebits JSON RPC commands.
type SetTicketVoteBitsCmd struct {
TxHash string
VoteBits uint16
VoteBitsExt *string
}
// NewSetTicketVoteBitsCmd creates a new instance of the setticketvotebits
// command.
func NewSetTicketVoteBitsCmd(txHash string, voteBits uint16, voteBitsExt *string) *SetTicketVoteBitsCmd {
return &SetTicketVoteBitsCmd{
TxHash: txHash,
VoteBits: voteBits,
VoteBitsExt: voteBitsExt,
}
}
// SignRawTransactionsCmd defines the signrawtransactions JSON-RPC command.
type SignRawTransactionsCmd struct {
RawTxs []string
Send *bool `jsonrpcdefault:"true"`
}
// NewSignRawTransactionsCmd returns a new instance which can be used to issue a
// signrawtransactions JSON-RPC command.
func NewSignRawTransactionsCmd(hexEncodedTxs []string,
send *bool) *SignRawTransactionsCmd {
return &SignRawTransactionsCmd{
RawTxs: hexEncodedTxs,
Send: send,
}
}
func init() {
// The commands in this file are only usable with a wallet
// server.
flags := UFWalletOnly
MustRegisterCmd("consolidate", (*ConsolidateCmd)(nil), flags)
MustRegisterCmd("createrawsstx", (*CreateRawSStxCmd)(nil), flags)
MustRegisterCmd("createrawssgentx", (*CreateRawSSGenTxCmd)(nil), flags)
MustRegisterCmd("createrawssrtx", (*CreateRawSSRtxCmd)(nil), flags)
MustRegisterCmd("getmultisigoutinfo", (*GetMultisigOutInfoCmd)(nil), flags)
MustRegisterCmd("getmasterpubkey", (*GetMasterPubkeyCmd)(nil), flags)
MustRegisterCmd("getseed", (*GetSeedCmd)(nil), flags)
MustRegisterCmd("getstakeinfo", (*GetStakeInfoCmd)(nil), flags)
MustRegisterCmd("getticketfee", (*GetTicketFeeCmd)(nil), flags)
MustRegisterCmd("getticketmaxprice", (*GetTicketMaxPriceCmd)(nil), flags)
MustRegisterCmd("gettickets", (*GetTicketsCmd)(nil), flags)
MustRegisterCmd("getticketvotebits", (*GetTicketVoteBitsCmd)(nil), flags)
MustRegisterCmd("getticketsvotebits", (*GetTicketsVoteBitsCmd)(nil), flags)
MustRegisterCmd("importscript", (*ImportScriptCmd)(nil), flags)
MustRegisterCmd("listscripts", (*ListScriptsCmd)(nil), flags)
MustRegisterCmd("notifynewtickets", (*NotifyNewTicketsCmd)(nil), flags)
MustRegisterCmd("notifyspentandmissedtickets",
(*NotifySpentAndMissedTicketsCmd)(nil), flags)
MustRegisterCmd("notifystakedifficulty",
(*NotifyStakeDifficultyCmd)(nil), flags)
MustRegisterCmd("notifywinningtickets",
(*NotifyWinningTicketsCmd)(nil), flags)
MustRegisterCmd("purchaseticket", (*PurchaseTicketCmd)(nil), flags)
MustRegisterCmd("redeemmultisigout", (*RedeemMultiSigOutCmd)(nil), flags)
MustRegisterCmd("redeemmultisigouts", (*RedeemMultiSigOutsCmd)(nil), flags)
MustRegisterCmd("sendtomultisig", (*SendToMultiSigCmd)(nil), flags)
MustRegisterCmd("sendtosstx", (*SendToSStxCmd)(nil), flags)
MustRegisterCmd("sendtossgen", (*SendToSSGenCmd)(nil), flags)
MustRegisterCmd("sendtossrtx", (*SendToSSRtxCmd)(nil), flags)
MustRegisterCmd("setticketfee", (*SetTicketFeeCmd)(nil), flags)
MustRegisterCmd("setticketmaxprice", (*SetTicketMaxPriceCmd)(nil), flags)
MustRegisterCmd("setticketvotebits", (*SetTicketVoteBitsCmd)(nil), flags)
MustRegisterCmd("signrawtransactions", (*SignRawTransactionsCmd)(nil), flags)
}