@@ -292,15 +292,25 @@ static struct command_result *found_best_peer(struct command *cmd,
292
292
* after `invoice_created_at`:
293
293
* - MUST set `invoice_relative_expiry`
294
294
*/
295
- /* Give them 6 blocks, plus one per 10 minutes until expiry. */
296
295
if (ir -> inv -> invoice_relative_expiry )
297
- base = blockheight + 6 + * ir -> inv -> invoice_relative_expiry / 600 ;
296
+ base = blockheight + * ir -> inv -> invoice_relative_expiry / 600 ;
298
297
else
299
- base = blockheight + 6 + 7200 / 600 ;
298
+ base = blockheight + 7200 / 600 ;
300
299
300
+ /* BOLT #12:
301
+ * - `max_cltv_expiry` to the largest block height at which
302
+ * the route is allowed to be used, starting from the final
303
+ * node's chosen `max_cltv_expiry` height at which the route
304
+ * should expire, adding the final node's
305
+ * `min_final_cltv_expiry_delta` and then adding
306
+ * `encrypted_data_tlv.payment_relay.cltv_expiry_delta` at
307
+ * each hop.
308
+ */
309
+ /* BUT: we also recommend padding CLTV when paying, to obscure paths: if this is too tight
310
+ * payments fail in practice! We add 1008 (half the max possible) */
301
311
etlvs [0 ]-> payment_constraints = tal (etlvs [0 ],
302
312
struct tlv_encrypted_data_tlv_payment_constraints );
303
- etlvs [0 ]-> payment_constraints -> max_cltv_expiry = base + best -> cltv + cltv_final ;
313
+ etlvs [0 ]-> payment_constraints -> max_cltv_expiry = 1008 + base + best -> cltv + cltv_final ;
304
314
etlvs [0 ]-> payment_constraints -> htlc_minimum_msat = best -> htlc_min .millisatoshis ; /* Raw: tlv */
305
315
306
316
/* So we recognize this payment */
0 commit comments