Skip to content

Commit

Permalink
wallet - increment counter if there was change when checking melt quo…
Browse files Browse the repository at this point in the history
…te state
  • Loading branch information
elnosh committed Oct 31, 2024
1 parent b0f7770 commit 997fca4
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions wallet/wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -870,9 +870,21 @@ func (w *Wallet) CheckMeltQuoteState(quoteId string) (*nut05.PostMeltQuoteBolt11
return nil, err
}

pendingProofs := w.db.GetPendingProofsByQuoteId(quoteId)
var keysetId string
if len(pendingProofs) > 0 {
keysetId = pendingProofs[0].Id
}
if err := w.db.DeletePendingProofsByQuoteId(quoteId); err != nil {
return nil, fmt.Errorf("error removing pending proofs: %v", err)
}
change := len(quote.Change)
// increment the counter if there was change from this quote
if change > 0 {
if err := w.db.IncrementKeysetCounter(keysetId, uint32(change)); err != nil {
return nil, fmt.Errorf("error incrementing keyset counter: %v", err)
}
}
}

if (quote.State == nut05.Unknown && !quote.Paid) || quote.State == nut05.Unpaid {
Expand Down

0 comments on commit 997fca4

Please sign in to comment.