|
|
@ -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 |
|
|
|
} |
|
|
|
|
|
|
|