From be14d3b414e527fed60f95f72f632f6742e09766 Mon Sep 17 00:00:00 2001 From: Jack Mallers Date: Tue, 25 Sep 2018 13:13:39 -0500 Subject: [PATCH] fix(utils): dont pass non-whole num to toBitcoin() --- app/lib/utils/btc.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/lib/utils/btc.js b/app/lib/utils/btc.js index 7f635ab0..5e44c444 100644 --- a/app/lib/utils/btc.js +++ b/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 }