Skip to content

Commit

Permalink
Add JSON RPC handling for per transaction VoteBits manipulation
Browse files Browse the repository at this point in the history
This adds the JSON handling for the per ticket manipulation of the
VoteBits field in wallet.
  • Loading branch information
cjepson committed Feb 17, 2016
1 parent c77e541 commit 2f9fc2d
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 5 deletions.
42 changes: 37 additions & 5 deletions dcrjson/dcrwalletextcmds.go
Expand Up @@ -124,6 +124,23 @@ 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}
}

// GetTicketVotesBitsCmd defines the getticketsvotebits 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}
}

// GetWalletFeeCmd defines the getwalletfee JSON-RPC command.
type GetWalletFeeCmd struct{}

Expand All @@ -134,11 +151,6 @@ func NewGetWalletFeeCmd() *GetWalletFeeCmd {
return &GetWalletFeeCmd{}
}

// NewGetTicketsCmd creates a new GetTicketsCmd.
func NewGetTicketsCmd(includeImmature bool) *GetTicketsCmd {
return &GetTicketsCmd{includeImmature}
}

// ImportScriptCmd is a type for handling custom marshaling and
// unmarshaling of importscript JSON wallet extension commands.
type ImportScriptCmd struct {
Expand Down Expand Up @@ -361,6 +373,24 @@ func NewSetTicketMaxPriceCmd(max float64) *SetTicketMaxPriceCmd {
}
}

// 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
Expand Down Expand Up @@ -390,6 +420,7 @@ func init() {
MustRegisterCmd("getseed", (*GetSeedCmd)(nil), flags)
MustRegisterCmd("getticketmaxprice", (*GetTicketMaxPriceCmd)(nil), flags)
MustRegisterCmd("gettickets", (*GetTicketsCmd)(nil), flags)
MustRegisterCmd("getticketvotebits", (*GetTicketVoteBitsCmd)(nil), flags)
MustRegisterCmd("importscript", (*ImportScriptCmd)(nil), flags)
MustRegisterCmd("notifynewtickets", (*NotifyNewTicketsCmd)(nil), flags)
MustRegisterCmd("notifyspentandmissedtickets",
Expand All @@ -406,5 +437,6 @@ func init() {
MustRegisterCmd("sendtossgen", (*SendToSSGenCmd)(nil), flags)
MustRegisterCmd("sendtossrtx", (*SendToSSRtxCmd)(nil), flags)
MustRegisterCmd("setticketmaxprice", (*SetTicketMaxPriceCmd)(nil), flags)
MustRegisterCmd("setticketvotebits", (*SetTicketVoteBitsCmd)(nil), flags)
MustRegisterCmd("signrawtransactions", (*SignRawTransactionsCmd)(nil), flags)
}
7 changes: 7 additions & 0 deletions dcrjson/dcrwalletextresults.go
Expand Up @@ -46,6 +46,13 @@ type GetTicketsResult struct {
Hashes []string `json:"hashes"`
}

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

// GetWalletFeeResult models the data returned from the getwalletfee command
type GetWalletFeeResult struct {
Fee float64 `json:"fee"`
Expand Down

0 comments on commit 2f9fc2d

Please sign in to comment.