@@ -27,7 +27,7 @@ use lightning::chain::chaininterface::{BroadcasterInterface,ConfirmationTarget,C
27
27
use lightning:: chain:: keysinterface:: { KeysInterface , InMemoryChannelKeys } ;
28
28
use lightning:: ln:: channelmonitor;
29
29
use lightning:: ln:: channelmonitor:: { ChannelMonitor , ChannelMonitorUpdateErr , HTLCUpdate } ;
30
- use lightning:: ln:: channelmanager:: { ChannelManager , PaymentHash , PaymentPreimage , ChannelManagerReadArgs } ;
30
+ use lightning:: ln:: channelmanager:: { ChannelManager , PaymentHash , PaymentPreimage , PaymentSecret , ChannelManagerReadArgs } ;
31
31
use lightning:: ln:: router:: { Route , RouteHop } ;
32
32
use lightning:: ln:: features:: { ChannelFeatures , InitFeatures , NodeFeatures } ;
33
33
use lightning:: ln:: msgs:: { CommitmentUpdate , ChannelMessageHandler , ErrorAction , UpdateAddHTLC , Init } ;
@@ -408,25 +408,25 @@ pub fn do_test(data: &[u8]) {
408
408
( $source: expr, $dest: expr) => { {
409
409
let payment_hash = Sha256 :: hash( & [ payment_id; 1 ] ) ;
410
410
payment_id = payment_id. wrapping_add( 1 ) ;
411
- if let Err ( _) = $source. send_payment( Route {
412
- hops : vec![ RouteHop {
411
+ if let Err ( _) = $source. send_payment( & Route {
412
+ paths : vec! [ vec![ RouteHop {
413
413
pubkey: $dest. 0 . get_our_node_id( ) ,
414
414
node_features: NodeFeatures :: empty( ) ,
415
415
short_channel_id: $dest. 1 ,
416
416
channel_features: ChannelFeatures :: empty( ) ,
417
417
fee_msat: 5000000 ,
418
418
cltv_expiry_delta: 200 ,
419
- } ] ,
420
- } , PaymentHash ( payment_hash. into_inner( ) ) ) {
419
+ } ] ] ,
420
+ } , PaymentHash ( payment_hash. into_inner( ) ) , & None ) {
421
421
// Probably ran out of funds
422
422
test_return!( ) ;
423
423
}
424
424
} } ;
425
425
( $source: expr, $middle: expr, $dest: expr) => { {
426
426
let payment_hash = Sha256 :: hash( & [ payment_id; 1 ] ) ;
427
427
payment_id = payment_id. wrapping_add( 1 ) ;
428
- if let Err ( _) = $source. send_payment( Route {
429
- hops : vec![ RouteHop {
428
+ if let Err ( _) = $source. send_payment( & Route {
429
+ paths : vec! [ vec![ RouteHop {
430
430
pubkey: $middle. 0 . get_our_node_id( ) ,
431
431
node_features: NodeFeatures :: empty( ) ,
432
432
short_channel_id: $middle. 1 ,
@@ -440,8 +440,50 @@ pub fn do_test(data: &[u8]) {
440
440
channel_features: ChannelFeatures :: empty( ) ,
441
441
fee_msat: 5000000 ,
442
442
cltv_expiry_delta: 200 ,
443
- } ] ,
444
- } , PaymentHash ( payment_hash. into_inner( ) ) ) {
443
+ } ] ] ,
444
+ } , PaymentHash ( payment_hash. into_inner( ) ) , & None ) {
445
+ // Probably ran out of funds
446
+ test_return!( ) ;
447
+ }
448
+ } }
449
+ }
450
+ macro_rules! send_payment_with_secret {
451
+ ( $source: expr, $middle: expr, $dest: expr) => { {
452
+ let payment_hash = Sha256 :: hash( & [ payment_id; 1 ] ) ;
453
+ payment_id = payment_id. wrapping_add( 1 ) ;
454
+ let payment_secret = Sha256 :: hash( & [ payment_id; 1 ] ) ;
455
+ payment_id = payment_id. wrapping_add( 1 ) ;
456
+ if let Err ( _) = $source. send_payment( & Route {
457
+ paths: vec![ vec![ RouteHop {
458
+ pubkey: $middle. 0 . get_our_node_id( ) ,
459
+ node_features: NodeFeatures :: empty( ) ,
460
+ short_channel_id: $middle. 1 ,
461
+ channel_features: ChannelFeatures :: empty( ) ,
462
+ fee_msat: 50000 ,
463
+ cltv_expiry_delta: 100 ,
464
+ } , RouteHop {
465
+ pubkey: $dest. 0 . get_our_node_id( ) ,
466
+ node_features: NodeFeatures :: empty( ) ,
467
+ short_channel_id: $dest. 1 ,
468
+ channel_features: ChannelFeatures :: empty( ) ,
469
+ fee_msat: 5000000 ,
470
+ cltv_expiry_delta: 200 ,
471
+ } ] , vec![ RouteHop {
472
+ pubkey: $middle. 0 . get_our_node_id( ) ,
473
+ node_features: NodeFeatures :: empty( ) ,
474
+ short_channel_id: $middle. 1 ,
475
+ channel_features: ChannelFeatures :: empty( ) ,
476
+ fee_msat: 50000 ,
477
+ cltv_expiry_delta: 100 ,
478
+ } , RouteHop {
479
+ pubkey: $dest. 0 . get_our_node_id( ) ,
480
+ node_features: NodeFeatures :: empty( ) ,
481
+ short_channel_id: $dest. 1 ,
482
+ channel_features: ChannelFeatures :: empty( ) ,
483
+ fee_msat: 5000000 ,
484
+ cltv_expiry_delta: 200 ,
485
+ } ] ] ,
486
+ } , PaymentHash ( payment_hash. into_inner( ) ) , & Some ( PaymentSecret ( payment_secret. into_inner( ) ) ) ) {
445
487
// Probably ran out of funds
446
488
test_return!( ) ;
447
489
}
@@ -599,12 +641,12 @@ pub fn do_test(data: &[u8]) {
599
641
} ) ;
600
642
for event in events. drain( ..) {
601
643
match event {
602
- events:: Event :: PaymentReceived { payment_hash, .. } => {
644
+ events:: Event :: PaymentReceived { payment_hash, payment_secret , .. } => {
603
645
if claim_set. insert( payment_hash. 0 ) {
604
646
if $fail {
605
- assert!( nodes[ $node] . fail_htlc_backwards( & payment_hash) ) ;
647
+ assert!( nodes[ $node] . fail_htlc_backwards( & payment_hash, & payment_secret ) ) ;
606
648
} else {
607
- assert!( nodes[ $node] . claim_funds( PaymentPreimage ( payment_hash. 0 ) , 5_000_000 ) ) ;
649
+ assert!( nodes[ $node] . claim_funds( PaymentPreimage ( payment_hash. 0 ) , & payment_secret , 5_000_000 ) ) ;
608
650
}
609
651
}
610
652
} ,
@@ -734,6 +776,8 @@ pub fn do_test(data: &[u8]) {
734
776
nodes[ 2 ] = node_c. clone ( ) ;
735
777
monitor_c = new_monitor_c;
736
778
} ,
779
+ 0x22 => send_payment_with_secret ! ( nodes[ 0 ] , ( & nodes[ 1 ] , chan_a) , ( & nodes[ 2 ] , chan_b) ) ,
780
+ 0x23 => send_payment_with_secret ! ( nodes[ 2 ] , ( & nodes[ 1 ] , chan_b) , ( & nodes[ 0 ] , chan_a) ) ,
737
781
// 0x24 defined above
738
782
_ => test_return ! ( ) ,
739
783
}
0 commit comments