Skip to content

Commit

Permalink
Remove features marked deprecated
Browse files Browse the repository at this point in the history
We are already in an untagged major version update, for both the Go module and
the RPC semantic versions.
  • Loading branch information
jrick committed May 19, 2023
1 parent 8374bd5 commit 9681727
Show file tree
Hide file tree
Showing 10 changed files with 1 addition and 246 deletions.
57 changes: 0 additions & 57 deletions internal/rpc/jsonrpc/methods.go
Expand Up @@ -100,7 +100,6 @@ var handlers = map[string]handler{
"discoverusage": {fn: (*Server).discoverUsage},
"dumpprivkey": {fn: (*Server).dumpPrivKey},
"fundrawtransaction": {fn: (*Server).fundRawTransaction},
"generatevote": {fn: (*Server).generateVote},
"getaccount": {fn: (*Server).getAccount},
"getaccountaddress": {fn: (*Server).getAccountAddress},
"getaddressesbyaccount": {fn: (*Server).getAddressesByAccount},
Expand Down Expand Up @@ -154,7 +153,6 @@ var handlers = map[string]handler{
"redeemmultisigouts": {fn: (*Server).redeemMultiSigOuts},
"renameaccount": {fn: (*Server).renameAccount},
"rescanwallet": {fn: (*Server).rescanWallet},
"revoketickets": {fn: (*Server).revokeTickets},
"sendfrom": {fn: (*Server).sendFrom},
"sendfromtreasury": {fn: (*Server).sendFromTreasury},
"sendmany": {fn: (*Server).sendMany},
Expand Down Expand Up @@ -953,53 +951,6 @@ func (s *Server) fundRawTransaction(ctx context.Context, icmd interface{}) (inte
return res, nil
}

// generateVote handles a generatevote request by constructing a signed
// vote and returning it.
func (s *Server) generateVote(ctx context.Context, icmd interface{}) (interface{}, error) {
cmd := icmd.(*types.GenerateVoteCmd)
w, ok := s.walletLoader.LoadedWallet()
if !ok {
return nil, errUnloadedWallet
}

blockHash, err := chainhash.NewHashFromStr(cmd.BlockHash)
if err != nil {
return nil, rpcError(dcrjson.ErrRPCDecodeHexString, err)
}

ticketHash, err := chainhash.NewHashFromStr(cmd.TicketHash)
if err != nil {
return nil, rpcError(dcrjson.ErrRPCDecodeHexString, err)
}

var voteBitsExt []byte
voteBitsExt, err = hex.DecodeString(cmd.VoteBitsExt)
if err != nil {
return nil, rpcError(dcrjson.ErrRPCDecodeHexString, err)
}
voteBits := stake.VoteBits{
Bits: cmd.VoteBits,
ExtendedBits: voteBitsExt,
}

ssgentx, err := w.GenerateVoteTx(ctx, blockHash, int32(cmd.Height), ticketHash,
voteBits)
if err != nil {
return nil, err
}

var b strings.Builder
b.Grow(2 * ssgentx.SerializeSize())
err = ssgentx.Serialize(hex.NewEncoder(&b))
if err != nil {
return nil, err
}
resp := &types.GenerateVoteResult{
Hex: b.String(),
}
return resp, nil
}

// getAddressesByAccount handles a getaddressesbyaccount request by returning
// all addresses for an account, or an error if the requested account does
// not exist.
Expand Down Expand Up @@ -4224,14 +4175,6 @@ func (s *Server) rescanWallet(ctx context.Context, icmd interface{}) (interface{
return nil, err
}

// revoketickets no longer revokes any tickets since revocations are now
// automatically created per DCP0009.
//
// Deprecated: this method will be removed in the next major RPC API version.
func (s *Server) revokeTickets(ctx context.Context, icmd interface{}) (interface{}, error) {
return nil, nil
}

// stakePoolUserInfo returns the ticket information for a given user from the
// stake pool.
func (s *Server) stakePoolUserInfo(ctx context.Context, icmd interface{}) (interface{}, error) {
Expand Down
4 changes: 1 addition & 3 deletions internal/rpc/jsonrpc/rpcserverhelp.go

Large diffs are not rendered by default.

12 changes: 0 additions & 12 deletions internal/rpchelp/helpdescs_en_US.go
Expand Up @@ -123,15 +123,6 @@ var helpDescsEnUS = map[string]string{
"fundrawtransactionresult-hex": "Funded transaction in hex encoding",
"fundrawtransactionresult-fee": "Absolute fee of funded transaction",

// GenerateVote help.
"generatevote--synopsis": "Returns the vote transaction encoded as a hexadecimal string",
"generatevote-blockhash": "Block hash for the ticket",
"generatevote-height": "Block height for the ticket",
"generatevote-tickethash": "The hash of the ticket",
"generatevote-votebits": "The voteBits to set for the ticket",
"generatevote-votebitsext": "The extended voteBits to set for the ticket",
"generatevoteresult-hex": "The hex encoded transaction",

// GetAccountAddressCmd help.
"getaccountaddress--synopsis": "DEPRECATED -- Returns the most recent external payment address for an account that has not been seen publicly.\n" +
"A new address is generated for the account if the most recently generated address has been seen on the blockchain or in mempool.",
Expand Down Expand Up @@ -721,9 +712,6 @@ var helpDescsEnUS = map[string]string{
"rescanwallet--synopsis": "Rescan the block chain for wallet data, blocking until the rescan completes or exits with an error",
"rescanwallet-beginheight": "The height of the first block to begin the rescan from",

// RevokeTickets help.
"revoketickets--synopsis": "DEPRECATED -- Performs no action and will be removed in a later API version.",

// SendFromCmd help.
"sendfrom--synopsis": "Authors, signs, and sends a transaction that outputs some amount to a payment address.\n" +
"A change output is automatically included to send extra output value back to the original account.",
Expand Down
2 changes: 0 additions & 2 deletions internal/rpchelp/methods.go
Expand Up @@ -43,7 +43,6 @@ var Methods = []struct {
{"discoverusage", nil},
{"dumpprivkey", returnsString},
{"fundrawtransaction", []interface{}{(*types.FundRawTransactionResult)(nil)}},
{"generatevote", []interface{}{(*types.GenerateVoteResult)(nil)}},
{"getaccount", returnsString},
{"getaccountaddress", returnsString},
{"getaddressesbyaccount", returnsStringArray},
Expand Down Expand Up @@ -97,7 +96,6 @@ var Methods = []struct {
{"redeemmultisigouts", []interface{}{(*types.RedeemMultiSigOutResult)(nil)}},
{"renameaccount", nil},
{"rescanwallet", nil},
{"revoketickets", nil},
{"sendfrom", returnsString},
{"sendfromtreasury", returnsString},
{"sendmany", returnsString},
Expand Down
34 changes: 0 additions & 34 deletions rpc/client/dcrd/calls.go
Expand Up @@ -88,40 +88,6 @@ func (r *RPC) ExistsLiveTicket(ctx context.Context, ticket *chainhash.Hash) (boo
return exists, err
}

// ExistsLiveExpiredTickets returns bitsets identifying whether each ticket is
// currently live or expired. Following the activation of DCP0009, this method
// will never return any expired tickets.
//
// Deprecated: Use ExistsLiveTickets instead.
func (r *RPC) ExistsLiveExpiredTickets(ctx context.Context, tickets []*chainhash.Hash) (live, _ bitset.Bytes, err error) {
const op errors.Op = "dcrd.ExistsLiveExpiredTickets"
// Reuse the single json.RawMessage for both calls
ticketArray, err := json.Marshal(hashSliceToStrings(tickets))
if err != nil {
return nil, nil, err
}
errs := make(chan error, 1)
go func() { errs <- exists(ctx, r, "existslivetickets", &live, ticketArray) }()
for i := 0; i < cap(errs); i++ {
if e := <-errs; err == nil && e != nil {
// Must only return after all exists calls are
// known to be completed to avoid a data race on the
// return values. Set the final error to return, and
// only return after all errors have been read.
err = errors.E(op, e)
}
}
return
}

// ExistsExpiredMissedTckets no longer performs any RPC as there should never be
// unspent expired or missed tickets after the activation of DCP0009.
//
// Deprecated: this method will be removed in the next major version.
func (r *RPC) ExistsExpiredMissedTickets(ctx context.Context, tickets []*chainhash.Hash) (_, _ bitset.Bytes, _ error) {
return
}

// UsedAddresses returns a bitset identifying whether each address has been
// publically used on the blockchain. This feature requires the optional dcrd
// existsaddress index to be enabled.
Expand Down
39 changes: 0 additions & 39 deletions rpc/client/dcrd/notifications.go
Expand Up @@ -65,45 +65,6 @@ func RelevantTxAccepted(params json.RawMessage) (tx *wire.MsgTx, err error) {
return
}

// MissedTickets extracts the missed ticket hashes from the parameters of a
// spentandmissedtickets JSON-RPC notification.
//
// Deprecated: The missedtickets notification was removed from dcrd and this
// function will be removed in the next major version.
func MissedTickets(params json.RawMessage) (missed []*chainhash.Hash, err error) {
// Parameters (array):
// 0: Block hash (reversed hex)
// 1: Block height (numeric)
// 2: Stake difficulty (numeric)
// 3: Object of tickets (keyed by ticket hash, value is "missed" or "spent")
//
// Of these, we only need the hashes of missed tickets.
var paramArray []json.RawMessage
err = json.Unmarshal(params, &paramArray)
if err != nil {
return nil, errors.E(errors.Encoding, err)
}
if len(paramArray) < 4 {
return nil, errors.E(errors.Protocol, "missing notification parameters")
}
ticketObj := make(map[string]string)
err = json.Unmarshal(paramArray[3], &ticketObj)
if err != nil {
return nil, errors.E(errors.Encoding, err)
}
for k, v := range ticketObj {
if v != "missed" {
continue
}
hash, err := chainhash.NewHashFromStr(k)
if err != nil {
return nil, errors.E(errors.Encoding, err)
}
missed = append(missed, hash)
}
return missed, nil
}

// TSpend extracts the parameters from a tspend JSON-RPC notification.
func TSpend(params json.RawMessage) (tx *wire.MsgTx, err error) {
// Parameters (array):
Expand Down
8 changes: 0 additions & 8 deletions rpc/client/dcrwallet/methods.go
Expand Up @@ -701,14 +701,6 @@ func (c *Client) FundRawTransaction(ctx context.Context, rawhex string, fundAcco
return res, err
}

// GenerateVote returns hex of an SSGen.
func (c *Client) GenerateVote(ctx context.Context, blockHash *chainhash.Hash, height int64, sstxHash *chainhash.Hash, voteBits uint16, voteBitsExt string) (*types.GenerateVoteResult, error) {
res := new(types.GenerateVoteResult)
err := c.Call(ctx, "generatevote", res, blockHash.String(), height, sstxHash.String(),
voteBits, voteBitsExt)
return res, err
}

// GetInfoWallet calls the getinfo method. It is named differently to avoid a
// naming clash for dcrd clients with a GetInfo method.
func (c *Client) GetInfo(ctx context.Context) (*types.InfoWalletResult, error) {
Expand Down
22 changes: 0 additions & 22 deletions rpc/jsonrpc/types/methods.go
Expand Up @@ -199,27 +199,6 @@ func NewFundRawTransactionCmd(hexString string, fundAccount string, options *Fun
}
}

// GenerateVoteCmd is a type handling custom marshaling and
// unmarshaling of generatevote JSON wallet extension commands.
type GenerateVoteCmd struct {
BlockHash string
Height int64
TicketHash string
VoteBits uint16
VoteBitsExt string
}

// NewGenerateVoteCmd creates a new GenerateVoteCmd.
func NewGenerateVoteCmd(blockhash string, height int64, tickethash string, votebits uint16, voteBitsExt string) *GenerateVoteCmd {
return &GenerateVoteCmd{
BlockHash: blockhash,
Height: height,
TicketHash: tickethash,
VoteBits: votebits,
VoteBitsExt: voteBitsExt,
}
}

// GetAccountCmd defines the getaccount JSON-RPC command.
type GetAccountCmd struct {
Address string
Expand Down Expand Up @@ -1253,7 +1232,6 @@ func init() {
{"discoverusage", (*DiscoverUsageCmd)(nil)},
{"dumpprivkey", (*DumpPrivKeyCmd)(nil)},
{"fundrawtransaction", (*FundRawTransactionCmd)(nil)},
{"generatevote", (*GenerateVoteCmd)(nil)},
{"getaccount", (*GetAccountCmd)(nil)},
{"getaccountaddress", (*GetAccountAddressCmd)(nil)},
{"getaddressesbyaccount", (*GetAddressesByAccountCmd)(nil)},
Expand Down
5 changes: 0 additions & 5 deletions rpc/jsonrpc/types/results.go
Expand Up @@ -11,11 +11,6 @@ type FundRawTransactionResult struct {
Fee float64 `json:"fee"`
}

// GenerateVoteResult models the data from the generatevote command.
type GenerateVoteResult struct {
Hex string `json:"hex"`
}

// GetAccountBalanceResult models the account data from the getbalance command.
type GetAccountBalanceResult struct {
AccountName string `json:"accountname"`
Expand Down
64 changes: 0 additions & 64 deletions wallet/tickets.go
Expand Up @@ -10,52 +10,12 @@ import (
"decred.org/dcrwallet/v3/errors"
"decred.org/dcrwallet/v3/rpc/client/dcrd"
"decred.org/dcrwallet/v3/wallet/walletdb"
"github.com/decred/dcrd/blockchain/stake/v5"
"github.com/decred/dcrd/chaincfg/chainhash"
dcrdtypes "github.com/decred/dcrd/rpc/jsonrpc/types/v4"
"github.com/decred/dcrd/txscript/v4/stdaddr"
"github.com/decred/dcrd/wire"
"golang.org/x/sync/errgroup"
)

// GenerateVoteTx creates a vote transaction for a chosen ticket purchase hash
// using the provided votebits. The ticket purchase transaction must be stored
// by the wallet.
//
// Deprecated: This method will not produce the proper vote subsidy after
// DCP0010 activation.
func (w *Wallet) GenerateVoteTx(ctx context.Context, blockHash *chainhash.Hash, height int32,
ticketHash *chainhash.Hash, voteBits stake.VoteBits) (*wire.MsgTx, error) {
const op errors.Op = "wallet.GenerateVoteTx"

var vote *wire.MsgTx
const dcp0010Active = false
const dcp0012Active = false
err := walletdb.View(ctx, w.db, func(dbtx walletdb.ReadTx) error {
addrmgrNs := dbtx.ReadBucket(waddrmgrNamespaceKey)
txmgrNs := dbtx.ReadBucket(wtxmgrNamespaceKey)
ticketPurchase, err := w.txStore.Tx(txmgrNs, ticketHash)
if err != nil {
return err
}
vote, err = createUnsignedVote(ticketHash, ticketPurchase,
height, blockHash, voteBits, w.subsidyCache, w.chainParams,
dcp0010Active, dcp0012Active)
if err != nil {
return errors.E(op, err)
}
err = w.signVote(addrmgrNs, ticketPurchase, vote)
if err != nil {
return errors.E(op, err)
}
return err
})
if err != nil {
return nil, errors.E(op, err)
}
return vote, nil
}

// LiveTicketHashes returns the hashes of live tickets that the wallet has
// purchased or has voting authority for.
func (w *Wallet) LiveTicketHashes(ctx context.Context, rpcCaller Caller, includeImmature bool) ([]chainhash.Hash, error) {
Expand Down Expand Up @@ -224,27 +184,3 @@ func (w *Wallet) TicketHashesForVotingAddress(ctx context.Context, votingAddr st
}
return ticketHashes, nil
}

// RevokeTickets no longer revokes any tickets since revocations are now
// automatically created per DCP0009.
//
// Deprecated: this method will be removed in the next major version.
func (w *Wallet) RevokeTickets(ctx context.Context, rpcCaller Caller) error {
return nil
}

// RevokeExpiredTickets no longer revokes any tickets since revocations are now
// automatically created per DCP0009.
//
// Deprecated: this method will be removed in the next major version.
func (w *Wallet) RevokeExpiredTickets(ctx context.Context, p Peer) (err error) {
return nil
}

// RevokeTicket no longer revokes any tickets since revocations are now
// automatically created per DCP0009.
//
// Deprecated: this method will be removed in the next major version.
func (w *Wallet) RevokeTicket(ctx context.Context, ticketHash *chainhash.Hash, p Peer) error {
return nil
}

0 comments on commit 9681727

Please sign in to comment.