@@ -28,7 +28,7 @@ use ln::msgs::{ChannelMessageHandler, ErrorAction, RoutingMessageHandler};
28
28
use routing:: router:: get_route;
29
29
use util:: config:: UserConfig ;
30
30
use util:: enforcing_trait_impls:: EnforcingSigner ;
31
- use util:: events:: { Event , MessageSendEvent , MessageSendEventsProvider } ;
31
+ use util:: events:: { Event , MessageSendEvent , MessageSendEventsProvider , PaymentPurpose } ;
32
32
use util:: errors:: APIError ;
33
33
use util:: ser:: { ReadableArgs , Writeable } ;
34
34
use util:: test_utils:: TestBroadcaster ;
@@ -220,11 +220,16 @@ fn do_test_simple_monitor_temporary_update_fail(disconnect: bool, persister_fail
220
220
let events_3 = nodes[ 1 ] . node . get_and_clear_pending_events ( ) ;
221
221
assert_eq ! ( events_3. len( ) , 1 ) ;
222
222
match events_3[ 0 ] {
223
- Event :: PaymentReceived { ref payment_hash, ref payment_preimage , ref payment_secret , amt, user_payment_id : _ } => {
223
+ Event :: PaymentReceived { ref payment_hash, ref purpose , amt } => {
224
224
assert_eq ! ( payment_hash_1, * payment_hash) ;
225
- assert ! ( payment_preimage. is_none( ) ) ;
226
- assert_eq ! ( payment_secret_1, * payment_secret) ;
227
225
assert_eq ! ( amt, 1000000 ) ;
226
+ match & purpose {
227
+ PaymentPurpose :: InvoicePayment { payment_preimage, payment_secret, .. } => {
228
+ assert ! ( payment_preimage. is_none( ) ) ;
229
+ assert_eq ! ( payment_secret_1, * payment_secret) ;
230
+ } ,
231
+ _ => panic ! ( "expected PaymentPurpose::InvoicePayment" )
232
+ }
228
233
} ,
229
234
_ => panic ! ( "Unexpected event" ) ,
230
235
}
@@ -589,11 +594,16 @@ fn do_test_monitor_temporary_update_fail(disconnect_count: usize) {
589
594
let events_5 = nodes[ 1 ] . node . get_and_clear_pending_events ( ) ;
590
595
assert_eq ! ( events_5. len( ) , 1 ) ;
591
596
match events_5[ 0 ] {
592
- Event :: PaymentReceived { ref payment_hash, ref payment_preimage , ref payment_secret , amt, user_payment_id : _ } => {
597
+ Event :: PaymentReceived { ref payment_hash, ref purpose , amt } => {
593
598
assert_eq ! ( payment_hash_2, * payment_hash) ;
594
- assert ! ( payment_preimage. is_none( ) ) ;
595
- assert_eq ! ( payment_secret_2, * payment_secret) ;
596
599
assert_eq ! ( amt, 1000000 ) ;
600
+ match & purpose {
601
+ PaymentPurpose :: InvoicePayment { payment_preimage, payment_secret, .. } => {
602
+ assert ! ( payment_preimage. is_none( ) ) ;
603
+ assert_eq ! ( payment_secret_2, * payment_secret) ;
604
+ } ,
605
+ _ => panic ! ( "expected PaymentPurpose::InvoicePayment" )
606
+ }
597
607
} ,
598
608
_ => panic ! ( "Unexpected event" ) ,
599
609
}
@@ -704,11 +714,16 @@ fn test_monitor_update_fail_cs() {
704
714
let events = nodes[ 1 ] . node . get_and_clear_pending_events ( ) ;
705
715
assert_eq ! ( events. len( ) , 1 ) ;
706
716
match events[ 0 ] {
707
- Event :: PaymentReceived { payment_hash, payment_preimage , payment_secret , amt, user_payment_id : _ } => {
717
+ Event :: PaymentReceived { payment_hash, ref purpose , amt } => {
708
718
assert_eq ! ( payment_hash, our_payment_hash) ;
709
- assert ! ( payment_preimage. is_none( ) ) ;
710
- assert_eq ! ( our_payment_secret, payment_secret) ;
711
719
assert_eq ! ( amt, 1000000 ) ;
720
+ match & purpose {
721
+ PaymentPurpose :: InvoicePayment { payment_preimage, payment_secret, .. } => {
722
+ assert ! ( payment_preimage. is_none( ) ) ;
723
+ assert_eq ! ( our_payment_secret, * payment_secret) ;
724
+ } ,
725
+ _ => panic ! ( "expected PaymentPurpose::InvoicePayment" )
726
+ }
712
727
} ,
713
728
_ => panic ! ( "Unexpected event" ) ,
714
729
} ;
@@ -1712,20 +1727,30 @@ fn test_monitor_update_fail_claim() {
1712
1727
let events = nodes[ 0 ] . node . get_and_clear_pending_events ( ) ;
1713
1728
assert_eq ! ( events. len( ) , 2 ) ;
1714
1729
match events[ 0 ] {
1715
- Event :: PaymentReceived { ref payment_hash, ref payment_preimage , ref payment_secret , amt, user_payment_id : _ } => {
1730
+ Event :: PaymentReceived { ref payment_hash, ref purpose , amt } => {
1716
1731
assert_eq ! ( payment_hash_2, * payment_hash) ;
1717
- assert ! ( payment_preimage. is_none( ) ) ;
1718
- assert_eq ! ( payment_secret_2, * payment_secret) ;
1719
1732
assert_eq ! ( 1_000_000 , amt) ;
1733
+ match & purpose {
1734
+ PaymentPurpose :: InvoicePayment { payment_preimage, payment_secret, .. } => {
1735
+ assert ! ( payment_preimage. is_none( ) ) ;
1736
+ assert_eq ! ( payment_secret_2, * payment_secret) ;
1737
+ } ,
1738
+ _ => panic ! ( "expected PaymentPurpose::InvoicePayment" )
1739
+ }
1720
1740
} ,
1721
1741
_ => panic ! ( "Unexpected event" ) ,
1722
1742
}
1723
1743
match events[ 1 ] {
1724
- Event :: PaymentReceived { ref payment_hash, ref payment_preimage , ref payment_secret , amt, user_payment_id : _ } => {
1744
+ Event :: PaymentReceived { ref payment_hash, ref purpose , amt } => {
1725
1745
assert_eq ! ( payment_hash_3, * payment_hash) ;
1726
- assert ! ( payment_preimage. is_none( ) ) ;
1727
- assert_eq ! ( payment_secret_3, * payment_secret) ;
1728
1746
assert_eq ! ( 1_000_000 , amt) ;
1747
+ match & purpose {
1748
+ PaymentPurpose :: InvoicePayment { payment_preimage, payment_secret, .. } => {
1749
+ assert ! ( payment_preimage. is_none( ) ) ;
1750
+ assert_eq ! ( payment_secret_3, * payment_secret) ;
1751
+ } ,
1752
+ _ => panic ! ( "expected PaymentPurpose::InvoicePayment" )
1753
+ }
1729
1754
} ,
1730
1755
_ => panic ! ( "Unexpected event" ) ,
1731
1756
}
@@ -2014,15 +2039,15 @@ fn test_path_paused_mpp() {
2014
2039
// Pass the first HTLC of the payment along to nodes[3].
2015
2040
let mut events = nodes[ 0 ] . node . get_and_clear_pending_msg_events ( ) ;
2016
2041
assert_eq ! ( events. len( ) , 1 ) ;
2017
- pass_along_path ( & nodes[ 0 ] , & [ & nodes[ 1 ] , & nodes[ 3 ] ] , 0 , payment_hash. clone ( ) , payment_secret, events. pop ( ) . unwrap ( ) , false ) ;
2042
+ pass_along_path ( & nodes[ 0 ] , & [ & nodes[ 1 ] , & nodes[ 3 ] ] , 0 , payment_hash. clone ( ) , Some ( payment_secret) , events. pop ( ) . unwrap ( ) , false , None ) ;
2018
2043
2019
2044
// And check that, after we successfully update the monitor for chan_2 we can pass the second
2020
2045
// HTLC along to nodes[3] and claim the whole payment back to nodes[0].
2021
2046
let ( outpoint, latest_update) = nodes[ 0 ] . chain_monitor . latest_monitor_update_id . lock ( ) . unwrap ( ) . get ( & chan_2_id) . unwrap ( ) . clone ( ) ;
2022
2047
nodes[ 0 ] . node . channel_monitor_updated ( & outpoint, latest_update) ;
2023
2048
let mut events = nodes[ 0 ] . node . get_and_clear_pending_msg_events ( ) ;
2024
2049
assert_eq ! ( events. len( ) , 1 ) ;
2025
- pass_along_path ( & nodes[ 0 ] , & [ & nodes[ 2 ] , & nodes[ 3 ] ] , 200_000 , payment_hash. clone ( ) , payment_secret, events. pop ( ) . unwrap ( ) , true ) ;
2050
+ pass_along_path ( & nodes[ 0 ] , & [ & nodes[ 2 ] , & nodes[ 3 ] ] , 200_000 , payment_hash. clone ( ) , Some ( payment_secret) , events. pop ( ) . unwrap ( ) , true , None ) ;
2026
2051
2027
2052
claim_payment_along_route ( & nodes[ 0 ] , & [ & [ & nodes[ 1 ] , & nodes[ 3 ] ] , & [ & nodes[ 2 ] , & nodes[ 3 ] ] ] , false , payment_preimage) ;
2028
2053
}
0 commit comments