diff --git a/conversions.go b/conversions.go index 5854649..cef083e 100644 --- a/conversions.go +++ b/conversions.go @@ -3,7 +3,6 @@ package bsvrates import ( "context" "fmt" - "strconv" "github.com/mrz1836/go-whatsonchain" ) @@ -32,10 +31,7 @@ func (c *Client) GetConversion(ctx context.Context, currency Currency, amount fl case ProviderWhatsOnChain: var response *whatsonchain.ExchangeRate if response, err = c.WhatsOnChain().GetExchangeRate(ctx); err == nil && response != nil { - var rate float64 - if rate, err = strconv.ParseFloat(response.Rate, 64); err == nil { - satoshis, err = ConvertPriceToSatoshis(rate, amount) - } + satoshis, err = ConvertPriceToSatoshis(response.Rate, amount) } case providerLast: err = fmt.Errorf("provider unknown") diff --git a/mock_whatsonchain_test.go b/mock_whatsonchain_test.go index ef69c79..72697d0 100644 --- a/mock_whatsonchain_test.go +++ b/mock_whatsonchain_test.go @@ -3,6 +3,7 @@ package bsvrates import ( "context" "errors" + "time" "github.com/mrz1836/go-whatsonchain" ) @@ -34,7 +35,8 @@ type mockWOCValid struct { func (m *mockWOCValid) GetExchangeRate(_ context.Context) (rate *whatsonchain.ExchangeRate, err error) { rate = &whatsonchain.ExchangeRate{ - Rate: "159.01", + Rate: 159.01, + Time: time.Now().Unix(), Currency: CurrencyToName(CurrencyDollars), } diff --git a/rates.go b/rates.go index 20319e6..2d8082b 100644 --- a/rates.go +++ b/rates.go @@ -6,7 +6,6 @@ package bsvrates import ( "context" "fmt" - "strconv" "github.com/mrz1836/go-whatsonchain" ) @@ -33,7 +32,7 @@ func (c *Client) GetRate(ctx context.Context, currency Currency) (rate float64, case ProviderWhatsOnChain: var response *whatsonchain.ExchangeRate if response, err = c.WhatsOnChain().GetExchangeRate(ctx); err == nil && response != nil { - rate, err = strconv.ParseFloat(response.Rate, 64) + rate = response.Rate } case providerLast: err = fmt.Errorf("provider unknown")