ynab-portfolio-monitor/providers/bitcoin/address.go

37 lines
1011 B
Go
Raw Normal View History

2023-11-12 23:50:46 +00:00
package bitcoin
import (
"fmt"
"net/url"
)
2024-03-23 20:06:38 +00:00
type addressData struct {
2023-11-12 23:50:46 +00:00
Address string `json:"address"`
ChainStats struct {
FundedTxoCount int `json:"funded_txo_count"`
FundedTxoSum int `json:"funded_txo_sum"`
SpentTxoCount int `json:"spent_txo_count"`
SpentTxoSum int `json:"spent_txo_sum"`
TxCount int `json:"tx_count"`
} `json:"chain_stats"`
MempoolStats struct {
FundedTxoCount int `json:"funded_txo_count"`
FundedTxoSum int `json:"funded_txo_sum"`
SpentTxoCount int `json:"spent_txo_count"`
SpentTxoSum int `json:"spent_txo_sum"`
TxCount int `json:"tx_count"`
} `json:"mempool_stats"`
}
// GetAddress returns an Address struct populated with data from blockstream.info
// for a given BTC address
2024-03-23 20:06:38 +00:00
func (c *client) getAddress(address string) (*addressData, error) {
addressResponse := &addressData{}
2023-11-12 23:50:46 +00:00
err := c.get(fmt.Sprintf("address/%s", address), addressResponse, url.Values{})
if err != nil {
return nil, err
}
return addressResponse, nil
}