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