Skip to content

Commit

Permalink
enabled gettickets for rpc+spv
Browse files Browse the repository at this point in the history
  • Loading branch information
buck54321 committed Jan 5, 2024
1 parent 3c1d19e commit 1e6f891
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
5 changes: 1 addition & 4 deletions internal/rpc/jsonrpc/methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -2564,10 +2564,7 @@ func (s *Server) getTickets(ctx context.Context, icmd any) (any, error) {
}

n, _ := s.walletLoader.NetworkBackend()
rpc, ok := n.(*dcrd.RPC)
if !ok {
return nil, errRPCClientNotConnected
}
rpc, _ := n.(*dcrd.RPC) // nil rpc indicates SPV to LiveTicketHashes

ticketHashes, err := w.LiveTicketHashes(ctx, rpc, cmd.IncludeImmature)
if err != nil {
Expand Down
8 changes: 7 additions & 1 deletion wallet/tickets.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ import (
)

// LiveTicketHashes returns the hashes of live tickets that the wallet has
// purchased or has voting authority for.
// purchased or has voting authority for. rpcCaller can be nil if this is an
// SPV wallet.
func (w *Wallet) LiveTicketHashes(ctx context.Context, rpcCaller Caller, includeImmature bool) ([]chainhash.Hash, error) {
const op errors.Op = "wallet.LiveTicketHashes"

Expand Down Expand Up @@ -75,6 +76,11 @@ func (w *Wallet) LiveTicketHashes(ctx context.Context, rpcCaller Caller, include
return nil, errors.E(op, err)
}

// SPV wallet can't evaluate extraTickets.
if rpcCaller == nil {
return ticketHashes, nil
}

// Determine if the extra tickets are immature or possibly live. Because
// these transactions are not part of the wallet's transaction history, dcrd
// must be queried for their blockchain height. This functionality requires
Expand Down

0 comments on commit 1e6f891

Please sign in to comment.