diff --git a/logic/lightning.js b/logic/lightning.js index b4b47ec..5fc8bf8 100644 --- a/logic/lightning.js +++ b/logic/lightning.js @@ -103,9 +103,9 @@ function decodePaymentRequest(paymentRequest) { // Estimate the cost of opening a channel. We do this by repurposing the existing estimateFee grpc route from lnd. We // generate our own unused address and then feed that into the existing call. Then we add an extra 10 sats per // feerateSatPerByte. This is because the actual cost is slightly more than the default one output estimate. -async function estimateChannelOpenFee(amt, confTarget) { +async function estimateChannelOpenFee(amt, confTarget, sweep) { const address = (await generateAddress()).address; - const baseFeeEstimate = await estimateFee(address, amt, confTarget, false); + const baseFeeEstimate = await estimateFee(address, amt, confTarget, sweep); if (confTarget === 0) { const keys = Object.keys(baseFeeEstimate); diff --git a/routes/v1/lnd/channel.js b/routes/v1/lnd/channel.js index 869d6d8..95fb8b0 100644 --- a/routes/v1/lnd/channel.js +++ b/routes/v1/lnd/channel.js @@ -13,10 +13,11 @@ router.get('/', auth.jwt, safeHandler((req, res) => .then(channels => res.json(channels)) )); -router.get('/estimateFee', auth.jwt, safeHandler(async(req, res, next) => { +router.get('/estimateFee', auth.jwt, safeHandler(async (req, res, next) => { const amt = req.query.amt; // Denominated in Satoshi const confTarget = req.query.confTarget; + const sweep = req.query.sweep === 'true'; try { validator.isPositiveIntegerOrZero(confTarget); @@ -25,7 +26,7 @@ router.get('/estimateFee', auth.jwt, safeHandler(async(req, res, next) => { return next(error); } - return await lightningLogic.estimateChannelOpenFee(parseInt(amt, 10), parseInt(confTarget, 10)) + return await lightningLogic.estimateChannelOpenFee(parseInt(amt, 10), parseInt(confTarget, 10), sweep) .then(response => res.json(response)); }));