You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
23 lines
554 B
23 lines
554 B
import sb from 'satoshi-bitcoin'
|
|
|
|
export function btcToSatoshis(btc) {
|
|
if (btc == undefined || btc === '') return
|
|
|
|
return sb.toSatoshi(btc)
|
|
}
|
|
|
|
export function satoshisToBtc(satoshis) {
|
|
if (satoshis == undefined || satoshis === '') return
|
|
|
|
return sb.toBitcoin(satoshis).toFixed(8)
|
|
}
|
|
|
|
export function satoshisToUsd(satoshis, price) {
|
|
if (satoshis == undefined || satoshis === '') return
|
|
|
|
return btcToUsd(satoshisToBtc(satoshis), price)
|
|
}
|
|
|
|
export function btcToUsd(btc, price) {
|
|
return parseFloat((btc * price).toFixed(2)).toLocaleString('en')
|
|
}
|