mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-06-06 06:06:49 +00:00
[NOD-462] Add error message when address is invalid for UTXO API request (#492)
* [NOD-462] Add error message when address is invalid * [NOD-462] Fix error message * [NOD-462] Remove function name from error message
This commit is contained in:
parent
6e4b18a498
commit
9a54b286c9
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user