@@ -834,6 +834,7 @@ pub(super) struct SendAlongPathArgs<'a> {
834834 pub invoice_request : Option < & ' a InvoiceRequest > ,
835835 pub bolt12_invoice : Option < & ' a PaidBolt12Invoice > ,
836836 pub session_priv_bytes : [ u8 ; 32 ] ,
837+ pub hold_htlc_at_next_hop : bool ,
837838}
838839
839840pub ( super ) struct OutboundPayments < L : Deref >
@@ -999,9 +1000,9 @@ where
9991000 }
10001001 let invoice = PaidBolt12Invoice :: Bolt12Invoice ( invoice. clone ( ) ) ;
10011002 self . send_payment_for_bolt12_invoice_internal (
1002- payment_id, payment_hash, None , None , invoice, route_params, retry_strategy, router , first_hops ,
1003- inflight_htlcs, entropy_source, node_signer, node_id_lookup, secp_ctx, best_block_height ,
1004- pending_events, send_payment_along_path
1003+ payment_id, payment_hash, None , None , invoice, route_params, retry_strategy, false , router ,
1004+ first_hops , inflight_htlcs, entropy_source, node_signer, node_id_lookup, secp_ctx,
1005+ best_block_height , pending_events, send_payment_along_path
10051006 )
10061007 }
10071008
@@ -1012,7 +1013,7 @@ where
10121013 & self , payment_id : PaymentId , payment_hash : PaymentHash ,
10131014 keysend_preimage : Option < PaymentPreimage > , invoice_request : Option < & InvoiceRequest > ,
10141015 bolt12_invoice : PaidBolt12Invoice ,
1015- mut route_params : RouteParameters , retry_strategy : Retry , router : & R ,
1016+ mut route_params : RouteParameters , retry_strategy : Retry , hold_htlcs_at_next_hop : bool , router : & R ,
10161017 first_hops : Vec < ChannelDetails > , inflight_htlcs : IH , entropy_source : & ES , node_signer : & NS ,
10171018 node_id_lookup : & NL , secp_ctx : & Secp256k1 < secp256k1:: All > , best_block_height : u32 ,
10181019 pending_events : & Mutex < VecDeque < ( events:: Event , Option < EventCompletionAction > ) > > ,
@@ -1097,7 +1098,7 @@ where
10971098
10981099 let result = self . pay_route_internal (
10991100 & route, payment_hash, & recipient_onion, keysend_preimage, invoice_request, Some ( & bolt12_invoice) , payment_id,
1100- Some ( route_params. final_value_msat ) , & onion_session_privs, false , node_signer,
1101+ Some ( route_params. final_value_msat ) , & onion_session_privs, hold_htlcs_at_next_hop , node_signer,
11011102 best_block_height, & send_payment_along_path
11021103 ) ;
11031104 log_info ! (
@@ -1231,9 +1232,9 @@ where
12311232 IH ,
12321233 SP ,
12331234 > (
1234- & self , payment_id : PaymentId , router : & R , first_hops : Vec < ChannelDetails > ,
1235- inflight_htlcs : IH , entropy_source : & ES , node_signer : & NS , node_id_lookup : & NL ,
1236- secp_ctx : & Secp256k1 < secp256k1:: All > , best_block_height : u32 ,
1235+ & self , payment_id : PaymentId , hold_htlcs_at_next_hop : bool , router : & R ,
1236+ first_hops : Vec < ChannelDetails > , inflight_htlcs : IH , entropy_source : & ES , node_signer : & NS ,
1237+ node_id_lookup : & NL , secp_ctx : & Secp256k1 < secp256k1:: All > , best_block_height : u32 ,
12371238 pending_events : & Mutex < VecDeque < ( events:: Event , Option < EventCompletionAction > ) > > ,
12381239 send_payment_along_path : SP ,
12391240 ) -> Result < ( ) , Bolt12PaymentError >
@@ -1249,7 +1250,7 @@ where
12491250 payment_hash,
12501251 keysend_preimage,
12511252 route_params,
1252- retry_strategy,
1253+ mut retry_strategy,
12531254 invoice_request,
12541255 invoice,
12551256 ) = match self . pending_outbound_payments . lock ( ) . unwrap ( ) . entry ( payment_id) {
@@ -1274,6 +1275,14 @@ where
12741275 } ,
12751276 hash_map:: Entry :: Vacant ( _) => return Err ( Bolt12PaymentError :: UnexpectedInvoice ) ,
12761277 } ;
1278+
1279+ // If we expect the HTLCs for this payment to be held at our next-hop counterparty, don't
1280+ // retry the payment. In future iterations of this feature, we will send this payment via
1281+ // trampoline and the counterparty will retry on our behalf.
1282+ if hold_htlcs_at_next_hop {
1283+ retry_strategy = Retry :: Attempts ( 0 ) ;
1284+ }
1285+
12771286 let invoice = PaidBolt12Invoice :: StaticInvoice ( invoice) ;
12781287 self . send_payment_for_bolt12_invoice_internal (
12791288 payment_id,
@@ -1283,6 +1292,7 @@ where
12831292 invoice,
12841293 route_params,
12851294 retry_strategy,
1295+ hold_htlcs_at_next_hop,
12861296 router,
12871297 first_hops,
12881298 inflight_htlcs,
@@ -2116,7 +2126,7 @@ where
21162126 let path_res = send_payment_along_path ( SendAlongPathArgs {
21172127 path : & path, payment_hash : & payment_hash, recipient_onion, total_value,
21182128 cur_height, payment_id, keysend_preimage : & keysend_preimage, invoice_request,
2119- bolt12_invoice,
2129+ bolt12_invoice, hold_htlc_at_next_hop : hold_htlcs_at_next_hop ,
21202130 session_priv_bytes : * session_priv_bytes
21212131 } ) ;
21222132 results. push ( path_res) ;
0 commit comments