Skip to content

Commit

Permalink
wallet: unlock outpoints in case of fee processment fail
Browse files Browse the repository at this point in the history
  • Loading branch information
vctt94 committed Sep 23, 2020
1 parent 5c7f83d commit 549897a
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions wallet/createtx.go
Original file line number Diff line number Diff line change
Expand Up @@ -1536,14 +1536,19 @@ func (w *Wallet) purchaseTickets(ctx context.Context, op errors.Op,
if req.VSPFeePaymentProcess != nil {
unlockCredits = false
for i, ticketHash := range purchaseTicketsResponse.TicketHashes {
_, err := req.VSPFeePaymentProcess(ctx, ticketHash, vspFeeCredits[i])
_, err = req.VSPFeePaymentProcess(ctx, ticketHash, vspFeeCredits[i])
if err != nil {
// TODO save fee tx on db in case of failure?
return purchaseTicketsResponse, err
// unlock outpoints in case of error
log.Errorf("vsp ticket %v fee proccessment failed: %v", ticketHash, err)
for _, outpoint := range vspFeeCredits[i] {
w.UnlockOutpoint(&outpoint.OutPoint.Hash, outpoint.OutPoint.Index)
}
continue
}
}
}
return purchaseTicketsResponse, nil

return purchaseTicketsResponse, err
}

// ReserveOutputsForAmount returns locked spendable outpoints from the given
Expand Down

0 comments on commit 549897a

Please sign in to comment.