Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove stakepool operating mode. #2403

Merged
merged 1 commit into from
Sep 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions config.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (c) 2013-2016 The btcsuite developers
// Copyright (c) 2015-2020 The Decred developers
// Copyright (c) 2015-2024 The Decred developers
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.

Expand Down Expand Up @@ -56,7 +56,6 @@ const (
defaultPass = ""
defaultPromptPublicPass = false
defaultGapLimit = wallet.DefaultGapLimit
defaultStakePoolColdExtKey = ""
defaultAllowHighFees = false
defaultAccountGapLimit = wallet.DefaultAccountGapLimit
defaultDisableCoinTypeUpgrades = false
Expand Down Expand Up @@ -115,7 +114,6 @@ type config struct {
PoolFees float64 `long:"poolfees" description:"VSP fee percentage (1.00 equals 1.00% fee)"`
GapLimit uint32 `long:"gaplimit" description:"Allowed unused address gap between used addresses of accounts"`
WatchLast uint32 `long:"watchlast" description:"Limit watched previous addresses of each HD account branch"`
StakePoolColdExtKey string `long:"stakepoolcoldextkey" description:"xpub:maxindex for fee addresses (VSP-only option)"`
ManualTickets bool `long:"manualtickets" description:"Do not discover new tickets through network synchronization"`
AllowHighFees bool `long:"allowhighfees" description:"Do not perform high fee checks"`
RelayFee *cfgutil.AmountFlag `long:"txfee" description:"Transaction fee per kilobyte"`
Expand Down Expand Up @@ -380,7 +378,6 @@ func loadConfig(ctx context.Context) (*config, []string, error) {
EnableVoting: defaultEnableVoting,
PurchaseAccount: defaultPurchaseAccount,
GapLimit: defaultGapLimit,
StakePoolColdExtKey: defaultStakePoolColdExtKey,
AllowHighFees: defaultAllowHighFees,
RelayFee: cfgutil.NewAmountFlag(txrules.DefaultRelayFeePerKb),
PoolAddress: cfgutil.NewAddressFlag(),
Expand Down
11 changes: 5 additions & 6 deletions dcrwallet.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (c) 2013-2015 The btcsuite developers
// Copyright (c) 2015-2023 The Decred developers
// Copyright (c) 2015-2024 The Decred developers
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.

Expand Down Expand Up @@ -167,11 +167,10 @@ func run(ctx context.Context) error {
// wallet. Otherwise, loading is deferred so it can be performed over RPC.
dbDir := networkDir(cfg.AppDataDir.Value, activeNet.Params)
stakeOptions := &ldr.StakeOptions{
VotingEnabled: cfg.EnableVoting,
VotingAddress: cfg.TBOpts.votingAddress,
PoolAddress: cfg.poolAddress,
PoolFees: cfg.PoolFees,
StakePoolColdExtKey: cfg.StakePoolColdExtKey,
VotingEnabled: cfg.EnableVoting,
VotingAddress: cfg.TBOpts.votingAddress,
PoolAddress: cfg.poolAddress,
PoolFees: cfg.PoolFees,
}
loader := ldr.NewLoader(activeNet.Params, dbDir, stakeOptions,
cfg.GapLimit, cfg.WatchLast, cfg.AllowHighFees, cfg.RelayFee.Amount,
Expand Down
14 changes: 5 additions & 9 deletions internal/loader/loader.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Copyright (c) 2015-2018 The btcsuite developers
// Copyright (c) 2017-2020 The Decred developers
// Copyright (c) 2017-2024 The Decred developers
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.

Expand Down Expand Up @@ -54,11 +54,10 @@ type Loader struct {

// StakeOptions contains the various options necessary for stake mining.
type StakeOptions struct {
VotingEnabled bool
VotingAddress stdaddr.StakeAddress
PoolAddress stdaddr.StakeAddress
PoolFees float64
StakePoolColdExtKey string
VotingEnabled bool
VotingAddress stdaddr.StakeAddress
PoolAddress stdaddr.StakeAddress
PoolFees float64
}

// NewLoader constructs a Loader.
Expand Down Expand Up @@ -185,7 +184,6 @@ func (l *Loader) CreateWatchingOnlyWallet(ctx context.Context, extendedPubKey st
AccountGapLimit: l.accountGapLimit,
DisableCoinTypeUpgrades: l.disableCoinTypeUpgrades,
DisableMixing: l.disableMixing,
StakePoolColdExtKey: so.StakePoolColdExtKey,
ManualTickets: l.manualTickets,
AllowHighFees: l.allowHighFees,
RelayFee: l.relayFee,
Expand Down Expand Up @@ -277,7 +275,6 @@ func (l *Loader) CreateNewWallet(ctx context.Context, pubPassphrase, privPassphr
WatchLast: l.watchLast,
AccountGapLimit: l.accountGapLimit,
DisableCoinTypeUpgrades: l.disableCoinTypeUpgrades,
StakePoolColdExtKey: so.StakePoolColdExtKey,
ManualTickets: l.manualTickets,
AllowHighFees: l.allowHighFees,
RelayFee: l.relayFee,
Expand Down Expand Up @@ -338,7 +335,6 @@ func (l *Loader) OpenExistingWallet(ctx context.Context, pubPassphrase []byte) (
WatchLast: l.watchLast,
AccountGapLimit: l.accountGapLimit,
DisableCoinTypeUpgrades: l.disableCoinTypeUpgrades,
StakePoolColdExtKey: so.StakePoolColdExtKey,
ManualTickets: l.manualTickets,
AllowHighFees: l.allowHighFees,
RelayFee: l.relayFee,
Expand Down
97 changes: 3 additions & 94 deletions internal/rpc/jsonrpc/methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ import (

// API version constants
const (
jsonrpcSemverString = "9.2.0"
jsonrpcSemverMajor = 9
jsonrpcSemverMinor = 2
jsonrpcSemverString = "10.0.0"
jsonrpcSemverMajor = 10
jsonrpcSemverMinor = 0
jsonrpcSemverPatch = 0
)

Expand Down Expand Up @@ -171,11 +171,9 @@ var handlers = map[string]handler{
"signrawtransaction": {fn: (*Server).signRawTransaction},
"signrawtransactions": {fn: (*Server).signRawTransactions},
"spendoutputs": {fn: (*Server).spendOutputs},
"stakepooluserinfo": {fn: (*Server).stakePoolUserInfo},
"sweepaccount": {fn: (*Server).sweepAccount},
"syncstatus": {fn: (*Server).syncStatus},
"ticketinfo": {fn: (*Server).ticketInfo},
"ticketsforaddress": {fn: (*Server).ticketsForAddress},
"treasurypolicy": {fn: (*Server).treasuryPolicy},
"tspendpolicy": {fn: (*Server).tspendPolicy},
"unlockaccount": {fn: (*Server).unlockAccount},
Expand Down Expand Up @@ -4343,67 +4341,6 @@ func (s *Server) spendOutputs(ctx context.Context, icmd any) (any, error) {
return hash.String(), nil
}

// stakePoolUserInfo returns the ticket information for a given user from the
// stake pool.
func (s *Server) stakePoolUserInfo(ctx context.Context, icmd any) (any, error) {
cmd := icmd.(*types.StakePoolUserInfoCmd)
w, ok := s.walletLoader.LoadedWallet()
if !ok {
return nil, errUnloadedWallet
}

userAddr, err := decodeStakeAddress(cmd.User, w.ChainParams())
if err != nil {
return nil, err
}
spui, err := w.StakePoolUserInfo(ctx, userAddr)
if err != nil {
return nil, err
}

resp := new(types.StakePoolUserInfoResult)
resp.Tickets = make([]types.PoolUserTicket, 0, len(spui.Tickets))
resp.InvalidTickets = make([]string, 0, len(spui.InvalidTickets))
_, height := w.MainChainTip(ctx)
for _, ticket := range spui.Tickets {
var ticketRes types.PoolUserTicket

status := ""
switch ticket.Status {
case udb.TSImmatureOrLive:
maturedHeight := int32(ticket.HeightTicket + uint32(w.ChainParams().TicketMaturity) + 1)

if height >= maturedHeight {
status = "live"
} else {
status = "immature"
}
case udb.TSVoted:
status = "voted"
case udb.TSMissed:
status = "missed"
if ticket.HeightSpent-ticket.HeightTicket >= w.ChainParams().TicketExpiry {
status = "expired"
}
}
ticketRes.Status = status

ticketRes.Ticket = ticket.Ticket.String()
ticketRes.TicketHeight = ticket.HeightTicket
ticketRes.SpentBy = ticket.SpentBy.String()
ticketRes.SpentByHeight = ticket.HeightSpent

resp.Tickets = append(resp.Tickets, ticketRes)
}
for _, invalid := range spui.InvalidTickets {
invalidTicket := invalid.String()

resp.InvalidTickets = append(resp.InvalidTickets, invalidTicket)
}

return resp, nil
}

func (s *Server) ticketInfo(ctx context.Context, icmd any) (any, error) {
cmd := icmd.(*types.TicketInfoCmd)
w, ok := s.walletLoader.LoadedWallet()
Expand Down Expand Up @@ -4481,34 +4418,6 @@ func (s *Server) ticketInfo(ctx context.Context, icmd any) (any, error) {
return res, err
}

// ticketsForAddress retrieves all ticket hashes that have the passed voting
// address. It will only return tickets that are in the mempool or blockchain,
// and should not return pruned tickets.
func (s *Server) ticketsForAddress(ctx context.Context, icmd any) (any, error) {
cmd := icmd.(*types.TicketsForAddressCmd)
w, ok := s.walletLoader.LoadedWallet()
if !ok {
return nil, errUnloadedWallet
}

addr, err := stdaddr.DecodeAddress(cmd.Address, w.ChainParams())
if err != nil {
return nil, err
}

ticketHashes, err := w.TicketHashesForVotingAddress(ctx, addr)
if err != nil {
return nil, err
}

ticketHashStrs := make([]string, 0, len(ticketHashes))
for _, hash := range ticketHashes {
ticketHashStrs = append(ticketHashStrs, hash.String())
}

return dcrdtypes.TicketsForAddressResult{Tickets: ticketHashStrs}, nil
}

func isNilOrEmpty(s *string) bool {
return s == nil || *s == ""
}
Expand Down
Loading
Loading