@@ -37,7 +37,9 @@ use crate::ln::peer_handler::IgnoringMessageHandler;
3737use crate :: ln:: types:: ChannelId ;
3838use crate :: onion_message:: messenger:: OnionMessenger ;
3939use crate :: routing:: gossip:: { NetworkGraph , NetworkUpdate , P2PGossipSync } ;
40- use crate :: routing:: router:: { self , PaymentParameters , Route , RouteParameters } ;
40+ use crate :: routing:: router:: {
41+ self , PaymentParameters , Route , RouteParameters , DEFAULT_PAYMENT_DUMMY_HOPS ,
42+ } ;
4143use crate :: sign:: { EntropySource , RandomBytes } ;
4244use crate :: types:: features:: ChannelTypeFeatures ;
4345use crate :: types:: features:: InitFeatures ;
@@ -3276,6 +3278,7 @@ fn fail_payment_along_path<'a, 'b, 'c>(expected_path: &[&Node<'a, 'b, 'c>]) {
32763278pub struct PassAlongPathArgs < ' a , ' b , ' c , ' d > {
32773279 pub origin_node : & ' a Node < ' b , ' c , ' d > ,
32783280 pub expected_path : & ' a [ & ' a Node < ' b , ' c , ' d > ] ,
3281+ pub dummy_hop_override : Option < usize > ,
32793282 pub recv_value : u64 ,
32803283 pub payment_hash : PaymentHash ,
32813284 pub payment_secret : Option < PaymentSecret > ,
@@ -3297,6 +3300,7 @@ impl<'a, 'b, 'c, 'd> PassAlongPathArgs<'a, 'b, 'c, 'd> {
32973300 Self {
32983301 origin_node,
32993302 expected_path,
3303+ dummy_hop_override : None ,
33003304 recv_value,
33013305 payment_hash,
33023306 payment_secret : None ,
@@ -3344,12 +3348,17 @@ impl<'a, 'b, 'c, 'd> PassAlongPathArgs<'a, 'b, 'c, 'd> {
33443348 self . expected_failure = Some ( failure) ;
33453349 self
33463350 }
3351+ pub fn with_dummy_override ( mut self , dummy_override : usize ) -> Self {
3352+ self . dummy_hop_override = Some ( dummy_override) ;
3353+ self
3354+ }
33473355}
33483356
33493357pub fn do_pass_along_path < ' a , ' b , ' c > ( args : PassAlongPathArgs ) -> Option < Event > {
33503358 let PassAlongPathArgs {
33513359 origin_node,
33523360 expected_path,
3361+ dummy_hop_override,
33533362 recv_value,
33543363 payment_hash : our_payment_hash,
33553364 payment_secret : our_payment_secret,
@@ -3383,6 +3392,14 @@ pub fn do_pass_along_path<'a, 'b, 'c>(args: PassAlongPathArgs) -> Option<Event>
33833392 node. node . process_pending_htlc_forwards ( ) ;
33843393 }
33853394
3395+ if is_last_hop {
3396+ let dummy_count = dummy_hop_override. unwrap_or ( DEFAULT_PAYMENT_DUMMY_HOPS ) ;
3397+ for _ in 0 ..dummy_count {
3398+ println ! ( "This ran" ) ;
3399+ node. node . process_pending_htlc_forwards ( ) ;
3400+ }
3401+ }
3402+
33863403 if is_last_hop && clear_recipient_events {
33873404 let events_2 = node. node . get_and_clear_pending_events ( ) ;
33883405 if payment_claimable_expected {
@@ -3494,9 +3511,33 @@ pub fn pass_along_path<'a, 'b, 'c>(
34943511 origin_node : & Node < ' a , ' b , ' c > , expected_path : & [ & Node < ' a , ' b , ' c > ] , recv_value : u64 ,
34953512 our_payment_hash : PaymentHash , our_payment_secret : Option < PaymentSecret > , ev : MessageSendEvent ,
34963513 payment_claimable_expected : bool , expected_preimage : Option < PaymentPreimage > ,
3514+ ) -> Option < Event > {
3515+ pass_along_path_with_dummy (
3516+ origin_node,
3517+ expected_path,
3518+ None , // no dummy hops
3519+ recv_value,
3520+ our_payment_hash,
3521+ our_payment_secret,
3522+ ev,
3523+ payment_claimable_expected,
3524+ expected_preimage,
3525+ )
3526+ }
3527+
3528+ pub fn pass_along_path_with_dummy < ' a , ' b , ' c > (
3529+ origin_node : & Node < ' a , ' b , ' c > , expected_path : & [ & Node < ' a , ' b , ' c > ] ,
3530+ dummy_count : Option < usize > , recv_value : u64 , our_payment_hash : PaymentHash ,
3531+ our_payment_secret : Option < PaymentSecret > , ev : MessageSendEvent ,
3532+ payment_claimable_expected : bool , expected_preimage : Option < PaymentPreimage > ,
34973533) -> Option < Event > {
34983534 let mut args =
34993535 PassAlongPathArgs :: new ( origin_node, expected_path, recv_value, our_payment_hash, ev) ;
3536+
3537+ if let Some ( count) = dummy_count {
3538+ args = args. with_dummy_override ( count) ;
3539+ }
3540+
35003541 if !payment_claimable_expected {
35013542 args = args. without_claimable_event ( ) ;
35023543 }
0 commit comments