@@ -235,7 +235,7 @@ fn do_test_simple_monitor_temporary_update_fail(disconnect: bool, persister_fail
235
235
_ => panic ! ( "Unexpected event" ) ,
236
236
}
237
237
238
- claim_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , payment_preimage_1) ;
238
+ claim_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , payment_preimage_1, payment_hash_1 ) ;
239
239
240
240
// Now set it to failed again...
241
241
let ( _, payment_hash_2, payment_secret_2) = get_payment_preimage_hash ! ( & nodes[ 1 ] ) ;
@@ -308,7 +308,7 @@ fn do_test_monitor_temporary_update_fail(disconnect_count: usize) {
308
308
let channel_id = create_announced_chan_between_nodes ( & nodes, 0 , 1 , InitFeatures :: known ( ) , InitFeatures :: known ( ) ) . 2 ;
309
309
let logger = test_utils:: TestLogger :: new ( ) ;
310
310
311
- let ( payment_preimage_1, _ , _) = route_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , 1000000 ) ;
311
+ let ( payment_preimage_1, payment_hash_1 , _) = route_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , 1000000 ) ;
312
312
313
313
// Now try to send a second payment which will fail to send
314
314
let ( payment_preimage_2, payment_hash_2, payment_secret_2) = get_payment_preimage_hash ! ( nodes[ 1 ] ) ;
@@ -344,8 +344,9 @@ fn do_test_monitor_temporary_update_fail(disconnect_count: usize) {
344
344
let events_3 = nodes[ 0 ] . node . get_and_clear_pending_events ( ) ;
345
345
assert_eq ! ( events_3. len( ) , 1 ) ;
346
346
match events_3[ 0 ] {
347
- Event :: PaymentSent { ref payment_preimage } => {
347
+ Event :: PaymentSent { ref payment_preimage, ref payment_hash } => {
348
348
assert_eq ! ( * payment_preimage, payment_preimage_1) ;
349
+ assert_eq ! ( * payment_hash, payment_hash_1) ;
349
350
} ,
350
351
_ => panic ! ( "Unexpected event" ) ,
351
352
}
@@ -436,8 +437,9 @@ fn do_test_monitor_temporary_update_fail(disconnect_count: usize) {
436
437
let events_3 = nodes[ 0 ] . node . get_and_clear_pending_events ( ) ;
437
438
assert_eq ! ( events_3. len( ) , 1 ) ;
438
439
match events_3[ 0 ] {
439
- Event :: PaymentSent { ref payment_preimage } => {
440
+ Event :: PaymentSent { ref payment_preimage, ref payment_hash } => {
440
441
assert_eq ! ( * payment_preimage, payment_preimage_1) ;
442
+ assert_eq ! ( * payment_hash, payment_hash_1) ;
441
443
} ,
442
444
_ => panic ! ( "Unexpected event" ) ,
443
445
}
@@ -609,7 +611,7 @@ fn do_test_monitor_temporary_update_fail(disconnect_count: usize) {
609
611
_ => panic ! ( "Unexpected event" ) ,
610
612
}
611
613
612
- claim_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , payment_preimage_2) ;
614
+ claim_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , payment_preimage_2, payment_hash_2 ) ;
613
615
}
614
616
615
617
#[ test]
@@ -729,7 +731,7 @@ fn test_monitor_update_fail_cs() {
729
731
_ => panic ! ( "Unexpected event" ) ,
730
732
} ;
731
733
732
- claim_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , payment_preimage) ;
734
+ claim_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , payment_preimage, our_payment_hash ) ;
733
735
}
734
736
735
737
#[ test]
@@ -780,7 +782,7 @@ fn test_monitor_update_fail_no_rebroadcast() {
780
782
_ => panic ! ( "Unexpected event" ) ,
781
783
}
782
784
783
- claim_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , payment_preimage_1) ;
785
+ claim_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , payment_preimage_1, our_payment_hash ) ;
784
786
}
785
787
786
788
#[ test]
@@ -858,8 +860,8 @@ fn test_monitor_update_raa_while_paused() {
858
860
expect_pending_htlcs_forwardable ! ( nodes[ 1 ] ) ;
859
861
expect_payment_received ! ( nodes[ 1 ] , our_payment_hash_1, our_payment_secret_1, 1000000 ) ;
860
862
861
- claim_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , payment_preimage_1) ;
862
- claim_payment ( & nodes[ 1 ] , & [ & nodes[ 0 ] ] , payment_preimage_2) ;
863
+ claim_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , payment_preimage_1, our_payment_hash_1 ) ;
864
+ claim_payment ( & nodes[ 1 ] , & [ & nodes[ 0 ] ] , payment_preimage_2, our_payment_hash_2 ) ;
863
865
}
864
866
865
867
fn do_test_monitor_update_fail_raa ( test_ignore_second_cs : bool ) {
@@ -1122,10 +1124,10 @@ fn do_test_monitor_update_fail_raa(test_ignore_second_cs: bool) {
1122
1124
Event :: PaymentReceived { payment_hash, .. } => assert_eq ! ( payment_hash, payment_hash_4. unwrap( ) ) ,
1123
1125
_ => panic ! ( "Unexpected event" ) ,
1124
1126
} ;
1125
- claim_payment ( & nodes[ 2 ] , & [ & nodes[ 1 ] , & nodes[ 0 ] ] , payment_preimage_4. unwrap ( ) ) ;
1127
+ claim_payment ( & nodes[ 2 ] , & [ & nodes[ 1 ] , & nodes[ 0 ] ] , payment_preimage_4. unwrap ( ) , payment_hash_4 . unwrap ( ) ) ;
1126
1128
}
1127
1129
1128
- claim_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] , & nodes[ 2 ] ] , payment_preimage_2) ;
1130
+ claim_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] , & nodes[ 2 ] ] , payment_preimage_2, payment_hash_2 ) ;
1129
1131
}
1130
1132
1131
1133
#[ test]
@@ -1341,9 +1343,9 @@ fn raa_no_response_awaiting_raa_state() {
1341
1343
expect_pending_htlcs_forwardable ! ( nodes[ 1 ] ) ;
1342
1344
expect_payment_received ! ( nodes[ 1 ] , payment_hash_3, payment_secret_3, 1000000 ) ;
1343
1345
1344
- claim_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , payment_preimage_1) ;
1345
- claim_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , payment_preimage_2) ;
1346
- claim_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , payment_preimage_3) ;
1346
+ claim_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , payment_preimage_1, payment_hash_1 ) ;
1347
+ claim_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , payment_preimage_2, payment_hash_2 ) ;
1348
+ claim_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , payment_preimage_3, payment_hash_3 ) ;
1347
1349
}
1348
1350
1349
1351
#[ test]
@@ -1362,7 +1364,7 @@ fn claim_while_disconnected_monitor_update_fail() {
1362
1364
let logger = test_utils:: TestLogger :: new ( ) ;
1363
1365
1364
1366
// Forward a payment for B to claim
1365
- let ( payment_preimage_1, _ , _) = route_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , 1000000 ) ;
1367
+ let ( payment_preimage_1, payment_hash_1 , _) = route_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , 1000000 ) ;
1366
1368
1367
1369
nodes[ 0 ] . node . peer_disconnected ( & nodes[ 1 ] . node . get_our_node_id ( ) , false ) ;
1368
1370
nodes[ 1 ] . node . peer_disconnected ( & nodes[ 0 ] . node . get_our_node_id ( ) , false ) ;
@@ -1463,13 +1465,14 @@ fn claim_while_disconnected_monitor_update_fail() {
1463
1465
let events = nodes[ 0 ] . node . get_and_clear_pending_events ( ) ;
1464
1466
assert_eq ! ( events. len( ) , 1 ) ;
1465
1467
match events[ 0 ] {
1466
- Event :: PaymentSent { ref payment_preimage } => {
1468
+ Event :: PaymentSent { ref payment_preimage, ref payment_hash } => {
1467
1469
assert_eq ! ( * payment_preimage, payment_preimage_1) ;
1470
+ assert_eq ! ( * payment_hash, payment_hash_1) ;
1468
1471
} ,
1469
1472
_ => panic ! ( "Unexpected event" ) ,
1470
1473
}
1471
1474
1472
- claim_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , payment_preimage_2) ;
1475
+ claim_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , payment_preimage_2, payment_hash_2 ) ;
1473
1476
}
1474
1477
1475
1478
#[ test]
@@ -1539,7 +1542,7 @@ fn monitor_failed_no_reestablish_response() {
1539
1542
expect_pending_htlcs_forwardable ! ( nodes[ 1 ] ) ;
1540
1543
expect_payment_received ! ( nodes[ 1 ] , payment_hash_1, payment_secret_1, 1000000 ) ;
1541
1544
1542
- claim_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , payment_preimage_1) ;
1545
+ claim_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , payment_preimage_1, payment_hash_1 ) ;
1543
1546
}
1544
1547
1545
1548
#[ test]
@@ -1640,8 +1643,8 @@ fn first_message_on_recv_ordering() {
1640
1643
expect_pending_htlcs_forwardable ! ( nodes[ 1 ] ) ;
1641
1644
expect_payment_received ! ( nodes[ 1 ] , payment_hash_2, payment_secret_2, 1000000 ) ;
1642
1645
1643
- claim_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , payment_preimage_1) ;
1644
- claim_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , payment_preimage_2) ;
1646
+ claim_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , payment_preimage_1, payment_hash_1 ) ;
1647
+ claim_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , payment_preimage_2, payment_hash_2 ) ;
1645
1648
}
1646
1649
1647
1650
#[ test]
@@ -1662,7 +1665,7 @@ fn test_monitor_update_fail_claim() {
1662
1665
// Rebalance a bit so that we can send backwards from 3 to 2.
1663
1666
send_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] , & nodes[ 2 ] ] , 5000000 ) ;
1664
1667
1665
- let ( payment_preimage_1, _ , _) = route_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , 1000000 ) ;
1668
+ let ( payment_preimage_1, payment_hash , _) = route_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , 1000000 ) ;
1666
1669
1667
1670
* nodes[ 1 ] . chain_monitor . update_ret . lock ( ) . unwrap ( ) = Some ( Err ( ChannelMonitorUpdateErr :: TemporaryFailure ) ) ;
1668
1671
assert ! ( nodes[ 1 ] . node. claim_funds( payment_preimage_1) ) ;
@@ -1715,7 +1718,7 @@ fn test_monitor_update_fail_claim() {
1715
1718
let bs_fulfill_update = get_htlc_update_msgs ! ( nodes[ 1 ] , nodes[ 0 ] . node. get_our_node_id( ) ) ;
1716
1719
nodes[ 0 ] . node . handle_update_fulfill_htlc ( & nodes[ 1 ] . node . get_our_node_id ( ) , & bs_fulfill_update. update_fulfill_htlcs [ 0 ] ) ;
1717
1720
commitment_signed_dance ! ( nodes[ 0 ] , nodes[ 1 ] , bs_fulfill_update. commitment_signed, false ) ;
1718
- expect_payment_sent ! ( nodes[ 0 ] , payment_preimage_1) ;
1721
+ expect_payment_sent ! ( nodes[ 0 ] , payment_preimage_1, payment_hash ) ;
1719
1722
1720
1723
// Get the payment forwards, note that they were batched into one commitment update.
1721
1724
expect_pending_htlcs_forwardable ! ( nodes[ 1 ] ) ;
@@ -1828,7 +1831,7 @@ fn test_monitor_update_on_pending_forwards() {
1828
1831
nodes[ 0 ] . node . process_pending_htlc_forwards ( ) ;
1829
1832
expect_payment_received ! ( nodes[ 0 ] , payment_hash_2, payment_secret_2, 1000000 ) ;
1830
1833
1831
- claim_payment ( & nodes[ 2 ] , & [ & nodes[ 1 ] , & nodes[ 0 ] ] , payment_preimage_2) ;
1834
+ claim_payment ( & nodes[ 2 ] , & [ & nodes[ 1 ] , & nodes[ 0 ] ] , payment_preimage_2, payment_hash_2 ) ;
1832
1835
}
1833
1836
1834
1837
#[ test]
@@ -1845,7 +1848,7 @@ fn monitor_update_claim_fail_no_response() {
1845
1848
let logger = test_utils:: TestLogger :: new ( ) ;
1846
1849
1847
1850
// Forward a payment for B to claim
1848
- let ( payment_preimage_1, _ , _) = route_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , 1000000 ) ;
1851
+ let ( payment_preimage_1, payment_hash_1 , _) = route_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , 1000000 ) ;
1849
1852
1850
1853
// Now start forwarding a second payment, skipping the last RAA so B is in AwaitingRAA
1851
1854
let ( payment_preimage_2, payment_hash_2, payment_secret_2) = get_payment_preimage_hash ! ( nodes[ 1 ] ) ;
@@ -1887,13 +1890,14 @@ fn monitor_update_claim_fail_no_response() {
1887
1890
let events = nodes[ 0 ] . node . get_and_clear_pending_events ( ) ;
1888
1891
assert_eq ! ( events. len( ) , 1 ) ;
1889
1892
match events[ 0 ] {
1890
- Event :: PaymentSent { ref payment_preimage } => {
1893
+ Event :: PaymentSent { ref payment_preimage, ref payment_hash } => {
1891
1894
assert_eq ! ( * payment_preimage, payment_preimage_1) ;
1895
+ assert_eq ! ( * payment_hash, payment_hash_1) ;
1892
1896
} ,
1893
1897
_ => panic ! ( "Unexpected event" ) ,
1894
1898
}
1895
1899
1896
- claim_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , payment_preimage_2) ;
1900
+ claim_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , payment_preimage_2, payment_hash_2 ) ;
1897
1901
}
1898
1902
1899
1903
// confirm_a_first and restore_b_before_conf are wholly unrelated to earlier bools and
@@ -2051,7 +2055,7 @@ fn test_path_paused_mpp() {
2051
2055
assert_eq ! ( events. len( ) , 1 ) ;
2052
2056
pass_along_path ( & nodes[ 0 ] , & [ & nodes[ 2 ] , & nodes[ 3 ] ] , 200_000 , payment_hash. clone ( ) , Some ( payment_secret) , events. pop ( ) . unwrap ( ) , true , None ) ;
2053
2057
2054
- claim_payment_along_route ( & nodes[ 0 ] , & [ & [ & nodes[ 1 ] , & nodes[ 3 ] ] , & [ & nodes[ 2 ] , & nodes[ 3 ] ] ] , false , payment_preimage) ;
2058
+ claim_payment_along_route ( & nodes[ 0 ] , & [ & [ & nodes[ 1 ] , & nodes[ 3 ] ] , & [ & nodes[ 2 ] , & nodes[ 3 ] ] ] , false , payment_preimage, payment_hash ) ;
2055
2059
}
2056
2060
2057
2061
#[ test]
@@ -2143,7 +2147,7 @@ fn test_pending_update_fee_ack_on_reconnect() {
2143
2147
expect_pending_htlcs_forwardable ! ( nodes[ 0 ] ) ;
2144
2148
expect_payment_received ! ( nodes[ 0 ] , payment_hash, payment_secret, 1_000_000 ) ;
2145
2149
2146
- claim_payment ( & nodes[ 1 ] , & [ & nodes[ 0 ] ] , payment_preimage) ;
2150
+ claim_payment ( & nodes[ 1 ] , & [ & nodes[ 0 ] ] , payment_preimage, payment_hash ) ;
2147
2151
}
2148
2152
2149
2153
fn do_update_fee_resend_test ( deliver_update : bool , parallel_updates : bool ) {
@@ -2279,7 +2283,7 @@ fn do_channel_holding_cell_serialize(disconnect: bool, reload_a: bool) {
2279
2283
//
2280
2284
// Note that because, at the end, MonitorUpdateFailed is still set, the HTLC generated in (c)
2281
2285
// will not be freed from the holding cell.
2282
- let ( payment_preimage_0, _ , _) = route_payment ( & nodes[ 1 ] , & [ & nodes[ 0 ] ] , 100000 ) ;
2286
+ let ( payment_preimage_0, payment_hash_0 , _) = route_payment ( & nodes[ 1 ] , & [ & nodes[ 0 ] ] , 100000 ) ;
2283
2287
2284
2288
let route = {
2285
2289
let net_graph_msg_handler = & nodes[ 0 ] . net_graph_msg_handler ;
@@ -2410,7 +2414,7 @@ fn do_channel_holding_cell_serialize(disconnect: bool, reload_a: bool) {
2410
2414
assert ! ( updates. update_fee. is_none( ) ) ;
2411
2415
assert_eq ! ( updates. update_fulfill_htlcs. len( ) , 1 ) ;
2412
2416
nodes[ 1 ] . node . handle_update_fulfill_htlc ( & nodes[ 0 ] . node . get_our_node_id ( ) , & updates. update_fulfill_htlcs [ 0 ] ) ;
2413
- expect_payment_sent ! ( nodes[ 1 ] , payment_preimage_0) ;
2417
+ expect_payment_sent ! ( nodes[ 1 ] , payment_preimage_0, payment_hash_0 ) ;
2414
2418
assert_eq ! ( updates. update_add_htlcs. len( ) , 1 ) ;
2415
2419
nodes[ 1 ] . node . handle_update_add_htlc ( & nodes[ 0 ] . node . get_our_node_id ( ) , & updates. update_add_htlcs [ 0 ] ) ;
2416
2420
updates. commitment_signed
@@ -2432,8 +2436,8 @@ fn do_channel_holding_cell_serialize(disconnect: bool, reload_a: bool) {
2432
2436
expect_pending_htlcs_forwardable ! ( nodes[ 1 ] ) ;
2433
2437
expect_payment_received ! ( nodes[ 1 ] , payment_hash_2, payment_secret_2, 100000 ) ;
2434
2438
2435
- claim_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , payment_preimage_1) ;
2436
- claim_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , payment_preimage_2) ;
2439
+ claim_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , payment_preimage_1, payment_hash_1 ) ;
2440
+ claim_payment ( & nodes[ 0 ] , & [ & nodes[ 1 ] ] , payment_preimage_2, payment_hash_2 ) ;
2437
2441
}
2438
2442
#[ test]
2439
2443
fn channel_holding_cell_serialize ( ) {
@@ -2516,7 +2520,7 @@ fn do_test_reconnect_dup_htlc_claims(htlc_status: HTLCStatusAtDupClaim, second_f
2516
2520
bs_updates = Some ( get_htlc_update_msgs ! ( nodes[ 1 ] , nodes[ 0 ] . node. get_our_node_id( ) ) ) ;
2517
2521
assert_eq ! ( bs_updates. as_ref( ) . unwrap( ) . update_fulfill_htlcs. len( ) , 1 ) ;
2518
2522
nodes[ 0 ] . node . handle_update_fulfill_htlc ( & nodes[ 1 ] . node . get_our_node_id ( ) , & bs_updates. as_ref ( ) . unwrap ( ) . update_fulfill_htlcs [ 0 ] ) ;
2519
- expect_payment_sent ! ( nodes[ 0 ] , payment_preimage) ;
2523
+ expect_payment_sent ! ( nodes[ 0 ] , payment_preimage, payment_hash ) ;
2520
2524
if htlc_status == HTLCStatusAtDupClaim :: Cleared {
2521
2525
commitment_signed_dance ! ( nodes[ 0 ] , nodes[ 1 ] , & bs_updates. as_ref( ) . unwrap( ) . commitment_signed, false ) ;
2522
2526
}
@@ -2542,7 +2546,7 @@ fn do_test_reconnect_dup_htlc_claims(htlc_status: HTLCStatusAtDupClaim, second_f
2542
2546
bs_updates = Some ( get_htlc_update_msgs ! ( nodes[ 1 ] , nodes[ 0 ] . node. get_our_node_id( ) ) ) ;
2543
2547
assert_eq ! ( bs_updates. as_ref( ) . unwrap( ) . update_fulfill_htlcs. len( ) , 1 ) ;
2544
2548
nodes[ 0 ] . node . handle_update_fulfill_htlc ( & nodes[ 1 ] . node . get_our_node_id ( ) , & bs_updates. as_ref ( ) . unwrap ( ) . update_fulfill_htlcs [ 0 ] ) ;
2545
- expect_payment_sent ! ( nodes[ 0 ] , payment_preimage) ;
2549
+ expect_payment_sent ! ( nodes[ 0 ] , payment_preimage, payment_hash ) ;
2546
2550
}
2547
2551
if htlc_status != HTLCStatusAtDupClaim :: Cleared {
2548
2552
commitment_signed_dance ! ( nodes[ 0 ] , nodes[ 1 ] , & bs_updates. as_ref( ) . unwrap( ) . commitment_signed, false ) ;
0 commit comments