Skip to content

Commit

Permalink
Add stakepooluserinfo and addticket RPC handling (#144)
Browse files Browse the repository at this point in the history
JSON handling for two new legacy RPC functions designed to aid wallets
running stake pools, stakepooluserinfo and addticket, have been added.
  • Loading branch information
cjepson authored and alexlyp committed May 2, 2016
1 parent 5623458 commit f1796b0
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
22 changes: 22 additions & 0 deletions dcrjson/dcrwalletextcmds.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ func NewAccountSyncAddressIndexCmd(acct string, branch int,
}
}

// AddTicketCmd forces a ticket into the wallet stake manager, for example if
// someone made an invalid ticket for a stake pool and the pool manager wanted
// to manually add it.
type AddTicketCmd struct {
TicketHex string `json:"tickethex"`
}

// ConsolidateCmd is a type handling custom marshaling and
// unmarshaling of consolidate JSON wallet extension
// commands.
Expand Down Expand Up @@ -568,6 +575,19 @@ func NewSignRawTransactionsCmd(hexEncodedTxs []string,
}
}

// StakePoolUserInfoCmd defines the stakepooluserinfo JSON-RPC command.
type StakePoolUserInfoCmd struct {
User string
}

// NewStakePoolUserInfoCmd returns a new instance which can be used to issue a
// signrawtransactions JSON-RPC command.
func NewStakePoolUserInfoCmd(user string) *StakePoolUserInfoCmd {
return &StakePoolUserInfoCmd{
User: user,
}
}

// WalletInfoCmd defines the walletinfo JSON-RPC command.
type WalletInfoCmd struct {
}
Expand All @@ -586,6 +606,7 @@ func init() {
MustRegisterCmd("accountaddressindex", (*AccountAddressIndexCmd)(nil), flags)
MustRegisterCmd("accountfetchaddresses", (*AccountFetchAddressesCmd)(nil), flags)
MustRegisterCmd("accountsyncaddressindex", (*AccountSyncAddressIndexCmd)(nil), flags)
MustRegisterCmd("addticket", (*AddTicketCmd)(nil), flags)
MustRegisterCmd("consolidate", (*ConsolidateCmd)(nil), flags)
MustRegisterCmd("createrawsstx", (*CreateRawSStxCmd)(nil), flags)
MustRegisterCmd("createrawssgentx", (*CreateRawSSGenTxCmd)(nil), flags)
Expand Down Expand Up @@ -621,5 +642,6 @@ func init() {
MustRegisterCmd("setticketmaxprice", (*SetTicketMaxPriceCmd)(nil), flags)
MustRegisterCmd("setticketvotebits", (*SetTicketVoteBitsCmd)(nil), flags)
MustRegisterCmd("signrawtransactions", (*SignRawTransactionsCmd)(nil), flags)
MustRegisterCmd("stakepooluserinfo", (*StakePoolUserInfoCmd)(nil), flags)
MustRegisterCmd("walletinfo", (*WalletInfoCmd)(nil), flags)
}
17 changes: 17 additions & 0 deletions dcrjson/dcrwalletextresults.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,23 @@ type SignRawTransactionsResult struct {
Results []SignedTransaction `json:"results"`
}

// PoolUserTicket is the JSON struct corresponding to a stake pool user ticket
// object.
type PoolUserTicket struct {
Status string `json:"status"`
Ticket string `json:"ticket"`
TicketHeight uint32 `json:"ticketheight"`
SpentBy string `json:"spentby"`
SpentByHeight uint32 `json:"spentbyheight"`
}

// StakePoolUserInfoResult models the data returned from the stakepooluserinfo
// command.
type StakePoolUserInfoResult struct {
Tickets []PoolUserTicket `json:"tickets"`
InvalidTickets []string `json:"invalid"`
}

// WalletInfoResult models the data returned from the walletinfo
// command.
type WalletInfoResult struct {
Expand Down
2 changes: 2 additions & 0 deletions rpcserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ var rpcAskWallet = map[string]struct{}{
"accountfetchaddresses": struct{}{},
"accountsyncaddressindex": struct{}{},
"addmultisigaddress": struct{}{},
"addticket": struct{}{},
"backupwallet": struct{}{},
"createencryptedwallet": struct{}{},
"createmultisig": struct{}{},
Expand Down Expand Up @@ -261,6 +262,7 @@ var rpcAskWallet = map[string]struct{}{
"settxfee": struct{}{},
"signmessage": struct{}{},
"signrawtransaction": struct{}{},
"stakepooluserinfo": struct{}{},
"walletinfo": struct{}{},
"walletlock": struct{}{},
"walletpassphrase": struct{}{},
Expand Down

0 comments on commit f1796b0

Please sign in to comment.