remove fee transactions if dcrd rejects it. (#114)

This commit is contained in:
David Hill 2020-06-08 16:31:22 +00:00 committed by GitHub
parent 9f48bae78e
commit 873d89e412
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 1 deletions

View File

@ -95,6 +95,17 @@ func blockConnected() {
feeTxHash, err := dcrdClient.SendRawTransaction(ticket.FeeTxHex) feeTxHash, err := dcrdClient.SendRawTransaction(ticket.FeeTxHex)
if err != nil { if err != nil {
log.Errorf("SendRawTransaction error: %v", err) 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 continue
} }

View File

@ -134,6 +134,7 @@ fields:
- `ticketconfirmed` is true when the ticket transaction has 6 confirmations. - `ticketconfirmed` is true when the ticket transaction has 6 confirmations.
- `feetxreceived` is true when the VSP has received a valid fee transaction. - `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. - `feetxbroadcast` is true when the VSP has broadcast the fee transaction.
- `feeconfirmed` is true when the fee transaction has 6 confirmations. - `feeconfirmed` is true when the fee transaction has 6 confirmations.

View File

@ -220,7 +220,19 @@ findAddress:
feeTxHash, err := dcrdClient.SendRawTransaction(payFeeRequest.FeeTx) feeTxHash, err := dcrdClient.SendRawTransaction(payFeeRequest.FeeTx)
if err != nil { if err != nil {
log.Errorf("SendRawTransaction failed: %v", err) 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 return
} }
ticket.FeeTxHash = feeTxHash ticket.FeeTxHash = feeTxHash