Skip to content

Commit

Permalink
[release-v1.8] vsp: Only remove confirmed payments
Browse files Browse the repository at this point in the history
The only way to be certain a VSP has acknowledged a fee tx and added a
ticket to its voting wallets is to check FeeTxStatus == "confirmed".
Checking for 6 confirmations on the fee tx is not an adequate
substitute.

For example, if a client has broadcast it's own fee tx rather than
waiting for the VSP to do it, it's possible that the tx could be mined
and have 6+ confs, but the amount paid is not enough, or the payment is
sent to the wrong address.

Backport of 3c8cd47
  • Loading branch information
jholdstock committed Aug 8, 2023
1 parent c4c6c42 commit 7c551ce
Showing 1 changed file with 0 additions and 24 deletions.
24 changes: 0 additions & 24 deletions internal/vsp/feepayment.go
Original file line number Diff line number Diff line change
Expand Up @@ -865,31 +865,7 @@ func (fp *feePayment) confirmPayment() (err error) {

status, err := fp.client.status(ctx, &fp.ticketHash)
if err != nil {

log.Warnf("Rescheduling status check for %v: %v", &fp.ticketHash, err)

// Stop processing if the status check cannot be performed, but
// a significant amount of confirmations are observed on the fee
// transaction.
//
// Otherwise, chedule another confirmation check, in case the
// status API can be performed at a later time or more
// confirmations are observed.
fp.mu.Lock()
feeHash := fp.feeHash
fp.mu.Unlock()
confs, err := w.TxConfirms(ctx, &feeHash)
if err != nil {
return err
}
if confs >= 6 {
fp.remove("confirmed")
err = w.UpdateVspTicketFeeToConfirmed(ctx, &fp.ticketHash, &feeHash, fp.client.URL, fp.client.PubKey)
if err != nil {
return err
}
return nil
}
fp.schedule("confirm payment", fp.confirmPayment)
return nil
}
Expand Down

0 comments on commit 7c551ce

Please sign in to comment.