Browse Source

fix(utils): dont pass non-whole num to toBitcoin()

renovate/lint-staged-8.x
Jack Mallers 6 years ago
parent
commit
be14d3b414
  1. 5
      app/lib/utils/btc.js

5
app/lib/utils/btc.js

@ -54,7 +54,10 @@ export function bitsToFiat(bits, price) {
export function satoshisToBtc(satoshis) { export function satoshisToBtc(satoshis) {
if (satoshis === undefined || satoshis === null || satoshis === '') return null if (satoshis === undefined || satoshis === null || satoshis === '') return null
const btcAmount = sb.toBitcoin(satoshis).toFixed(8) // Make sure we are not passing a non-whole number to sb.toBitcoin(). If the number isn't whole we round up
const numSats = satoshis % 1 === 0 ? satoshis : Math.ceil(satoshis)
const btcAmount = sb.toBitcoin(numSats).toFixed(8)
return btcAmount > 0 ? btcAmount : btcAmount * -1 return btcAmount > 0 ? btcAmount : btcAmount * -1
} }

Loading…
Cancel
Save