Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function decimalToSatoshi(number) {
if (!number) {
return number;
}
const toStringNumber = Number(number).toFixed(8);
const splitArr = toStringNumber.split('.');
const integerPart = splitArr[0];
const decimalPart = splitArr.length > 1 ? NP.times(Number(`.${splitArr[1]}`), SATOSHI_CONVERSION) : 0;
const conversionBN = toBN(SATOSHI_CONVERSION);
return toBN(integerPart).mul(conversionBN).add(toBN(decimalPart)).toString(10);
}