Do not export when not required
Some checks reported errors
continuous-integration/drone/push Build encountered an error

This commit is contained in:
Steven Polley 2024-03-23 14:06:38 -06:00
parent 7d52632af6
commit 92a6246052
3 changed files with 9 additions and 9 deletions

View File

@ -5,7 +5,7 @@ import (
"net/url" "net/url"
) )
type Address struct { type addressData struct {
Address string `json:"address"` Address string `json:"address"`
ChainStats struct { ChainStats struct {
FundedTxoCount int `json:"funded_txo_count"` FundedTxoCount int `json:"funded_txo_count"`
@ -25,8 +25,8 @@ type Address struct {
// GetAddress returns an Address struct populated with data from blockstream.info // GetAddress returns an Address struct populated with data from blockstream.info
// for a given BTC address // for a given BTC address
func (c *client) getAddress(address string) (*Address, error) { func (c *client) getAddress(address string) (*addressData, error) {
addressResponse := &Address{} addressResponse := &addressData{}
err := c.get(fmt.Sprintf("address/%s", address), addressResponse, url.Values{}) err := c.get(fmt.Sprintf("address/%s", address), addressResponse, url.Values{})
if err != nil { if err != nil {

View File

@ -7,7 +7,7 @@ import (
const fiatConvertURL = "https://api.coingecko.com/api/v3/coins/bitcoin?localization=false&tickers=false&market_data=true&community_data=false&developer_data=false&sparkline=false" const fiatConvertURL = "https://api.coingecko.com/api/v3/coins/bitcoin?localization=false&tickers=false&market_data=true&community_data=false&developer_data=false&sparkline=false"
type FiatConversion struct { type coinGeckoResponse struct {
MarketData struct { MarketData struct {
CurrentPrice struct { CurrentPrice struct {
CAD int `json:"cad"` CAD int `json:"cad"`
@ -15,8 +15,8 @@ type FiatConversion struct {
} `json:"market_data"` } `json:"market_data"`
} }
func (c *client) ConvertBTCToCAD(amount int) (int, error) { func (c *client) convertBTCToCAD(amount int) (int, error) {
fiatConversion := &FiatConversion{} coinGeckoData := &coinGeckoResponse{}
req, err := http.NewRequest("GET", fiatConvertURL, nil) req, err := http.NewRequest("GET", fiatConvertURL, nil)
if err != nil { if err != nil {
@ -28,10 +28,10 @@ func (c *client) ConvertBTCToCAD(amount int) (int, error) {
return 0, fmt.Errorf("http GET request failed: %v", err) return 0, fmt.Errorf("http GET request failed: %v", err)
} }
err = c.processResponse(res, fiatConversion) err = c.processResponse(res, coinGeckoData)
if err != nil { if err != nil {
return 0, fmt.Errorf("failed to process response: %v", err) return 0, fmt.Errorf("failed to process response: %v", err)
} }
return (amount * int(fiatConversion.MarketData.CurrentPrice.CAD*1000)) / 100000000, nil // one BTC = one hundred million satoshi's return (amount * int(coinGeckoData.MarketData.CurrentPrice.CAD*1000)) / 100000000, nil // one BTC = one hundred million satoshi's
} }

View File

@ -59,7 +59,7 @@ func (p *Provider) GetBalances() ([]int, []string, error) {
satoshiBalance += addressResponse.ChainStats.FundedTxoSum - addressResponse.ChainStats.SpentTxoSum satoshiBalance += addressResponse.ChainStats.FundedTxoSum - addressResponse.ChainStats.SpentTxoSum
} }
fiatBalance, err := p.client.ConvertBTCToCAD(satoshiBalance) fiatBalance, err := p.client.convertBTCToCAD(satoshiBalance)
if err != nil { if err != nil {
return balances, ynabAccountIDs, fmt.Errorf("failed to convert satoshi balance to fiat balance: %v", err) return balances, ynabAccountIDs, fmt.Errorf("failed to convert satoshi balance to fiat balance: %v", err)
} }