@@ -39,7 +39,9 @@ use crate::ln::peer_handler::IgnoringMessageHandler;
3939use crate :: ln:: types:: ChannelId ;
4040use crate :: onion_message:: messenger:: OnionMessenger ;
4141use crate :: routing:: gossip:: { NetworkGraph , NetworkUpdate , P2PGossipSync } ;
42- use crate :: routing:: router:: { self , PaymentParameters , Route , RouteParameters } ;
42+ use crate :: routing:: router:: {
43+ self , PaymentParameters , Route , RouteParameters , DEFAULT_PAYMENT_DUMMY_HOPS ,
44+ } ;
4345use crate :: sign:: { EntropySource , RandomBytes } ;
4446use crate :: types:: features:: ChannelTypeFeatures ;
4547use crate :: types:: features:: InitFeatures ;
@@ -3435,6 +3437,7 @@ fn fail_payment_along_path<'a, 'b, 'c>(expected_path: &[&Node<'a, 'b, 'c>]) {
34353437pub struct PassAlongPathArgs < ' a , ' b , ' c , ' d > {
34363438 pub origin_node : & ' a Node < ' b , ' c , ' d > ,
34373439 pub expected_path : & ' a [ & ' a Node < ' b , ' c , ' d > ] ,
3440+ pub dummy_hop_override : Option < usize > ,
34383441 pub recv_value : u64 ,
34393442 pub payment_hash : PaymentHash ,
34403443 pub payment_secret : Option < PaymentSecret > ,
@@ -3456,6 +3459,7 @@ impl<'a, 'b, 'c, 'd> PassAlongPathArgs<'a, 'b, 'c, 'd> {
34563459 Self {
34573460 origin_node,
34583461 expected_path,
3462+ dummy_hop_override : None ,
34593463 recv_value,
34603464 payment_hash,
34613465 payment_secret : None ,
@@ -3503,12 +3507,17 @@ impl<'a, 'b, 'c, 'd> PassAlongPathArgs<'a, 'b, 'c, 'd> {
35033507 self . expected_failure = Some ( failure) ;
35043508 self
35053509 }
3510+ pub fn with_dummy_override ( mut self , dummy_override : usize ) -> Self {
3511+ self . dummy_hop_override = Some ( dummy_override) ;
3512+ self
3513+ }
35063514}
35073515
35083516pub fn do_pass_along_path < ' a , ' b , ' c > ( args : PassAlongPathArgs ) -> Option < Event > {
35093517 let PassAlongPathArgs {
35103518 origin_node,
35113519 expected_path,
3520+ dummy_hop_override,
35123521 recv_value,
35133522 payment_hash : our_payment_hash,
35143523 payment_secret : our_payment_secret,
@@ -3543,6 +3552,14 @@ pub fn do_pass_along_path<'a, 'b, 'c>(args: PassAlongPathArgs) -> Option<Event>
35433552 node. node . process_pending_htlc_forwards ( ) ;
35443553 }
35453554
3555+ if is_last_hop {
3556+ let dummy_count = dummy_hop_override. unwrap_or ( DEFAULT_PAYMENT_DUMMY_HOPS ) ;
3557+ for _ in 0 ..dummy_count {
3558+ println ! ( "This ran" ) ;
3559+ node. node . process_pending_htlc_forwards ( ) ;
3560+ }
3561+ }
3562+
35463563 if is_last_hop && clear_recipient_events {
35473564 let events_2 = node. node . get_and_clear_pending_events ( ) ;
35483565 if payment_claimable_expected {
@@ -3654,9 +3671,33 @@ pub fn pass_along_path<'a, 'b, 'c>(
36543671 origin_node : & Node < ' a , ' b , ' c > , expected_path : & [ & Node < ' a , ' b , ' c > ] , recv_value : u64 ,
36553672 our_payment_hash : PaymentHash , our_payment_secret : Option < PaymentSecret > , ev : MessageSendEvent ,
36563673 payment_claimable_expected : bool , expected_preimage : Option < PaymentPreimage > ,
3674+ ) -> Option < Event > {
3675+ pass_along_path_with_dummy (
3676+ origin_node,
3677+ expected_path,
3678+ None , // no dummy hops
3679+ recv_value,
3680+ our_payment_hash,
3681+ our_payment_secret,
3682+ ev,
3683+ payment_claimable_expected,
3684+ expected_preimage,
3685+ )
3686+ }
3687+
3688+ pub fn pass_along_path_with_dummy < ' a , ' b , ' c > (
3689+ origin_node : & Node < ' a , ' b , ' c > , expected_path : & [ & Node < ' a , ' b , ' c > ] ,
3690+ dummy_count : Option < usize > , recv_value : u64 , our_payment_hash : PaymentHash ,
3691+ our_payment_secret : Option < PaymentSecret > , ev : MessageSendEvent ,
3692+ payment_claimable_expected : bool , expected_preimage : Option < PaymentPreimage > ,
36573693) -> Option < Event > {
36583694 let mut args =
36593695 PassAlongPathArgs :: new ( origin_node, expected_path, recv_value, our_payment_hash, ev) ;
3696+
3697+ if let Some ( count) = dummy_count {
3698+ args = args. with_dummy_override ( count) ;
3699+ }
3700+
36603701 if !payment_claimable_expected {
36613702 args = args. without_claimable_event ( ) ;
36623703 }
0 commit comments