webapi: validate script version in fee transaction (#112)

This commit is contained in:
David Hill 2020-06-05 16:00:13 +00:00 committed by GitHub
parent 1c92856303
commit eeaefab280
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -112,11 +112,15 @@ func payFee(c *gin.Context) {
findAddress:
for _, txOut := range feeTx.TxOut {
if txOut.Version != scriptVersion {
sendErrorResponse("invalid script version", http.StatusBadRequest, c)
return
}
_, addresses, _, err := txscript.ExtractPkScriptAddrs(scriptVersion,
txOut.PkScript, cfg.NetParams)
if err != nil {
log.Errorf("Extract PK error: %v", err)
sendErrorResponse("extract PK error", http.StatusInternalServerError, c)
sendErrorResponse("extract PK error", http.StatusBadRequest, c)
return
}
for _, addr := range addresses {