HTTP 428 when fee tx references unknown outputs. (#195)
JSON body will be `{"code": 16, "message":"fee transaction could not be broadcast due to unknown outputs"}`
This commit is contained in:
parent
56a5aa5b1d
commit
b40681d38e
@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
- Success responses use HTTP status 200 and a JSON encoded body.
|
- Success responses use HTTP status 200 and a JSON encoded body.
|
||||||
|
|
||||||
- Error responses use HTTP status 500 to indicate a server error or 400 to
|
- Error responses use HTTP status 500 to indicate a server error or 4XX to
|
||||||
indiciate a client error, and will include a JSON body describing the error.
|
indiciate a client error, and will include a JSON body describing the error.
|
||||||
For example:
|
For example:
|
||||||
|
|
||||||
|
|||||||
@ -25,6 +25,7 @@ const (
|
|||||||
errInvalidTicket
|
errInvalidTicket
|
||||||
errCannotBroadcastTicket
|
errCannotBroadcastTicket
|
||||||
errCannotBroadcastFee
|
errCannotBroadcastFee
|
||||||
|
errCannotBroadcastFeeUnknownOutputs
|
||||||
)
|
)
|
||||||
|
|
||||||
// httpStatus maps application error codes to HTTP status codes.
|
// httpStatus maps application error codes to HTTP status codes.
|
||||||
@ -62,6 +63,8 @@ func (e apiError) httpStatus() int {
|
|||||||
return http.StatusInternalServerError
|
return http.StatusInternalServerError
|
||||||
case errCannotBroadcastFee:
|
case errCannotBroadcastFee:
|
||||||
return http.StatusInternalServerError
|
return http.StatusInternalServerError
|
||||||
|
case errCannotBroadcastFeeUnknownOutputs:
|
||||||
|
return http.StatusPreconditionRequired
|
||||||
default:
|
default:
|
||||||
return http.StatusInternalServerError
|
return http.StatusInternalServerError
|
||||||
}
|
}
|
||||||
@ -102,6 +105,8 @@ func (e apiError) defaultMessage() string {
|
|||||||
return "ticket transaction could not be broadcast"
|
return "ticket transaction could not be broadcast"
|
||||||
case errCannotBroadcastFee:
|
case errCannotBroadcastFee:
|
||||||
return "fee transaction could not be broadcast"
|
return "fee transaction could not be broadcast"
|
||||||
|
case errCannotBroadcastFeeUnknownOutputs:
|
||||||
|
return "fee transaction could not be broadcast due to unknown outputs"
|
||||||
default:
|
default:
|
||||||
return "unknown error"
|
return "unknown error"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,6 +5,7 @@
|
|||||||
package webapi
|
package webapi
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/decred/dcrd/blockchain/v3"
|
"github.com/decred/dcrd/blockchain/v3"
|
||||||
@ -246,7 +247,12 @@ findAddress:
|
|||||||
funcName, ticket.Hash, err)
|
funcName, ticket.Hash, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
sendErrorWithMsg("could not broadcast fee transaction", errCannotBroadcastFee, c)
|
if strings.Contains(err.Error(),
|
||||||
|
"references outputs of unknown or fully-spent transaction") {
|
||||||
|
sendError(errCannotBroadcastFeeUnknownOutputs, c)
|
||||||
|
} else {
|
||||||
|
sendError(errCannotBroadcastFee, c)
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user