Mayank
4 years ago
No known key found for this signature in database
GPG Key ID: D037D60476CE748C
2 changed files with
5 additions and
4 deletions
-
logic/lightning.js
-
routes/v1/lnd/channel.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); |
|
|
|
|
|
@ -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)); |
|
|
|
})); |
|
|
|
|
|
|
|