Browse Source

Merge pull request #821 from LN-Zap/fix/satoshis-crash

fix(utils): dont pass non-whole num to toBitcoin()
renovate/lint-staged-8.x
Tom Kirkpatrick 6 years ago
committed by GitHub
parent
commit
88fcf7537a
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  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) {
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
}

Loading…
Cancel
Save