Fix utxo rest API endpoint
This commit is contained in:
parent
3d59bd096b
commit
ad18eda804
@ -1050,7 +1050,8 @@ func (s *PublicServer) apiXpub(r *http.Request, apiVersion int) (interface{}, er
|
||||
func (s *PublicServer) apiUtxo(r *http.Request, apiVersion int) (interface{}, error) {
|
||||
var utxo []api.Utxo
|
||||
var err error
|
||||
if i := strings.LastIndexByte(r.URL.Path, '/'); i > 0 {
|
||||
if i := strings.LastIndex(r.URL.Path, "utxo/"); i > 0 {
|
||||
desc := r.URL.Path[i+5:]
|
||||
onlyConfirmed := false
|
||||
c := r.URL.Query().Get("confirmed")
|
||||
if len(c) > 0 {
|
||||
@ -1063,11 +1064,11 @@ func (s *PublicServer) apiUtxo(r *http.Request, apiVersion int) (interface{}, er
|
||||
if ec != nil {
|
||||
gap = 0
|
||||
}
|
||||
utxo, err = s.api.GetXpubUtxo(r.URL.Path[i+1:], onlyConfirmed, gap)
|
||||
utxo, err = s.api.GetXpubUtxo(desc, onlyConfirmed, gap)
|
||||
if err == nil {
|
||||
s.metrics.ExplorerViews.With(common.Labels{"action": "api-xpub-utxo"}).Inc()
|
||||
} else {
|
||||
utxo, err = s.api.GetAddressUtxo(r.URL.Path[i+1:], onlyConfirmed)
|
||||
utxo, err = s.api.GetAddressUtxo(desc, onlyConfirmed)
|
||||
s.metrics.ExplorerViews.With(common.Labels{"action": "api-address-utxo"}).Inc()
|
||||
}
|
||||
if err == nil && apiVersion == apiV1 {
|
||||
|
||||
@ -811,6 +811,15 @@ func httpTestsBitcoinType(t *testing.T, ts *httptest.Server) {
|
||||
`[{"txid":"3d90d15ed026dc45e19ffb52875ed18fa9e8012ad123d7f7212176e2b0ebdb71","vout":0,"value":"118641975500","height":225494,"confirmations":1,"address":"2N6utyMZfPNUb1Bk8oz7p2JqJrXkq83gegu","path":"m/49'/1'/33'/1/3"}]`,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "apiUtxo v2 xpub",
|
||||
r: newGetRequest(ts.URL + "/api/v2/utxo/" + url.QueryEscape(dbtestdata.TaprootDescriptor)),
|
||||
status: http.StatusOK,
|
||||
contentType: "application/json; charset=utf-8",
|
||||
body: []string{
|
||||
`[]`,
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "apiBalanceHistory Addr2 v2",
|
||||
r: newGetRequest(ts.URL + "/api/v2/balancehistory/mtGXQvBowMkBpnhLckhxhbwYK44Gs9eEtz"),
|
||||
|
||||
Loading…
Reference in New Issue
Block a user