Skip to content

Commit 484b413

Browse files
committed
fix not counting final cltv delta
1 parent b775a25 commit 484b413

File tree

2 files changed

+2
-7
lines changed

2 files changed

+2
-7
lines changed

api/lnd/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,7 @@ 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-
// because we are simulating estimateRouteFee's probe, we remove the final hop's cltv_delta
73-
timeLockDelay: toPositiveNumber(timeLockDelay - inv.cltv_delta)
72+
timeLockDelay: toPositiveNumber(timeLockDelay)
7473
}
7574
}
7675

wallets/server/wrap.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@ 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-
// the buffer in case we underestimated the cltv delta with our probe
14-
// also ln-service enforces a 3 block buffer ontop of the final hop's cltv delta
15-
// preventing outgoing cltv limits that may be exact from being sent
16-
const CLTV_DELTA_BUFFER = 10
1713

1814
/*
1915
The wrapInvoice function is used to wrap an outgoing invoice with the necessary parameters for an incoming hold invoice.
@@ -169,7 +165,7 @@ async function wrapBolt11Params ({ msats, bolt11, maxRoutingFeeMsats, hideInvoic
169165
*/
170166
wrapped.cltv_delta = toPositiveNumber(
171167
toPositiveNumber(timeLockDelay) + toPositiveNumber(inv.cltv_delta) -
172-
toPositiveNumber(blockHeight) + MIN_SETTLEMENT_CLTV_DELTA + CLTV_DELTA_BUFFER)
168+
toPositiveNumber(blockHeight) + MIN_SETTLEMENT_CLTV_DELTA)
173169
console.log('routingFeeMsat', routingFeeMsat, 'wrapped cltv_delta', wrapped.cltv_delta,
174170
'timeLockDelay', timeLockDelay, 'inv.cltv_delta', inv.cltv_delta, 'blockHeight', blockHeight)
175171

0 commit comments

Comments
 (0)