generated from mrz1836/go-template
/
addresses.go
40 lines (35 loc) 路 1.23 KB
/
addresses.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package nownodes
import (
"context"
)
// AddressInfo is the address information returned to the GetAddress request
type AddressInfo struct {
Address string `json:"address"`
Balance string `json:"balance"`
ItemsOnPage uint64 `json:"itemsOnPage"`
Page uint64 `json:"page"`
TotalPages uint64 `json:"totalPages"`
TotalReceived string `json:"totalReceived"`
TotalSent string `json:"totalSent"`
TxIDs []string `json:"txids,omitempty"`
Txs uint64 `json:"txs"`
UnconfirmedBalance string `json:"unconfirmedBalance"`
UnconfirmedTxs uint64 `json:"unconfirmedTxs"`
}
// GetAddress will get address information by a given address
//
// This method supports the following chains: BCH, BSV, BTC, BTCTestnet, BTG, DASH, DOGE, LTC
func (c *Client) GetAddress(ctx context.Context, chain Blockchain, address string) (*AddressInfo, error) {
// Validate the input
if !chain.ValidateAddress(address) {
return nil, ErrInvalidAddress
}
// Fire the HTTP request
info := new(AddressInfo)
if err := blockBookRequest(
ctx, c, getAddressBlockchains, chain, routeGetAddress+address, &info,
); err != nil {
return nil, err
}
return info, nil
}