From 0a08f4a623389f9e78464bf3649a3a82bd3d5152 Mon Sep 17 00:00:00 2001 From: Valentine Wallace Date: Fri, 2 Apr 2021 15:36:17 -0400 Subject: [PATCH] Include min_final_cltv when generating invoices --- src/cli.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/cli.rs b/src/cli.rs index d22f549..0144c00 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -588,6 +588,7 @@ fn get_invoice( // Add route hints to the invoice. let our_channels = channel_manager.list_usable_channels(); + let mut min_final_cltv_expiry = 9; for channel in our_channels { let short_channel_id = match channel.short_channel_id { Some(id) => id.to_be_bytes(), @@ -597,6 +598,9 @@ fn get_invoice( Some(info) => info, None => continue, }; + if forwarding_info.cltv_expiry_delta > min_final_cltv_expiry { + min_final_cltv_expiry = forwarding_info.cltv_expiry_delta; + } invoice = invoice.route(vec![lightning_invoice::RouteHop { pubkey: channel.remote_network_id, short_channel_id, @@ -605,6 +609,7 @@ fn get_invoice( cltv_expiry_delta: forwarding_info.cltv_expiry_delta, }]); } + invoice = invoice.min_final_cltv_expiry(min_final_cltv_expiry.into()); // Sign the invoice. let invoice = -- 2.39.5