diff --git a/background/background.go b/background/background.go index 598e4c6..882c8b6 100644 --- a/background/background.go +++ b/background/background.go @@ -95,6 +95,17 @@ func blockConnected() { feeTxHash, err := dcrdClient.SendRawTransaction(ticket.FeeTxHex) if err != nil { log.Errorf("SendRawTransaction error: %v", err) + + // Unset fee related fields and update the database. + ticket.FeeTxHex = "" + ticket.VotingWIF = "" + ticket.VoteChoices = make(map[string]string) + + err = db.UpdateTicket(ticket) + if err != nil { + log.Errorf("UpdateTicket error: %v", err) + } + log.Infof("Removed fee transaction for ticket %v", ticket.Hash) continue } diff --git a/docs/api.md b/docs/api.md index 424954c..61d8fa6 100644 --- a/docs/api.md +++ b/docs/api.md @@ -134,6 +134,7 @@ fields: - `ticketconfirmed` is true when the ticket transaction has 6 confirmations. - `feetxreceived` is true when the VSP has received a valid fee transaction. + If the broadcast of the fee transaction fails, this will be reset to false. - `feetxbroadcast` is true when the VSP has broadcast the fee transaction. - `feeconfirmed` is true when the fee transaction has 6 confirmations. diff --git a/webapi/payfee.go b/webapi/payfee.go index 1e5e38e..691e4f1 100644 --- a/webapi/payfee.go +++ b/webapi/payfee.go @@ -220,7 +220,19 @@ findAddress: feeTxHash, err := dcrdClient.SendRawTransaction(payFeeRequest.FeeTx) if err != nil { log.Errorf("SendRawTransaction failed: %v", err) - sendError(errInternalError, c) + + // Unset fee related fields and update the database. + ticket.FeeTxHex = "" + ticket.VotingWIF = "" + ticket.VoteChoices = make(map[string]string) + + err = db.UpdateTicket(ticket) + if err != nil { + log.Errorf("UpdateTicket error: %v", err) + } + log.Infof("Removed fee transaction for ticket %v", ticket.Hash) + + sendErrorWithMsg("could not broadcast fee transaction", errInvalidFeeTx, c) return } ticket.FeeTxHash = feeTxHash