UNPKG

@tatumio/utxo-wallet-provider

Version:

UTXO provider with local wallet operations

25 lines 1.3 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.fromSatoshis = exports.toSatoshis = exports.getNetworkConfig = exports.getDefaultDerivationPath = void 0; const bignumber_js_1 = __importDefault(require("bignumber.js")); const consts_1 = require("./consts"); const getDefaultDerivationPath = (network) => consts_1.DERIVATION_PATHS.get(network); exports.getDefaultDerivationPath = getDefaultDerivationPath; const getNetworkConfig = (network) => consts_1.NETWORK_CONFIG.get(network); exports.getNetworkConfig = getNetworkConfig; const toSatoshis = (amount) => { const amountBigNumber = new bignumber_js_1.default(amount); const satoshiValue = amountBigNumber.multipliedBy(10 ** 8); const satoshis = satoshiValue.integerValue(); if (satoshis.toFixed() !== satoshiValue.toFixed() || satoshis.lt(0)) { throw new Error(`Invalid amount ${amountBigNumber.toString()}`); } return Number(satoshis); }; exports.toSatoshis = toSatoshis; const fromSatoshis = (amount) => new bignumber_js_1.default(amount).dividedBy(10 ** 8).toNumber(); exports.fromSatoshis = fromSatoshis; //# sourceMappingURL=utils.js.map