From 35c6ac0f53e6558f3c14f274b3109c1480451785 Mon Sep 17 00:00:00 2001 From: jholdstock Date: Tue, 25 Jul 2023 09:37:07 +0100 Subject: [PATCH] wallet: Fix VSP ticket iteration bug. Returning early meant that not all tickets were being attempted. --- wallet/udb/txquery.go | 4 ++-- wallet/wallet.go | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/wallet/udb/txquery.go b/wallet/udb/txquery.go index 7a53df968..d1f58ea93 100644 --- a/wallet/udb/txquery.go +++ b/wallet/udb/txquery.go @@ -205,8 +205,8 @@ type TicketDetails struct { // TicketDetails looks up all recorded details regarding a ticket with some // hash. // -// Not finding a ticket with this hash is not an error. In this case, -// a nil TicketDetiails is returned. +// Not finding a ticket with this hash is not an error. In this case, a nil +// TicketDetails is returned. func (s *Store) TicketDetails(ns walletdb.ReadBucket, txDetails *TxDetails) (*TicketDetails, error) { var ticketDetails = &TicketDetails{} if !stake.IsSStx(&txDetails.MsgTx) { diff --git a/wallet/wallet.go b/wallet/wallet.go index 46d4ab57a..7ecb7d378 100644 --- a/wallet/wallet.go +++ b/wallet/wallet.go @@ -3212,7 +3212,8 @@ func (w *Wallet) GetTicketsPrecise(ctx context.Context, rpcCaller Caller, // The arguments to f may be reused and should not be kept by the caller. // // Because this function does not have any chain client argument, tickets are -// unable to be determined whether or not they have been missed, simply unspent. +// unable to be determined whether or not they have been missed or simply +// unspent. func (w *Wallet) GetTickets(ctx context.Context, f func([]*TicketSummary, *wire.BlockHeader) (bool, error), startBlock, endBlock *BlockIdentifier) error { @@ -3237,7 +3238,7 @@ func (w *Wallet) GetTickets(ctx context.Context, return false, errors.Errorf("%v while trying to get "+ "ticket details for txhash: %v", err, &details[i].Hash) } - // Continue if not a ticket + // Continue if not a ticket. if ticketInfo == nil { continue } @@ -5894,7 +5895,7 @@ func (w *Wallet) ForUnspentUnexpiredTickets(ctx context.Context, ticketHash := *ticketSummary.Ticket.Hash err := f(&ticketHash) if err != nil { - return false, err + continue } }