Adding query option 'confirmed' for address API
Adding query option confirmed=true for address details - if confirmed is of boolean true, then only return confirmed txs
This commit is contained in:
parent
d1a0c9326b
commit
9fa5ee3618
@ -1276,6 +1276,7 @@ func (s *PublicServer) apiTxSpecific(r *http.Request, apiVersion int) (interface
|
|||||||
|
|
||||||
func (s *PublicServer) apiAddress(r *http.Request, apiVersion int) (interface{}, error) {
|
func (s *PublicServer) apiAddress(r *http.Request, apiVersion int) (interface{}, error) {
|
||||||
var addressParam string
|
var addressParam string
|
||||||
|
var err error
|
||||||
i := strings.LastIndexByte(r.URL.Path, '/')
|
i := strings.LastIndexByte(r.URL.Path, '/')
|
||||||
if i > 0 {
|
if i > 0 {
|
||||||
addressParam = r.URL.Path[i+1:]
|
addressParam = r.URL.Path[i+1:]
|
||||||
@ -1283,10 +1284,18 @@ func (s *PublicServer) apiAddress(r *http.Request, apiVersion int) (interface{},
|
|||||||
if len(addressParam) == 0 {
|
if len(addressParam) == 0 {
|
||||||
return nil, api.NewAPIError("Missing address", true)
|
return nil, api.NewAPIError("Missing address", true)
|
||||||
}
|
}
|
||||||
|
onlyConfirmed := false
|
||||||
|
confirmed := r.URL.Query().Get("confirmed")
|
||||||
|
if len(confirmed) > 0 {
|
||||||
|
onlyConfirmed, err = strconv.ParseBool(confirmed)
|
||||||
|
if err != nil {
|
||||||
|
return nil, api.NewAPIError("Parameter 'confirmed' cannot be converted to boolean", true)
|
||||||
|
}
|
||||||
|
}
|
||||||
var address *api.Address
|
var address *api.Address
|
||||||
var err error
|
|
||||||
s.metrics.ExplorerViews.With(common.Labels{"action": "api-address"}).Inc()
|
s.metrics.ExplorerViews.With(common.Labels{"action": "api-address"}).Inc()
|
||||||
page, pageSize, details, filter, _, _ := s.getAddressQueryParams(r, api.AccountDetailsTxidHistory, txsInAPI)
|
page, pageSize, details, filter, _, _ := s.getAddressQueryParams(r, api.AccountDetailsTxidHistory, txsInAPI)
|
||||||
|
filter.OnlyConfirmed = onlyConfirmed
|
||||||
secondaryCoin := strings.ToLower(r.URL.Query().Get("secondary"))
|
secondaryCoin := strings.ToLower(r.URL.Query().Get("secondary"))
|
||||||
address, err = s.api.GetAddress(addressParam, page, pageSize, details, filter, secondaryCoin)
|
address, err = s.api.GetAddress(addressParam, page, pageSize, details, filter, secondaryCoin)
|
||||||
if err == nil && apiVersion == apiV1 {
|
if err == nil && apiVersion == apiV1 {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user