Skip to content

Commit 0868ba3

Browse files
committed
workaround ln-service bug
1 parent 4da1359 commit 0868ba3

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

api/lnd/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ export async function estimateRouteFeeProbe ({ lnd, request, maxFeeMsat, timeout
6969
const { htlcs: [{ route: { total_fees_msat: routingFeeMsat, total_time_lock: timeLockDelay } }] } = probe
7070
return {
7171
routingFeeMsat: toPositiveNumber(routingFeeMsat),
72-
timeLockDelay: toPositiveNumber(timeLockDelay)
72+
// subtract the cltv delta of the invoice to emulate estimateRouteFee
73+
timeLockDelay: toPositiveNumber(timeLockDelay - inv.cltv_delta)
7374
}
7475
}
7576

wallets/server/wrap.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ const INCOMING_EXPIRATION_BUFFER_MSECS = 120_000 // the buffer enforce for the i
1010
const MAX_OUTGOING_CLTV_DELTA = 1000 // the maximum cltv delta we'll allow for the outgoing invoice
1111
export const MIN_SETTLEMENT_CLTV_DELTA = 80 // the minimum blocks we'll leave for settling the incoming invoice
1212
const FEE_ESTIMATE_TIMEOUT_SECS = 5 // the timeout for the fee estimate request
13+
// https://github.com/alexbosworth/lightning/issues/207 - ln service bug
14+
const XXX_CLTV_DELTA_BUFFER_FOR_LN_SERVICE_BUG = 46 // the buffer to add for the cltv delta to account for the ln service bug
1315

1416
/*
1517
The wrapInvoice function is used to wrap an outgoing invoice with the necessary parameters for an incoming hold invoice.
@@ -165,7 +167,7 @@ async function wrapBolt11Params ({ msats, bolt11, maxRoutingFeeMsats, hideInvoic
165167
*/
166168
wrapped.cltv_delta = toPositiveNumber(
167169
toPositiveNumber(timeLockDelay) + toPositiveNumber(inv.cltv_delta) -
168-
toPositiveNumber(blockHeight) + MIN_SETTLEMENT_CLTV_DELTA)
170+
toPositiveNumber(blockHeight) + MIN_SETTLEMENT_CLTV_DELTA + XXX_CLTV_DELTA_BUFFER_FOR_LN_SERVICE_BUG)
169171
console.log('routingFeeMsat', routingFeeMsat, 'wrapped cltv_delta', wrapped.cltv_delta,
170172
'timeLockDelay', timeLockDelay, 'inv.cltv_delta', inv.cltv_delta, 'blockHeight', blockHeight)
171173

0 commit comments

Comments
 (0)