Skip to content

Commit

Permalink
Add getticketsvotebits batched command for wallet RPC
Browse files Browse the repository at this point in the history
JSON handling for the new wallet command getticketsvotebits has been
added. A common struct for voteBits data is now also used between
getticketvotebits and getticketsvotebits.
  • Loading branch information
cjepson committed Mar 1, 2016
1 parent c1420d9 commit 95b4e76
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
14 changes: 13 additions & 1 deletion dcrjson/dcrwalletextcmds.go
Expand Up @@ -151,7 +151,7 @@ func NewGetTicketsCmd(includeImmature bool) *GetTicketsCmd {
return &GetTicketsCmd{includeImmature}
}

// GetTicketVoteBitsCmd defines the getticketsvotebits JSON-RPC command.
// GetTicketVoteBitsCmd defines the getticketvotebits JSON-RPC command.
type GetTicketVoteBitsCmd struct {
TxHash string
}
Expand All @@ -162,6 +162,17 @@ 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{}

Expand Down Expand Up @@ -469,6 +480,7 @@ func init() {
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)
Expand Down
15 changes: 13 additions & 2 deletions dcrjson/dcrwalletextresults.go
Expand Up @@ -45,11 +45,22 @@ type GetTicketsResult struct {
Hashes []string `json:"hashes"`
}

// VoteBitsData models the data stored for any given voteBits for a ticket.
type VoteBitsData struct {
VoteBits uint16 `json:"votebits"`
VoteBitsExt string `json:"votebitsext"`
}

// GetTicketVoteBitsResult models the data returned from the getticketvotebits
// command.
type GetTicketVoteBitsResult struct {
VoteBits uint16 `json:"votebits"`
VoteBitsExt string `json:"votebitsext"`
VoteBitsData
}

// GetTicketsVoteBitsResult models the data returned from the getticketsvotebits
// command.
type GetTicketsVoteBitsResult struct {
VoteBitsList []VoteBitsData `json:"votebitslist"`
}

// ScriptInfo is the structure representing a redeem script, its hash,
Expand Down
3 changes: 3 additions & 0 deletions rpcserver.go
Expand Up @@ -218,6 +218,8 @@ var rpcAskWallet = map[string]struct{}{
"getreceivedbyaccount": struct{}{},
"getreceivedbyaddress": struct{}{},
"getstakeinfo": struct{}{},
"getticketvotebits": struct{}{},
"getticketsvotebits": struct{}{},
"gettransaction": struct{}{},
"gettxoutsetinfo": struct{}{},
"getunconfirmedbalance": struct{}{},
Expand All @@ -239,6 +241,7 @@ var rpcAskWallet = map[string]struct{}{
"sendmany": struct{}{},
"sendtoaddress": struct{}{},
"setaccount": struct{}{},
"setticketvotebits": struct{}{},
"settxfee": struct{}{},
"signmessage": struct{}{},
"signrawtransaction": struct{}{},
Expand Down

0 comments on commit 95b4e76

Please sign in to comment.