diff --git a/providers/bitcoinElectrum/fiat.go b/providers/bitcoinElectrum/fiat.go index 96a9595..dba6de5 100644 --- a/providers/bitcoinElectrum/fiat.go +++ b/providers/bitcoinElectrum/fiat.go @@ -18,7 +18,7 @@ type coinGeckoResponse struct { } `json:"market_data"` } -func convertBTCToCAD(amount int, coinGeckoApiKey string) (int, error) { +func convertBTCToCAD(amount int64, coinGeckoApiKey string) (int64, error) { coinGeckoData := &coinGeckoResponse{} req, err := http.NewRequest("GET", fmt.Sprintf("%s&x-cg-demo-api-key=%s", fiatConvertURL, coinGeckoApiKey), nil) @@ -37,7 +37,7 @@ func convertBTCToCAD(amount int, coinGeckoApiKey string) (int, error) { return 0, fmt.Errorf("failed to process response: %v", err) } - return (amount * int(coinGeckoData.MarketData.CurrentPrice.CAD*1000)) / 100000000, nil // one BTC = one hundred million satoshi's + return (amount * int64(coinGeckoData.MarketData.CurrentPrice.CAD*1000)) / 100000000, nil // one BTC = one hundred million satoshi's } // processResponse takes the body of an HTTP response, and either returns diff --git a/providers/bitcoinElectrum/providerImpl.go b/providers/bitcoinElectrum/providerImpl.go index 90995de..61228c2 100644 --- a/providers/bitcoinElectrum/providerImpl.go +++ b/providers/bitcoinElectrum/providerImpl.go @@ -58,5 +58,15 @@ func (p *Provider) GetBalances() ([]int, []string, error) { wg.Wait() - return nil, nil, nil + cad, err := convertBTCToCAD(totalSats, p.coinGeckoApiKey) + if err != nil { + return nil, nil, fmt.Errorf("failed to convert sats to CAD: %v", err) + } + + balances := make([]int, 0) + accounts := make([]string, 0) + balances = append(balances, int(cad)) + accounts = append(accounts, p.ynabAccountID) + + return balances, accounts, nil }