diff --git a/apiserver/controllers/transaction.go b/apiserver/controllers/transaction.go index 876895fc0..e4b9f2c8b 100644 --- a/apiserver/controllers/transaction.go +++ b/apiserver/controllers/transaction.go @@ -5,6 +5,7 @@ import ( "encoding/hex" "encoding/json" "fmt" + "github.com/daglabs/btcd/util" "net/http" "github.com/daglabs/btcd/apiserver/apimodels" @@ -147,6 +148,13 @@ func areTxsInBlock(blockID uint64, txIDs []uint64) (map[uint64]bool, error) { // GetUTXOsByAddressHandler searches for all UTXOs that belong to a certain address. func GetUTXOsByAddressHandler(address string) (interface{}, error) { + _, err := util.DecodeAddress(address, config.ActiveConfig().ActiveNetParams.Prefix) + if err != nil { + return nil, httpserverutils.NewHandlerErrorWithCustomClientMessage(http.StatusUnprocessableEntity, + errors.Wrap(err, "error decoding address"), + "The given address is not a well-formatted P2PKH or P2SH address.") + } + db, err := database.DB() if err != nil { return nil, err