]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Pipe through PaymentSecrets in tests during payment hash creation
authorMatt Corallo <git@bluematt.me>
Thu, 22 Apr 2021 22:45:14 +0000 (22:45 +0000)
committerMatt Corallo <git@bluematt.me>
Wed, 28 Apr 2021 19:30:25 +0000 (15:30 -0400)
In order to reduce code movement in the next commit, this commit
simply tweaks get_payment_preimage_hash!() and related functions in
functional tests to return a payment secret. Further, we ensure
that we always call get_payment_preimage_hash!() with the node
which will ultimately receive the payment.

lightning/src/ln/chanmon_update_fail_tests.rs
lightning/src/ln/functional_test_utils.rs
lightning/src/ln/functional_tests.rs
lightning/src/ln/onion_route_tests.rs
lightning/src/ln/reorg_tests.rs

index ee9936b3329222a9974a93014849ad38be82bd3b..d5bf6490ba00ac001f1499a3f39d7ee7d45a9eea 100644 (file)
@@ -19,7 +19,7 @@ use chain::channelmonitor::{ChannelMonitor, ChannelMonitorUpdateErr};
 use chain::transaction::OutPoint;
 use chain::Listen;
 use chain::Watch;
-use ln::channelmanager::{RAACommitmentOrder, PaymentPreimage, PaymentHash, PaymentSecret, PaymentSendFailure};
+use ln::channelmanager::{RAACommitmentOrder, PaymentPreimage, PaymentHash, PaymentSendFailure};
 use ln::features::InitFeatures;
 use ln::msgs;
 use ln::msgs::{ChannelMessageHandler, ErrorAction, RoutingMessageHandler};
@@ -47,7 +47,7 @@ fn do_test_simple_monitor_permanent_update_fail(persister_fail: bool) {
        create_announced_chan_between_nodes(&nodes, 0, 1, InitFeatures::known(), InitFeatures::known());
        let logger = test_utils::TestLogger::new();
 
-       let (_, payment_hash_1) = get_payment_preimage_hash!(&nodes[0]);
+       let (_, payment_hash_1, payment_secret_1) = get_payment_preimage_hash!(&nodes[1]);
 
        match persister_fail {
                true => chanmon_cfgs[0].persister.set_update_ret(Err(ChannelMonitorUpdateErr::PermanentFailure)),
@@ -162,7 +162,7 @@ fn do_test_simple_monitor_temporary_update_fail(disconnect: bool, persister_fail
        let channel_id = create_announced_chan_between_nodes(&nodes, 0, 1, InitFeatures::known(), InitFeatures::known()).2;
        let logger = test_utils::TestLogger::new();
 
-       let (payment_preimage_1, payment_hash_1) = get_payment_preimage_hash!(&nodes[0]);
+       let (payment_preimage_1, payment_hash_1, payment_secret_1) = get_payment_preimage_hash!(&nodes[1]);
 
        match persister_fail {
                true => chanmon_cfgs[0].persister.set_update_ret(Err(ChannelMonitorUpdateErr::TemporaryFailure)),
@@ -217,7 +217,7 @@ fn do_test_simple_monitor_temporary_update_fail(disconnect: bool, persister_fail
        claim_payment(&nodes[0], &[&nodes[1]], payment_preimage_1, 1_000_000);
 
        // Now set it to failed again...
-       let (_, payment_hash_2) = get_payment_preimage_hash!(&nodes[0]);
+       let (_, payment_hash_2, payment_secret_2) = get_payment_preimage_hash!(&nodes[1]);
        {
                match persister_fail {
                        true => chanmon_cfgs[0].persister.set_update_ret(Err(ChannelMonitorUpdateErr::TemporaryFailure)),
@@ -287,10 +287,10 @@ fn do_test_monitor_temporary_update_fail(disconnect_count: usize) {
        let channel_id = create_announced_chan_between_nodes(&nodes, 0, 1, InitFeatures::known(), InitFeatures::known()).2;
        let logger = test_utils::TestLogger::new();
 
-       let (payment_preimage_1, _) = route_payment(&nodes[0], &[&nodes[1]], 1000000);
+       let (payment_preimage_1, _, _) = route_payment(&nodes[0], &[&nodes[1]], 1000000);
 
        // Now try to send a second payment which will fail to send
-       let (payment_preimage_2, payment_hash_2) = get_payment_preimage_hash!(nodes[0]);
+       let (payment_preimage_2, payment_hash_2, payment_secret_2) = get_payment_preimage_hash!(nodes[1]);
        {
                *nodes[0].chain_monitor.update_ret.lock().unwrap() = Some(Err(ChannelMonitorUpdateErr::TemporaryFailure));
                let net_graph_msg_handler = &nodes[0].net_graph_msg_handler;
@@ -622,7 +622,7 @@ fn test_monitor_update_fail_cs() {
        let channel_id = create_announced_chan_between_nodes(&nodes, 0, 1, InitFeatures::known(), InitFeatures::known()).2;
        let logger = test_utils::TestLogger::new();
 
-       let (payment_preimage, our_payment_hash) = get_payment_preimage_hash!(nodes[0]);
+       let (payment_preimage, our_payment_hash, our_payment_secret) = get_payment_preimage_hash!(nodes[1]);
        {
                let net_graph_msg_handler = &nodes[0].net_graph_msg_handler;
                let route = get_route(&nodes[0].node.get_our_node_id(), &net_graph_msg_handler.network_graph.read().unwrap(), &nodes[1].node.get_our_node_id(), None, None, &Vec::new(), 1000000, TEST_FINAL_CLTV, &logger).unwrap();
@@ -711,7 +711,7 @@ fn test_monitor_update_fail_no_rebroadcast() {
        let channel_id = create_announced_chan_between_nodes(&nodes, 0, 1, InitFeatures::known(), InitFeatures::known()).2;
        let logger = test_utils::TestLogger::new();
 
-       let (payment_preimage_1, our_payment_hash) = get_payment_preimage_hash!(nodes[0]);
+       let (payment_preimage_1, our_payment_hash, payment_secret_1) = get_payment_preimage_hash!(nodes[1]);
        {
                let net_graph_msg_handler = &nodes[0].net_graph_msg_handler;
                let route = get_route(&nodes[0].node.get_our_node_id(), &net_graph_msg_handler.network_graph.read().unwrap(), &nodes[1].node.get_our_node_id(), None, None, &Vec::new(), 1000000, TEST_FINAL_CLTV, &logger).unwrap();
@@ -762,7 +762,7 @@ fn test_monitor_update_raa_while_paused() {
        let logger = test_utils::TestLogger::new();
 
        send_payment(&nodes[0], &[&nodes[1]], 5000000, 5_000_000);
-       let (payment_preimage_1, our_payment_hash_1) = get_payment_preimage_hash!(nodes[0]);
+       let (payment_preimage_1, our_payment_hash_1, our_payment_secret_1) = get_payment_preimage_hash!(nodes[1]);
        {
                let net_graph_msg_handler = &nodes[0].net_graph_msg_handler;
                let route = get_route(&nodes[0].node.get_our_node_id(), &net_graph_msg_handler.network_graph.read().unwrap(), &nodes[1].node.get_our_node_id(), None, None, &Vec::new(), 1000000, TEST_FINAL_CLTV, &logger).unwrap();
@@ -771,7 +771,7 @@ fn test_monitor_update_raa_while_paused() {
        }
        let send_event_1 = SendEvent::from_event(nodes[0].node.get_and_clear_pending_msg_events().remove(0));
 
-       let (payment_preimage_2, our_payment_hash_2) = get_payment_preimage_hash!(nodes[0]);
+       let (payment_preimage_2, our_payment_hash_2, our_payment_secret_2) = get_payment_preimage_hash!(nodes[0]);
        {
                let net_graph_msg_handler = &nodes[1].net_graph_msg_handler;
                let route = get_route(&nodes[1].node.get_our_node_id(), &net_graph_msg_handler.network_graph.read().unwrap(), &nodes[0].node.get_our_node_id(), None, None, &Vec::new(), 1000000, TEST_FINAL_CLTV, &logger).unwrap();
@@ -843,7 +843,7 @@ fn do_test_monitor_update_fail_raa(test_ignore_second_cs: bool) {
        send_payment(&nodes[0], &[&nodes[1], &nodes[2]], 5000000, 5_000_000);
 
        // Route a first payment that we'll fail backwards
-       let (_, payment_hash_1) = route_payment(&nodes[0], &[&nodes[1], &nodes[2]], 1000000);
+       let (_, payment_hash_1, _) = route_payment(&nodes[0], &[&nodes[1], &nodes[2]], 1000000);
 
        // Fail the payment backwards, failing the monitor update on nodes[1]'s receipt of the RAA
        assert!(nodes[2].node.fail_htlc_backwards(&payment_hash_1, &None));
@@ -863,7 +863,7 @@ fn do_test_monitor_update_fail_raa(test_ignore_second_cs: bool) {
 
        // While the second channel is AwaitingRAA, forward a second payment to get it into the
        // holding cell.
-       let (payment_preimage_2, payment_hash_2) = get_payment_preimage_hash!(nodes[0]);
+       let (payment_preimage_2, payment_hash_2, payment_secret_2) = get_payment_preimage_hash!(nodes[2]);
        {
                let net_graph_msg_handler = &nodes[0].net_graph_msg_handler;
                let route = get_route(&nodes[0].node.get_our_node_id(), &net_graph_msg_handler.network_graph.read().unwrap(), &nodes[2].node.get_our_node_id(), None, None, &Vec::new(), 1000000, TEST_FINAL_CLTV, &logger).unwrap();
@@ -890,7 +890,7 @@ fn do_test_monitor_update_fail_raa(test_ignore_second_cs: bool) {
 
        // Attempt to forward a third payment but fail due to the second channel being unavailable
        // for forwarding.
-       let (_, payment_hash_3) = get_payment_preimage_hash!(nodes[0]);
+       let (_, payment_hash_3, payment_secret_3) = get_payment_preimage_hash!(nodes[2]);
        {
                let net_graph_msg_handler = &nodes[0].net_graph_msg_handler;
                let route = get_route(&nodes[0].node.get_our_node_id(), &net_graph_msg_handler.network_graph.read().unwrap(), &nodes[2].node.get_our_node_id(), None, None, &Vec::new(), 1000000, TEST_FINAL_CLTV, &logger).unwrap();
@@ -940,7 +940,7 @@ fn do_test_monitor_update_fail_raa(test_ignore_second_cs: bool) {
 
        let (payment_preimage_4, payment_hash_4) = if test_ignore_second_cs {
                // Try to route another payment backwards from 2 to make sure 1 holds off on responding
-               let (payment_preimage_4, payment_hash_4) = get_payment_preimage_hash!(nodes[0]);
+               let (payment_preimage_4, payment_hash_4, payment_secret_4) = get_payment_preimage_hash!(nodes[0]);
                let net_graph_msg_handler = &nodes[2].net_graph_msg_handler;
                let route = get_route(&nodes[2].node.get_our_node_id(), &net_graph_msg_handler.network_graph.read().unwrap(), &nodes[0].node.get_our_node_id(), None, None, &Vec::new(), 1000000, TEST_FINAL_CLTV, &logger).unwrap();
                nodes[2].node.send_payment(&route, payment_hash_4, &None).unwrap();
@@ -1103,7 +1103,7 @@ fn test_monitor_update_fail_reestablish() {
        let chan_1 = create_announced_chan_between_nodes(&nodes, 0, 1, InitFeatures::known(), InitFeatures::known());
        create_announced_chan_between_nodes(&nodes, 1, 2, InitFeatures::known(), InitFeatures::known());
 
-       let (our_payment_preimage, _) = route_payment(&nodes[0], &[&nodes[1], &nodes[2]], 1000000);
+       let (our_payment_preimage, _, _) = route_payment(&nodes[0], &[&nodes[1], &nodes[2]], 1000000);
 
        nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id(), false);
        nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id(), false);
@@ -1185,9 +1185,9 @@ fn raa_no_response_awaiting_raa_state() {
        let channel_id = create_announced_chan_between_nodes(&nodes, 0, 1, InitFeatures::known(), InitFeatures::known()).2;
        let logger = test_utils::TestLogger::new();
 
-       let (payment_preimage_1, payment_hash_1) = get_payment_preimage_hash!(nodes[0]);
-       let (payment_preimage_2, payment_hash_2) = get_payment_preimage_hash!(nodes[0]);
-       let (payment_preimage_3, payment_hash_3) = get_payment_preimage_hash!(nodes[0]);
+       let (payment_preimage_1, payment_hash_1, payment_secret_1) = get_payment_preimage_hash!(nodes[1]);
+       let (payment_preimage_2, payment_hash_2, payment_secret_2) = get_payment_preimage_hash!(nodes[1]);
+       let (payment_preimage_3, payment_hash_3, payment_secret_3) = get_payment_preimage_hash!(nodes[1]);
 
        // Queue up two payments - one will be delivered right away, one immediately goes into the
        // holding cell as nodes[0] is AwaitingRAA. Ultimately this allows us to deliver an RAA
@@ -1310,7 +1310,7 @@ fn claim_while_disconnected_monitor_update_fail() {
        let logger = test_utils::TestLogger::new();
 
        // Forward a payment for B to claim
-       let (payment_preimage_1, _) = route_payment(&nodes[0], &[&nodes[1]], 1000000);
+       let (payment_preimage_1, _, _) = route_payment(&nodes[0], &[&nodes[1]], 1000000);
 
        nodes[0].node.peer_disconnected(&nodes[1].node.get_our_node_id(), false);
        nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id(), false);
@@ -1339,7 +1339,7 @@ fn claim_while_disconnected_monitor_update_fail() {
 
        // Send a second payment from A to B, resulting in a commitment update that gets swallowed with
        // the monitor still failed
-       let (payment_preimage_2, payment_hash_2) = get_payment_preimage_hash!(nodes[0]);
+       let (payment_preimage_2, payment_hash_2, payment_secret_2) = get_payment_preimage_hash!(nodes[1]);
        {
                let net_graph_msg_handler = &nodes[0].net_graph_msg_handler;
                let route = get_route(&nodes[0].node.get_our_node_id(), &net_graph_msg_handler.network_graph.read().unwrap(), &nodes[1].node.get_our_node_id(), None, None, &Vec::new(), 1000000, TEST_FINAL_CLTV, &logger).unwrap();
@@ -1435,7 +1435,7 @@ fn monitor_failed_no_reestablish_response() {
 
        // Route the payment and deliver the initial commitment_signed (with a monitor update failure
        // on receipt).
-       let (payment_preimage_1, payment_hash_1) = get_payment_preimage_hash!(nodes[0]);
+       let (payment_preimage_1, payment_hash_1, payment_secret_1) = get_payment_preimage_hash!(nodes[1]);
        {
                let net_graph_msg_handler = &nodes[0].net_graph_msg_handler;
                let route = get_route(&nodes[0].node.get_our_node_id(), &net_graph_msg_handler.network_graph.read().unwrap(), &nodes[1].node.get_our_node_id(), None, None, &Vec::new(), 1000000, TEST_FINAL_CLTV, &logger).unwrap();
@@ -1509,7 +1509,7 @@ fn first_message_on_recv_ordering() {
 
        // Route the first payment outbound, holding the last RAA for B until we are set up so that we
        // can deliver it and fail the monitor update.
-       let (payment_preimage_1, payment_hash_1) = get_payment_preimage_hash!(nodes[0]);
+       let (payment_preimage_1, payment_hash_1, payment_secret_1) = get_payment_preimage_hash!(nodes[1]);
        {
                let net_graph_msg_handler = &nodes[0].net_graph_msg_handler;
                let route = get_route(&nodes[0].node.get_our_node_id(), &net_graph_msg_handler.network_graph.read().unwrap(), &nodes[1].node.get_our_node_id(), None, None, &Vec::new(), 1000000, TEST_FINAL_CLTV, &logger).unwrap();
@@ -1534,7 +1534,7 @@ fn first_message_on_recv_ordering() {
        let as_raa = get_event_msg!(nodes[0], MessageSendEvent::SendRevokeAndACK, nodes[1].node.get_our_node_id());
 
        // Route the second payment, generating an update_add_htlc/commitment_signed
-       let (payment_preimage_2, payment_hash_2) = get_payment_preimage_hash!(nodes[0]);
+       let (payment_preimage_2, payment_hash_2, payment_secret_2) = get_payment_preimage_hash!(nodes[1]);
        {
                let net_graph_msg_handler = &nodes[0].net_graph_msg_handler;
                let route = get_route(&nodes[0].node.get_our_node_id(), &net_graph_msg_handler.network_graph.read().unwrap(), &nodes[1].node.get_our_node_id(), None, None, &Vec::new(), 1000000, TEST_FINAL_CLTV, &logger).unwrap();
@@ -1608,13 +1608,13 @@ fn test_monitor_update_fail_claim() {
        // Rebalance a bit so that we can send backwards from 3 to 2.
        send_payment(&nodes[0], &[&nodes[1], &nodes[2]], 5000000, 5_000_000);
 
-       let (payment_preimage_1, _) = route_payment(&nodes[0], &[&nodes[1]], 1000000);
+       let (payment_preimage_1, _, _) = route_payment(&nodes[0], &[&nodes[1]], 1000000);
 
        *nodes[1].chain_monitor.update_ret.lock().unwrap() = Some(Err(ChannelMonitorUpdateErr::TemporaryFailure));
        assert!(nodes[1].node.claim_funds(payment_preimage_1, &None, 1_000_000));
        check_added_monitors!(nodes[1], 1);
 
-       let (_, payment_hash_2) = get_payment_preimage_hash!(nodes[0]);
+       let (_, payment_hash_2, payment_secret_2) = get_payment_preimage_hash!(nodes[0]);
        {
                let net_graph_msg_handler = &nodes[2].net_graph_msg_handler;
                let route = get_route(&nodes[2].node.get_our_node_id(), &net_graph_msg_handler.network_graph.read().unwrap(), &nodes[0].node.get_our_node_id(), None, None, &Vec::new(), 1000000, TEST_FINAL_CLTV, &logger).unwrap();
@@ -1689,7 +1689,7 @@ fn test_monitor_update_on_pending_forwards() {
        // Rebalance a bit so that we can send backwards from 3 to 1.
        send_payment(&nodes[0], &[&nodes[1], &nodes[2]], 5000000, 5_000_000);
 
-       let (_, payment_hash_1) = route_payment(&nodes[0], &[&nodes[1], &nodes[2]], 1000000);
+       let (_, payment_hash_1, _) = route_payment(&nodes[0], &[&nodes[1], &nodes[2]], 1000000);
        assert!(nodes[2].node.fail_htlc_backwards(&payment_hash_1, &None));
        expect_pending_htlcs_forwardable!(nodes[2]);
        check_added_monitors!(nodes[2], 1);
@@ -1699,7 +1699,7 @@ fn test_monitor_update_on_pending_forwards() {
        commitment_signed_dance!(nodes[1], nodes[2], cs_fail_update.commitment_signed, true, true);
        assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty());
 
-       let (payment_preimage_2, payment_hash_2) = get_payment_preimage_hash!(nodes[0]);
+       let (payment_preimage_2, payment_hash_2, payment_secret_2) = get_payment_preimage_hash!(nodes[0]);
        {
                let net_graph_msg_handler = &nodes[2].net_graph_msg_handler;
                let route = get_route(&nodes[2].node.get_our_node_id(), &net_graph_msg_handler.network_graph.read().unwrap(), &nodes[0].node.get_our_node_id(), None, None, &Vec::new(), 1000000, TEST_FINAL_CLTV, &logger).unwrap();
@@ -1759,10 +1759,10 @@ fn monitor_update_claim_fail_no_response() {
        let logger = test_utils::TestLogger::new();
 
        // Forward a payment for B to claim
-       let (payment_preimage_1, _) = route_payment(&nodes[0], &[&nodes[1]], 1000000);
+       let (payment_preimage_1, _, _) = route_payment(&nodes[0], &[&nodes[1]], 1000000);
 
        // Now start forwarding a second payment, skipping the last RAA so B is in AwaitingRAA
-       let (payment_preimage_2, payment_hash_2) = get_payment_preimage_hash!(nodes[0]);
+       let (payment_preimage_2, payment_hash_2, payment_secret_2) = get_payment_preimage_hash!(nodes[1]);
        {
                let net_graph_msg_handler = &nodes[0].net_graph_msg_handler;
                let route = get_route(&nodes[0].node.get_our_node_id(), &net_graph_msg_handler.network_graph.read().unwrap(), &nodes[1].node.get_our_node_id(), None, None, &Vec::new(), 1000000, TEST_FINAL_CLTV, &logger).unwrap();
@@ -1923,8 +1923,7 @@ fn test_path_paused_mpp() {
        let chan_4_id = create_announced_chan_between_nodes(&nodes, 2, 3, InitFeatures::known(), InitFeatures::known()).0.contents.short_channel_id;
        let logger = test_utils::TestLogger::new();
 
-       let (payment_preimage, payment_hash) = get_payment_preimage_hash!(&nodes[0]);
-       let payment_secret = PaymentSecret([0xdb; 32]);
+       let (payment_preimage, payment_hash, payment_secret) = get_payment_preimage_hash!(&nodes[3]);
        let mut route = get_route(&nodes[0].node.get_our_node_id(), &nodes[0].net_graph_msg_handler.network_graph.read().unwrap(), &nodes[3].node.get_our_node_id(), None, None, &[], 100000, TEST_FINAL_CLTV, &logger).unwrap();
 
        // Set us up to take multiple routes, one 0 -> 1 -> 3 and one 0 -> 2 -> 3:
index 5951b5bca4b67d6d0306e03f066251c7282d849f..b47228d4370573ac920e470a42d9e8886eb6e5bd 100644 (file)
@@ -894,12 +894,13 @@ macro_rules! commitment_signed_dance {
 /// Get a payment preimage and hash.
 #[macro_export]
 macro_rules! get_payment_preimage_hash {
-       ($node: expr) => {
+       ($dest_node: expr) => {
                {
-                       let payment_preimage = PaymentPreimage([*$node.network_payment_count.borrow(); 32]);
-                       *$node.network_payment_count.borrow_mut() += 1;
+                       let payment_preimage = PaymentPreimage([*$dest_node.network_payment_count.borrow(); 32]);
+                       *$dest_node.network_payment_count.borrow_mut() += 1;
                        let payment_hash = PaymentHash(Sha256::hash(&payment_preimage.0[..]).into_inner());
-                       (payment_preimage, payment_hash)
+                       let payment_secret = $dest_node.node.create_inbound_payment_for_hash(payment_hash, None, 7200).unwrap();
+                       (payment_preimage, payment_hash, payment_secret)
                }
        }
 }
@@ -907,12 +908,12 @@ macro_rules! get_payment_preimage_hash {
 #[cfg(test)]
 macro_rules! get_route_and_payment_hash {
        ($send_node: expr, $recv_node: expr, $recv_value: expr) => {{
-               let (payment_preimage, payment_hash) = get_payment_preimage_hash!($recv_node);
+               let (payment_preimage, payment_hash, payment_secret) = get_payment_preimage_hash!($recv_node);
                let net_graph_msg_handler = &$send_node.net_graph_msg_handler;
                let route = get_route(&$send_node.node.get_our_node_id(),
                        &net_graph_msg_handler.network_graph.read().unwrap(),
                        &$recv_node.node.get_our_node_id(), None, None, &Vec::new(), $recv_value, TEST_FINAL_CLTV, $send_node.logger).unwrap();
-               (route, payment_hash, payment_preimage)
+               (route, payment_hash, payment_preimage, payment_secret)
        }}
 }
 
@@ -1045,10 +1046,10 @@ pub fn send_along_route_with_hash<'a, 'b, 'c>(origin_node: &Node<'a, 'b, 'c>, ro
        send_along_route_with_secret(origin_node, route, &[expected_route], recv_value, our_payment_hash, None);
 }
 
-pub fn send_along_route<'a, 'b, 'c>(origin_node: &Node<'a, 'b, 'c>, route: Route, expected_route: &[&Node<'a, 'b, 'c>], recv_value: u64) -> (PaymentPreimage, PaymentHash) {
-       let (our_payment_preimage, our_payment_hash) = get_payment_preimage_hash!(origin_node);
+pub fn send_along_route<'a, 'b, 'c>(origin_node: &Node<'a, 'b, 'c>, route: Route, expected_route: &[&Node<'a, 'b, 'c>], recv_value: u64) -> (PaymentPreimage, PaymentHash, PaymentSecret) {
+       let (our_payment_preimage, our_payment_hash, our_payment_secret) = get_payment_preimage_hash!(expected_route.last().unwrap());
        send_along_route_with_hash(origin_node, route, expected_route, recv_value, our_payment_hash);
-       (our_payment_preimage, our_payment_hash)
+       (our_payment_preimage, our_payment_hash, our_payment_secret)
 }
 
 pub fn claim_payment_along_route_with_secret<'a, 'b, 'c>(origin_node: &Node<'a, 'b, 'c>, expected_paths: &[&[&Node<'a, 'b, 'c>]], skip_last: bool, our_payment_preimage: PaymentPreimage, our_payment_secret: Option<PaymentSecret>, expected_amount: u64) {
@@ -1149,7 +1150,7 @@ pub fn claim_payment<'a, 'b, 'c>(origin_node: &Node<'a, 'b, 'c>, expected_route:
 
 pub const TEST_FINAL_CLTV: u32 = 50;
 
-pub fn route_payment<'a, 'b, 'c>(origin_node: &Node<'a, 'b, 'c>, expected_route: &[&Node<'a, 'b, 'c>], recv_value: u64) -> (PaymentPreimage, PaymentHash) {
+pub fn route_payment<'a, 'b, 'c>(origin_node: &Node<'a, 'b, 'c>, expected_route: &[&Node<'a, 'b, 'c>], recv_value: u64) -> (PaymentPreimage, PaymentHash, PaymentSecret) {
        let net_graph_msg_handler = &origin_node.net_graph_msg_handler;
        let logger = test_utils::TestLogger::new();
        let route = get_route(&origin_node.node.get_our_node_id(), &net_graph_msg_handler.network_graph.read().unwrap(), &expected_route.last().unwrap().node.get_our_node_id(), None, None, &Vec::new(), recv_value, TEST_FINAL_CLTV, &logger).unwrap();
@@ -1172,7 +1173,7 @@ pub fn route_over_limit<'a, 'b, 'c>(origin_node: &Node<'a, 'b, 'c>, expected_rou
                assert_eq!(hop.pubkey, node.node.get_our_node_id());
        }
 
-       let (_, our_payment_hash) = get_payment_preimage_hash!(origin_node);
+       let (_, our_payment_hash, _) = get_payment_preimage_hash!(expected_route.last().unwrap());
        unwrap_send_err!(origin_node.node.send_payment(&route, our_payment_hash, &None), true, APIError::ChannelUnavailable { ref err },
                assert!(err.contains("Cannot send value that would put us over the max HTLC value in flight our peer will accept")));
 }
index 4ad777f5b6275cc957d5528cf62f4818db049f28..214c2605a27208d5b25c7efee8ef1fafc5f50e92 100644 (file)
@@ -163,7 +163,7 @@ fn test_async_inbound_update_fee() {
        nodes[1].node.handle_update_fee(&nodes[0].node.get_our_node_id(), update_msg.unwrap());
 
        // ...but before it's delivered, nodes[1] starts to send a payment back to nodes[0]...
-       let (_, our_payment_hash) = get_payment_preimage_hash!(nodes[0]);
+       let (_, our_payment_hash, our_payment_secret) = get_payment_preimage_hash!(nodes[0]);
        let net_graph_msg_handler = &nodes[1].net_graph_msg_handler;
        nodes[1].node.send_payment(&get_route(&nodes[1].node.get_our_node_id(), &net_graph_msg_handler.network_graph.read().unwrap(), &nodes[0].node.get_our_node_id(), None, None, &Vec::new(), 40000, TEST_FINAL_CLTV, &logger).unwrap(), our_payment_hash, &None).unwrap();
        check_added_monitors!(nodes[1], 1);
@@ -261,7 +261,7 @@ fn test_update_fee_unordered_raa() {
        nodes[1].node.handle_update_fee(&nodes[0].node.get_our_node_id(), update_msg.unwrap());
 
        // ...but before it's delivered, nodes[1] starts to send a payment back to nodes[0]...
-       let (_, our_payment_hash) = get_payment_preimage_hash!(nodes[0]);
+       let (_, our_payment_hash, our_payment_secret) = get_payment_preimage_hash!(nodes[0]);
        let net_graph_msg_handler = &nodes[1].net_graph_msg_handler;
        nodes[1].node.send_payment(&get_route(&nodes[1].node.get_our_node_id(), &net_graph_msg_handler.network_graph.read().unwrap(), &nodes[0].node.get_our_node_id(), None, None, &Vec::new(), 40000, TEST_FINAL_CLTV, &logger).unwrap(), our_payment_hash, &None).unwrap();
        check_added_monitors!(nodes[1], 1);
@@ -644,7 +644,7 @@ fn test_update_fee_with_fundee_update_add_htlc() {
        let (revoke_msg, commitment_signed) = get_revoke_commit_msgs!(nodes[1], nodes[0].node.get_our_node_id());
        check_added_monitors!(nodes[1], 1);
 
-       let (our_payment_preimage, our_payment_hash) = get_payment_preimage_hash!(nodes[1]);
+       let (our_payment_preimage, our_payment_hash, our_payment_secret) = get_payment_preimage_hash!(nodes[0]);
        let net_graph_msg_handler = &nodes[1].net_graph_msg_handler;
        let route = get_route(&nodes[1].node.get_our_node_id(), &net_graph_msg_handler.network_graph.read().unwrap(), &nodes[0].node.get_our_node_id(), None, None, &Vec::new(), 800000, TEST_FINAL_CLTV, &logger).unwrap();
 
@@ -854,7 +854,7 @@ fn updates_shutdown_wait() {
        let chan_2 = create_announced_chan_between_nodes(&nodes, 1, 2, InitFeatures::known(), InitFeatures::known());
        let logger = test_utils::TestLogger::new();
 
-       let (our_payment_preimage, _) = route_payment(&nodes[0], &[&nodes[1], &nodes[2]], 100000);
+       let (our_payment_preimage, _, _) = route_payment(&nodes[0], &[&nodes[1], &nodes[2]], 100000);
 
        nodes[0].node.close_channel(&chan_1.2).unwrap();
        let node_0_shutdown = get_event_msg!(nodes[0], MessageSendEvent::SendShutdown, nodes[1].node.get_our_node_id());
@@ -865,7 +865,7 @@ fn updates_shutdown_wait() {
        assert!(nodes[0].node.get_and_clear_pending_msg_events().is_empty());
        assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty());
 
-       let (_, payment_hash) = get_payment_preimage_hash!(nodes[0]);
+       let (_, payment_hash, payment_secret) = get_payment_preimage_hash!(nodes[0]);
 
        let net_graph_msg_handler0 = &nodes[0].net_graph_msg_handler;
        let net_graph_msg_handler1 = &nodes[1].net_graph_msg_handler;
@@ -931,7 +931,7 @@ fn htlc_fail_async_shutdown() {
        let chan_2 = create_announced_chan_between_nodes(&nodes, 1, 2, InitFeatures::known(), InitFeatures::known());
        let logger = test_utils::TestLogger::new();
 
-       let (_, our_payment_hash) = get_payment_preimage_hash!(nodes[0]);
+       let (_, our_payment_hash, our_payment_secret) = get_payment_preimage_hash!(nodes[2]);
        let net_graph_msg_handler = &nodes[0].net_graph_msg_handler;
        let route = get_route(&nodes[0].node.get_our_node_id(), &net_graph_msg_handler.network_graph.read().unwrap(), &nodes[2].node.get_our_node_id(), None, None, &[], 100000, TEST_FINAL_CLTV, &logger).unwrap();
        nodes[0].node.send_payment(&route, our_payment_hash, &None).unwrap();
@@ -1008,7 +1008,7 @@ fn do_test_shutdown_rebroadcast(recv_count: u8) {
        let chan_1 = create_announced_chan_between_nodes(&nodes, 0, 1, InitFeatures::known(), InitFeatures::known());
        let chan_2 = create_announced_chan_between_nodes(&nodes, 1, 2, InitFeatures::known(), InitFeatures::known());
 
-       let (our_payment_preimage, _) = route_payment(&nodes[0], &[&nodes[1], &nodes[2]], 100000);
+       let (our_payment_preimage, _, our_payment_secret) = route_payment(&nodes[0], &[&nodes[1], &nodes[2]], 100000);
 
        nodes[1].node.close_channel(&chan_1.2).unwrap();
        let node_1_shutdown = get_event_msg!(nodes[1], MessageSendEvent::SendShutdown, nodes[0].node.get_our_node_id());
@@ -1306,7 +1306,7 @@ fn holding_cell_htlc_counting() {
 
        let mut payments = Vec::new();
        for _ in 0..::ln::channel::OUR_MAX_HTLCS {
-               let (payment_preimage, payment_hash) = get_payment_preimage_hash!(nodes[0]);
+               let (payment_preimage, payment_hash, payment_secret) = get_payment_preimage_hash!(nodes[2]);
                let net_graph_msg_handler = &nodes[1].net_graph_msg_handler;
                let route = get_route(&nodes[1].node.get_our_node_id(), &net_graph_msg_handler.network_graph.read().unwrap(), &nodes[2].node.get_our_node_id(), None, None, &Vec::new(), 100000, TEST_FINAL_CLTV, &logger).unwrap();
                nodes[1].node.send_payment(&route, payment_hash, &None).unwrap();
@@ -1322,7 +1322,7 @@ fn holding_cell_htlc_counting() {
        // There is now one HTLC in an outbound commitment transaction and (OUR_MAX_HTLCS - 1) HTLCs in
        // the holding cell waiting on B's RAA to send. At this point we should not be able to add
        // another HTLC.
-       let (_, payment_hash_1) = get_payment_preimage_hash!(nodes[0]);
+       let (_, payment_hash_1, payment_secret_1) = get_payment_preimage_hash!(nodes[2]);
        {
                let net_graph_msg_handler = &nodes[1].net_graph_msg_handler;
                let route = get_route(&nodes[1].node.get_our_node_id(), &net_graph_msg_handler.network_graph.read().unwrap(), &nodes[2].node.get_our_node_id(), None, None, &Vec::new(), 100000, TEST_FINAL_CLTV, &logger).unwrap();
@@ -1333,7 +1333,7 @@ fn holding_cell_htlc_counting() {
        }
 
        // This should also be true if we try to forward a payment.
-       let (_, payment_hash_2) = get_payment_preimage_hash!(nodes[0]);
+       let (_, payment_hash_2, payment_secret_2) = get_payment_preimage_hash!(nodes[2]);
        {
                let net_graph_msg_handler = &nodes[0].net_graph_msg_handler;
                let route = get_route(&nodes[0].node.get_our_node_id(), &net_graph_msg_handler.network_graph.read().unwrap(), &nodes[2].node.get_our_node_id(), None, None, &Vec::new(), 100000, TEST_FINAL_CLTV, &logger).unwrap();
@@ -1437,7 +1437,7 @@ fn duplicate_htlc_test() {
        create_announced_chan_between_nodes(&nodes, 3, 4, InitFeatures::known(), InitFeatures::known());
        create_announced_chan_between_nodes(&nodes, 3, 5, InitFeatures::known(), InitFeatures::known());
 
-       let (payment_preimage, payment_hash) = route_payment(&nodes[0], &vec!(&nodes[3], &nodes[4])[..], 1000000);
+       let (payment_preimage, payment_hash, _) = route_payment(&nodes[0], &vec!(&nodes[3], &nodes[4])[..], 1000000);
 
        *nodes[0].network_payment_count.borrow_mut() -= 1;
        assert_eq!(route_payment(&nodes[1], &vec!(&nodes[3])[..], 1000000).0, payment_preimage);
@@ -1466,7 +1466,7 @@ fn test_duplicate_htlc_different_direction_onchain() {
        // balancing
        send_payment(&nodes[0], &vec!(&nodes[1])[..], 8000000, 8_000_000);
 
-       let (payment_preimage, payment_hash) = route_payment(&nodes[0], &vec!(&nodes[1])[..], 900_000);
+       let (payment_preimage, payment_hash, payment_secret) = route_payment(&nodes[0], &vec!(&nodes[1])[..], 900_000);
 
        let net_graph_msg_handler = &nodes[1].net_graph_msg_handler;
        let route = get_route(&nodes[1].node.get_our_node_id(), &net_graph_msg_handler.network_graph.read().unwrap(), &nodes[0].node.get_our_node_id(), None, None, &Vec::new(), 800_000, TEST_FINAL_CLTV, &logger).unwrap();
@@ -1540,7 +1540,7 @@ fn test_basic_channel_reserve() {
        let channel_reserve = chan_stat.channel_reserve_msat;
 
        // The 2* and +1 are for the fee spike reserve.
-       let (_, our_payment_hash) = get_payment_preimage_hash!(nodes[0]);
+       let (_, our_payment_hash, our_payment_secret) = get_payment_preimage_hash!(nodes[1]);
        let commit_tx_fee = 2 * commit_tx_fee_msat(get_feerate!(nodes[0], chan.2), 1 + 1);
        let max_can_send = 5000000 - channel_reserve - commit_tx_fee;
        let net_graph_msg_handler = &nodes[0].net_graph_msg_handler;
@@ -1570,7 +1570,7 @@ fn test_fee_spike_violation_fails_htlc() {
        let mut nodes = create_network(2, &node_cfgs, &node_chanmgrs);
        let chan = create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 100000, 95000000, InitFeatures::known(), InitFeatures::known());
 
-       let (route, payment_hash, _) = get_route_and_payment_hash!(nodes[0], nodes[1], 3460001);
+       let (route, payment_hash, _, payment_secret) = get_route_and_payment_hash!(nodes[0], nodes[1], 3460001);
        // Need to manually create the update_add_htlc message to go around the channel reserve check in send_htlc()
        let secp_ctx = Secp256k1::new();
        let session_priv = SecretKey::from_slice(&[42; 32]).expect("RNG is bad!");
@@ -1700,7 +1700,7 @@ fn test_chan_reserve_violation_outbound_htlc_inbound_chan() {
        let mut nodes = create_network(2, &node_cfgs, &node_chanmgrs);
        let _ = create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 100000, 95000000, InitFeatures::known(), InitFeatures::known());
 
-       let (route, our_payment_hash, _) = get_route_and_payment_hash!(nodes[1], nodes[0], 4843000);
+       let (route, our_payment_hash, _, our_payment_secret) = get_route_and_payment_hash!(nodes[1], nodes[0], 4843000);
        unwrap_send_err!(nodes[1].node.send_payment(&route, our_payment_hash, &None), true, APIError::ChannelUnavailable { ref err },
                assert_eq!(err, "Cannot send value that would put counterparty balance under holder-announced channel reserve value"));
        assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty());
@@ -1722,7 +1722,7 @@ fn test_chan_reserve_violation_inbound_htlc_outbound_channel() {
        let mut nodes = create_network(2, &node_cfgs, &node_chanmgrs);
        let chan = create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 100000, 95000000, InitFeatures::known(), InitFeatures::known());
 
-       let (route, payment_hash, _) = get_route_and_payment_hash!(nodes[1], nodes[0], 1000);
+       let (route, payment_hash, _, payment_secret) = get_route_and_payment_hash!(nodes[1], nodes[0], 1000);
        // Need to manually create the update_add_htlc message to go around the channel reserve check in send_htlc()
        let secp_ctx = Secp256k1::new();
        let session_priv = SecretKey::from_slice(&[42; 32]).unwrap();
@@ -1766,7 +1766,7 @@ fn test_chan_reserve_dust_inbound_htlcs_outbound_chan() {
        // In the previous code, routing this dust payment would cause nodes[0] to perceive a channel
        // reserve violation even though it's a dust HTLC and therefore shouldn't count towards the
        // commitment transaction fee.
-       let (_, _) = route_payment(&nodes[1], &[&nodes[0]], dust_amt);
+       let (_, _, _) = route_payment(&nodes[1], &[&nodes[0]], dust_amt);
 }
 
 #[test]
@@ -1781,22 +1781,22 @@ fn test_chan_reserve_dust_inbound_htlcs_inbound_chan() {
 
        let payment_amt = 46000; // Dust amount
        // In the previous code, these first four payments would succeed.
-       let (_, _) = route_payment(&nodes[0], &[&nodes[1]], payment_amt);
-       let (_, _) = route_payment(&nodes[0], &[&nodes[1]], payment_amt);
-       let (_, _) = route_payment(&nodes[0], &[&nodes[1]], payment_amt);
-       let (_, _) = route_payment(&nodes[0], &[&nodes[1]], payment_amt);
+       let (_, _, _) = route_payment(&nodes[0], &[&nodes[1]], payment_amt);
+       let (_, _, _) = route_payment(&nodes[0], &[&nodes[1]], payment_amt);
+       let (_, _, _) = route_payment(&nodes[0], &[&nodes[1]], payment_amt);
+       let (_, _, _) = route_payment(&nodes[0], &[&nodes[1]], payment_amt);
 
        // Then these next 5 would be interpreted by nodes[1] as violating the fee spike buffer.
-       let (_, _) = route_payment(&nodes[0], &[&nodes[1]], payment_amt);
-       let (_, _) = route_payment(&nodes[0], &[&nodes[1]], payment_amt);
-       let (_, _) = route_payment(&nodes[0], &[&nodes[1]], payment_amt);
-       let (_, _) = route_payment(&nodes[0], &[&nodes[1]], payment_amt);
-       let (_, _) = route_payment(&nodes[0], &[&nodes[1]], payment_amt);
+       let (_, _, _) = route_payment(&nodes[0], &[&nodes[1]], payment_amt);
+       let (_, _, _) = route_payment(&nodes[0], &[&nodes[1]], payment_amt);
+       let (_, _, _) = route_payment(&nodes[0], &[&nodes[1]], payment_amt);
+       let (_, _, _) = route_payment(&nodes[0], &[&nodes[1]], payment_amt);
+       let (_, _, _) = route_payment(&nodes[0], &[&nodes[1]], payment_amt);
 
        // And this last payment previously resulted in nodes[1] closing on its inbound-channel
        // counterparty, because it counted all the previous dust HTLCs against nodes[0]'s commitment
        // transaction fee and therefore perceived this next payment as a channel reserve violation.
-       let (_, _) = route_payment(&nodes[0], &[&nodes[1]], payment_amt);
+       let (_, _, _) = route_payment(&nodes[0], &[&nodes[1]], payment_amt);
 }
 
 #[test]
@@ -1819,7 +1819,7 @@ fn test_chan_reserve_violation_inbound_htlc_inbound_chan() {
        let amt_msat_1 = recv_value_1 + total_routing_fee_msat;
 
        // Add a pending HTLC.
-       let (route_1, our_payment_hash_1, _) = get_route_and_payment_hash!(nodes[0], nodes[2], amt_msat_1);
+       let (route_1, our_payment_hash_1, _, our_payment_secret_1) = get_route_and_payment_hash!(nodes[0], nodes[2], amt_msat_1);
        let payment_event_1 = {
                nodes[0].node.send_payment(&route_1, our_payment_hash_1, &None).unwrap();
                check_added_monitors!(nodes[0], 1);
@@ -1834,7 +1834,7 @@ fn test_chan_reserve_violation_inbound_htlc_inbound_chan() {
        let commit_tx_fee_2_htlcs = commit_tx_fee_msat(feerate, 2);
        let recv_value_2 = chan_stat.value_to_self_msat - amt_msat_1 - chan_stat.channel_reserve_msat - total_routing_fee_msat - commit_tx_fee_2_htlcs + 1;
        let amt_msat_2 = recv_value_2 + total_routing_fee_msat;
-       let (route_2, _, _) = get_route_and_payment_hash!(nodes[0], nodes[2], amt_msat_2);
+       let (route_2, _, _, _) = get_route_and_payment_hash!(nodes[0], nodes[2], amt_msat_2);
 
        // Need to manually create the update_add_htlc message to go around the channel reserve check in send_htlc()
        let secp_ctx = Secp256k1::new();
@@ -1917,7 +1917,7 @@ fn test_channel_reserve_holding_cell_htlcs() {
 
        // attempt to send amt_msat > their_max_htlc_value_in_flight_msat
        {
-               let (mut route, our_payment_hash, _) = get_route_and_payment_hash!(nodes[0], nodes[2], recv_value_0);
+               let (mut route, our_payment_hash, _, our_payment_secret) = get_route_and_payment_hash!(nodes[0], nodes[2], recv_value_0);
                route.paths[0].last_mut().unwrap().fee_msat += 1;
                assert!(route.paths[0].iter().rev().skip(1).all(|h| h.fee_msat == feemsat));
                unwrap_send_err!(nodes[0].node.send_payment(&route, our_payment_hash, &None), true, APIError::ChannelUnavailable { ref err },
@@ -1969,7 +1969,7 @@ fn test_channel_reserve_holding_cell_htlcs() {
        let recv_value_1 = (stat01.value_to_self_msat - stat01.channel_reserve_msat - total_fee_msat - commit_tx_fee_2_htlcs)/2;
        let amt_msat_1 = recv_value_1 + total_fee_msat;
 
-       let (route_1, our_payment_hash_1, our_payment_preimage_1) = get_route_and_payment_hash!(nodes[0], nodes[2], recv_value_1);
+       let (route_1, our_payment_hash_1, our_payment_preimage_1, our_payment_secret_1) = get_route_and_payment_hash!(nodes[0], nodes[2], recv_value_1);
        let payment_event_1 = {
                nodes[0].node.send_payment(&route_1, our_payment_hash_1, &None).unwrap();
                check_added_monitors!(nodes[0], 1);
@@ -1983,7 +1983,7 @@ fn test_channel_reserve_holding_cell_htlcs() {
        // channel reserve test with htlc pending output > 0
        let recv_value_2 = stat01.value_to_self_msat - amt_msat_1 - stat01.channel_reserve_msat - total_fee_msat - commit_tx_fee_2_htlcs;
        {
-               let (route, our_payment_hash, _) = get_route_and_payment_hash!(nodes[0], nodes[2], recv_value_2 + 1);
+               let (route, our_payment_hash, _, our_payment_secret) = get_route_and_payment_hash!(nodes[0], nodes[2], recv_value_2 + 1);
                unwrap_send_err!(nodes[0].node.send_payment(&route, our_payment_hash, &None), true, APIError::ChannelUnavailable { ref err },
                        assert!(regex::Regex::new(r"Cannot send value that would put our balance under counterparty-announced channel reserve value \(\d+\)").unwrap().is_match(err)));
                assert!(nodes[0].node.get_and_clear_pending_msg_events().is_empty());
@@ -2000,7 +2000,7 @@ fn test_channel_reserve_holding_cell_htlcs() {
        }
 
        // now see if they go through on both sides
-       let (route_21, our_payment_hash_21, our_payment_preimage_21) = get_route_and_payment_hash!(nodes[0], nodes[2], recv_value_21);
+       let (route_21, our_payment_hash_21, our_payment_preimage_21, our_payment_secret_21) = get_route_and_payment_hash!(nodes[0], nodes[2], recv_value_21);
        // but this will stuck in the holding cell
        nodes[0].node.send_payment(&route_21, our_payment_hash_21, &None).unwrap();
        check_added_monitors!(nodes[0], 0);
@@ -2009,14 +2009,14 @@ fn test_channel_reserve_holding_cell_htlcs() {
 
        // test with outbound holding cell amount > 0
        {
-               let (route, our_payment_hash, _) = get_route_and_payment_hash!(nodes[0], nodes[2], recv_value_22+1);
+               let (route, our_payment_hash, _, our_payment_secret) = get_route_and_payment_hash!(nodes[0], nodes[2], recv_value_22+1);
                unwrap_send_err!(nodes[0].node.send_payment(&route, our_payment_hash, &None), true, APIError::ChannelUnavailable { ref err },
                        assert!(regex::Regex::new(r"Cannot send value that would put our balance under counterparty-announced channel reserve value \(\d+\)").unwrap().is_match(err)));
                assert!(nodes[0].node.get_and_clear_pending_msg_events().is_empty());
                nodes[0].logger.assert_log_contains("lightning::ln::channelmanager".to_string(), "Cannot send value that would put our balance under counterparty-announced channel reserve value".to_string(), 2);
        }
 
-       let (route_22, our_payment_hash_22, our_payment_preimage_22) = get_route_and_payment_hash!(nodes[0], nodes[2], recv_value_22);
+       let (route_22, our_payment_hash_22, our_payment_preimage_22, our_payment_secret_22) = get_route_and_payment_hash!(nodes[0], nodes[2], recv_value_22);
        // this will also stuck in the holding cell
        nodes[0].node.send_payment(&route_22, our_payment_hash_22, &None).unwrap();
        check_added_monitors!(nodes[0], 0);
@@ -2136,11 +2136,11 @@ fn channel_reserve_in_flight_removes() {
 
        let b_chan_values = get_channel_value_stat!(nodes[1], chan_1.2);
        // Route the first two HTLCs.
-       let (payment_preimage_1, _) = route_payment(&nodes[0], &[&nodes[1]], b_chan_values.channel_reserve_msat - b_chan_values.value_to_self_msat - 10000);
-       let (payment_preimage_2, _) = route_payment(&nodes[0], &[&nodes[1]], 20000);
+       let (payment_preimage_1, _, _) = route_payment(&nodes[0], &[&nodes[1]], b_chan_values.channel_reserve_msat - b_chan_values.value_to_self_msat - 10000);
+       let (payment_preimage_2, _, _) = route_payment(&nodes[0], &[&nodes[1]], 20000);
 
        // Start routing the third HTLC (this is just used to get everyone in the right state).
-       let (payment_preimage_3, payment_hash_3) = get_payment_preimage_hash!(nodes[0]);
+       let (payment_preimage_3, payment_hash_3, payment_secret_3) = get_payment_preimage_hash!(nodes[1]);
        let send_1 = {
                let net_graph_msg_handler = &nodes[0].net_graph_msg_handler;
                let route = get_route(&nodes[0].node.get_our_node_id(), &net_graph_msg_handler.network_graph.read().unwrap(), &nodes[1].node.get_our_node_id(), None, None, &[], 100000, TEST_FINAL_CLTV, &logger).unwrap();
@@ -2213,7 +2213,7 @@ fn channel_reserve_in_flight_removes() {
 
        // Now that B doesn't have the second RAA anymore, but A still does, send a payment from B back
        // to A to ensure that A doesn't count the almost-removed HTLC in update_add processing.
-       let (payment_preimage_4, payment_hash_4) = get_payment_preimage_hash!(nodes[1]);
+       let (payment_preimage_4, payment_hash_4, payment_secret_4) = get_payment_preimage_hash!(nodes[0]);
        let send_2 = {
                let net_graph_msg_handler = &nodes[1].net_graph_msg_handler;
                let route = get_route(&nodes[1].node.get_our_node_id(), &net_graph_msg_handler.network_graph.read().unwrap(), &nodes[0].node.get_our_node_id(), None, None, &[], 10000, TEST_FINAL_CLTV, &logger).unwrap();
@@ -2580,7 +2580,7 @@ fn claim_htlc_outputs_shared_tx() {
        send_payment(&nodes[0], &vec!(&nodes[1])[..], 8000000, 8_000_000);
        // node[0] is gonna to revoke an old state thus node[1] should be able to claim both offered/received HTLC outputs on top of commitment tx
        let payment_preimage_1 = route_payment(&nodes[0], &vec!(&nodes[1])[..], 3000000).0;
-       let (_payment_preimage_2, payment_hash_2) = route_payment(&nodes[1], &vec!(&nodes[0])[..], 3000000);
+       let (_payment_preimage_2, payment_hash_2, _) = route_payment(&nodes[1], &vec!(&nodes[0])[..], 3000000);
 
        // Get the will-be-revoked local txn from node[0]
        let revoked_local_txn = get_local_commitment_txn!(nodes[0], chan_1.2);
@@ -2650,7 +2650,7 @@ fn claim_htlc_outputs_single_tx() {
        // node[0] is gonna to revoke an old state thus node[1] should be able to claim both offered/received HTLC outputs on top of commitment tx, but this
        // time as two different claim transactions as we're gonna to timeout htlc with given a high current height
        let payment_preimage_1 = route_payment(&nodes[0], &vec!(&nodes[1])[..], 3000000).0;
-       let (_payment_preimage_2, payment_hash_2) = route_payment(&nodes[1], &vec!(&nodes[0])[..], 3000000);
+       let (_payment_preimage_2, payment_hash_2, _payment_secret_2) = route_payment(&nodes[1], &vec!(&nodes[0])[..], 3000000);
 
        // Get the will-be-revoked local txn from node[0]
        let revoked_local_txn = get_local_commitment_txn!(nodes[0], chan_1.2);
@@ -2735,8 +2735,8 @@ fn test_htlc_on_chain_success() {
        send_payment(&nodes[0], &vec!(&nodes[1], &nodes[2])[..], 8000000, 8_000_000);
        send_payment(&nodes[0], &vec!(&nodes[1], &nodes[2])[..], 8000000, 8_000_000);
 
-       let (our_payment_preimage, _payment_hash) = route_payment(&nodes[0], &vec!(&nodes[1], &nodes[2]), 3000000);
-       let (our_payment_preimage_2, _payment_hash_2) = route_payment(&nodes[0], &vec!(&nodes[1], &nodes[2]), 3000000);
+       let (our_payment_preimage, _payment_hash, _payment_secret) = route_payment(&nodes[0], &vec!(&nodes[1], &nodes[2]), 3000000);
+       let (our_payment_preimage_2, _payment_hash_2, _payment_secret_2) = route_payment(&nodes[0], &vec!(&nodes[1], &nodes[2]), 3000000);
 
        // Broadcast legit commitment tx from C on B's chain
        // Broadcast HTLC Success transaction by C on received output from C's commitment tx on B's chain
@@ -2916,7 +2916,7 @@ fn do_test_htlc_on_chain_timeout(connect_style: ConnectStyle) {
        send_payment(&nodes[0], &vec!(&nodes[1], &nodes[2])[..], 8000000, 8_000_000);
        send_payment(&nodes[0], &vec!(&nodes[1], &nodes[2])[..], 8000000, 8_000_000);
 
-       let (_payment_preimage, payment_hash) = route_payment(&nodes[0], &vec!(&nodes[1], &nodes[2]), 3000000);
+       let (_payment_preimage, payment_hash, _payment_secret) = route_payment(&nodes[0], &vec!(&nodes[1], &nodes[2]), 3000000);
 
        // Broadcast legit commitment tx from C on B's chain
        let commitment_tx = get_local_commitment_txn!(nodes[2], chan_2.2);
@@ -3041,13 +3041,13 @@ fn test_simple_commitment_revoked_fail_backward() {
        create_announced_chan_between_nodes(&nodes, 0, 1, InitFeatures::known(), InitFeatures::known());
        let chan_2 = create_announced_chan_between_nodes(&nodes, 1, 2, InitFeatures::known(), InitFeatures::known());
 
-       let (payment_preimage, _payment_hash) = route_payment(&nodes[0], &[&nodes[1], &nodes[2]], 3000000);
+       let (payment_preimage, _payment_hash, _payment_secret) = route_payment(&nodes[0], &[&nodes[1], &nodes[2]], 3000000);
        // Get the will-be-revoked local txn from nodes[2]
        let revoked_local_txn = get_local_commitment_txn!(nodes[2], chan_2.2);
        // Revoke the old state
        claim_payment(&nodes[0], &[&nodes[1], &nodes[2]], payment_preimage, 3_000_000);
 
-       let (_, payment_hash) = route_payment(&nodes[0], &[&nodes[1], &nodes[2]], 3000000);
+       let (_, payment_hash, _) = route_payment(&nodes[0], &[&nodes[1], &nodes[2]], 3000000);
 
        mine_transaction(&nodes[1], &revoked_local_txn[0]);
        connect_blocks(&nodes[1], ANTI_REORG_DELAY - 1);
@@ -3106,7 +3106,7 @@ fn do_test_commitment_revoked_fail_backward_exhaustive(deliver_bs_raa: bool, use
        create_announced_chan_between_nodes(&nodes, 0, 1, InitFeatures::known(), InitFeatures::known());
        let chan_2 = create_announced_chan_between_nodes(&nodes, 1, 2, InitFeatures::known(), InitFeatures::known());
 
-       let (payment_preimage, _payment_hash) = route_payment(&nodes[0], &[&nodes[1], &nodes[2]], if no_to_remote { 10_000 } else { 3_000_000 });
+       let (payment_preimage, _payment_hash, _payment_secret) = route_payment(&nodes[0], &[&nodes[1], &nodes[2]], if no_to_remote { 10_000 } else { 3_000_000 });
        // Get the will-be-revoked local txn from nodes[2]
        let revoked_local_txn = get_local_commitment_txn!(nodes[2], chan_2.2);
        assert_eq!(revoked_local_txn[0].output.len(), if no_to_remote { 1 } else { 2 });
@@ -3119,9 +3119,9 @@ fn do_test_commitment_revoked_fail_backward_exhaustive(deliver_bs_raa: bool, use
                nodes[2].node.channel_state.lock().unwrap().by_id.get(&chan_2.2).unwrap().holder_dust_limit_satoshis * 1000
        } else { 3000000 };
 
-       let (_, first_payment_hash) = route_payment(&nodes[0], &[&nodes[1], &nodes[2]], value);
-       let (_, second_payment_hash) = route_payment(&nodes[0], &[&nodes[1], &nodes[2]], value);
-       let (_, third_payment_hash) = route_payment(&nodes[0], &[&nodes[1], &nodes[2]], value);
+       let (_, first_payment_hash, _) = route_payment(&nodes[0], &[&nodes[1], &nodes[2]], value);
+       let (_, second_payment_hash, _) = route_payment(&nodes[0], &[&nodes[1], &nodes[2]], value);
+       let (_, third_payment_hash, _) = route_payment(&nodes[0], &[&nodes[1], &nodes[2]], value);
 
        assert!(nodes[2].node.fail_htlc_backwards(&first_payment_hash, &None));
        expect_pending_htlcs_forwardable!(nodes[2]);
@@ -3174,7 +3174,7 @@ fn do_test_commitment_revoked_fail_backward_exhaustive(deliver_bs_raa: bool, use
 
        // Add a fourth HTLC, this one will get sequestered away in nodes[1]'s holding cell waiting
        // on nodes[2]'s RAA.
-       let (_, fourth_payment_hash) = get_payment_preimage_hash!(nodes[0]);
+       let (_, fourth_payment_hash, fourth_payment_secret) = get_payment_preimage_hash!(nodes[2]);
        let net_graph_msg_handler = &nodes[1].net_graph_msg_handler;
        let logger = test_utils::TestLogger::new();
        let route = get_route(&nodes[1].node.get_our_node_id(), &net_graph_msg_handler.network_graph.read().unwrap(), &nodes[2].node.get_our_node_id(), None, None, &Vec::new(), 1000000, TEST_FINAL_CLTV, &logger).unwrap();
@@ -3327,7 +3327,7 @@ fn fail_backward_pending_htlc_upon_channel_failure() {
 
        // Alice -> Bob: Route a payment but without Bob sending revoke_and_ack.
        {
-               let (_, payment_hash) = get_payment_preimage_hash!(nodes[0]);
+               let (_, payment_hash, payment_secret) = get_payment_preimage_hash!(nodes[1]);
                let net_graph_msg_handler = &nodes[0].net_graph_msg_handler;
                let route = get_route(&nodes[0].node.get_our_node_id(), &net_graph_msg_handler.network_graph.read().unwrap(), &nodes[1].node.get_our_node_id(), None, None, &Vec::new(), 50_000, TEST_FINAL_CLTV, &logger).unwrap();
                nodes[0].node.send_payment(&route, payment_hash, &None).unwrap();
@@ -3343,7 +3343,7 @@ fn fail_backward_pending_htlc_upon_channel_failure() {
        }
 
        // Alice -> Bob: Route another payment but now Alice waits for Bob's earlier revoke_and_ack.
-       let (_, failed_payment_hash) = get_payment_preimage_hash!(nodes[0]);
+       let (_, failed_payment_hash, failed_payment_secret) = get_payment_preimage_hash!(nodes[1]);
        {
                let net_graph_msg_handler = &nodes[0].net_graph_msg_handler;
                let route = get_route(&nodes[0].node.get_our_node_id(), &net_graph_msg_handler.network_graph.read().unwrap(), &nodes[1].node.get_our_node_id(), None, None, &Vec::new(), 50_000, TEST_FINAL_CLTV, &logger).unwrap();
@@ -3355,7 +3355,7 @@ fn fail_backward_pending_htlc_upon_channel_failure() {
 
        // Alice <- Bob: Send a malformed update_add_htlc so Alice fails the channel.
        {
-               let (_, payment_hash) = get_payment_preimage_hash!(nodes[1]);
+               let (_, payment_hash, payment_secret) = get_payment_preimage_hash!(nodes[0]);
 
                let secp_ctx = Secp256k1::new();
                let session_priv = SecretKey::from_slice(&[42; 32]).unwrap();
@@ -3424,7 +3424,7 @@ fn test_force_close_fail_back() {
        create_announced_chan_between_nodes(&nodes, 1, 2, InitFeatures::known(), InitFeatures::known());
        let logger = test_utils::TestLogger::new();
 
-       let (our_payment_preimage, our_payment_hash) = get_payment_preimage_hash!(nodes[0]);
+       let (our_payment_preimage, our_payment_hash, our_payment_secret) = get_payment_preimage_hash!(nodes[2]);
 
        let mut payment_event = {
                let net_graph_msg_handler = &nodes[0].net_graph_msg_handler;
@@ -3562,7 +3562,7 @@ fn do_test_drop_messages_peer_disconnect(messages_delivered: u8) {
                create_announced_chan_between_nodes(&nodes, 0, 1, InitFeatures::known(), InitFeatures::known());
        }
 
-       let (payment_preimage_1, payment_hash_1) = get_payment_preimage_hash!(nodes[0]);
+       let (payment_preimage_1, payment_hash_1, payment_secret_1) = get_payment_preimage_hash!(nodes[1]);
 
        let logger = test_utils::TestLogger::new();
        let payment_event = {
@@ -3848,7 +3848,7 @@ fn test_funding_peer_disconnect() {
        let net_graph_msg_handler = &nodes[0].net_graph_msg_handler;
        let logger = test_utils::TestLogger::new();
        let route = get_route(&nodes[0].node.get_our_node_id(), &net_graph_msg_handler.network_graph.read().unwrap(), &nodes[1].node.get_our_node_id(), None, None, &Vec::new(), 1000000, TEST_FINAL_CLTV, &logger).unwrap();
-       let (payment_preimage, _) = send_along_route(&nodes[0], route, &[&nodes[1]], 1000000);
+       let (payment_preimage, _, _) = send_along_route(&nodes[0], route, &[&nodes[1]], 1000000);
        claim_payment(&nodes[0], &[&nodes[1]], payment_preimage, 1_000_000);
 }
 
@@ -3863,10 +3863,10 @@ fn test_drop_messages_peer_disconnect_dual_htlc() {
        create_announced_chan_between_nodes(&nodes, 0, 1, InitFeatures::known(), InitFeatures::known());
        let logger = test_utils::TestLogger::new();
 
-       let (payment_preimage_1, _) = route_payment(&nodes[0], &[&nodes[1]], 1000000);
+       let (payment_preimage_1, _, _) = route_payment(&nodes[0], &[&nodes[1]], 1000000);
 
        // Now try to send a second payment which will fail to send
-       let (payment_preimage_2, payment_hash_2) = get_payment_preimage_hash!(nodes[0]);
+       let (payment_preimage_2, payment_hash_2, payment_secret_2) = get_payment_preimage_hash!(nodes[1]);
        let net_graph_msg_handler = &nodes[0].net_graph_msg_handler;
        let route = get_route(&nodes[0].node.get_our_node_id(), &net_graph_msg_handler.network_graph.read().unwrap(), &nodes[1].node.get_our_node_id(), None, None, &Vec::new(), 1000000, TEST_FINAL_CLTV, &logger).unwrap();
        nodes[0].node.send_payment(&route, payment_hash_2, &None).unwrap();
@@ -4010,8 +4010,7 @@ fn do_test_htlc_timeout(send_partial_mpp: bool) {
        let our_payment_hash = if send_partial_mpp {
                let net_graph_msg_handler = &nodes[0].net_graph_msg_handler;
                let route = get_route(&nodes[0].node.get_our_node_id(), &net_graph_msg_handler.network_graph.read().unwrap(), &nodes[1].node.get_our_node_id(), None, None, &Vec::new(), 100000, TEST_FINAL_CLTV, &logger).unwrap();
-               let (_, our_payment_hash) = get_payment_preimage_hash!(&nodes[0]);
-               let payment_secret = PaymentSecret([0xdb; 32]);
+               let (_, our_payment_hash, payment_secret) = get_payment_preimage_hash!(&nodes[1]);
                // Use the utility function send_payment_along_path to send the payment with MPP data which
                // indicates there are more HTLCs coming.
                let cur_height = CHAN_CONFIRM_DEPTH + 1; // route_payment calls send_payment, which adds 1 to the current height. So we do the same here to match.
@@ -4079,7 +4078,7 @@ fn do_test_holding_cell_htlc_add_timeouts(forwarded_htlc: bool) {
        let logger = test_utils::TestLogger::new();
 
        // Route a first payment to get the 1 -> 2 channel in awaiting_raa...
-       let (_, first_payment_hash) = get_payment_preimage_hash!(nodes[0]);
+       let (_, first_payment_hash, first_payment_secret) = get_payment_preimage_hash!(nodes[2]);
        {
                let net_graph_msg_handler = &nodes[1].net_graph_msg_handler;
                let route = get_route(&nodes[1].node.get_our_node_id(), &net_graph_msg_handler.network_graph.read().unwrap(), &nodes[2].node.get_our_node_id(), None, None, &Vec::new(), 100000, TEST_FINAL_CLTV, &logger).unwrap();
@@ -4089,7 +4088,7 @@ fn do_test_holding_cell_htlc_add_timeouts(forwarded_htlc: bool) {
        check_added_monitors!(nodes[1], 1);
 
        // Now attempt to route a second payment, which should be placed in the holding cell
-       let (_, second_payment_hash) = get_payment_preimage_hash!(nodes[0]);
+       let (_, second_payment_hash, second_payment_secret) = get_payment_preimage_hash!(nodes[2]);
        if forwarded_htlc {
                let net_graph_msg_handler = &nodes[0].net_graph_msg_handler;
                let route = get_route(&nodes[0].node.get_our_node_id(), &net_graph_msg_handler.network_graph.read().unwrap(), &nodes[2].node.get_our_node_id(), None, None, &Vec::new(), 100000, TEST_FINAL_CLTV, &logger).unwrap();
@@ -4428,8 +4427,8 @@ fn test_simple_manager_serialize_deserialize() {
        let mut nodes = create_network(2, &node_cfgs, &node_chanmgrs);
        create_announced_chan_between_nodes(&nodes, 0, 1, InitFeatures::known(), InitFeatures::known());
 
-       let (our_payment_preimage, _) = route_payment(&nodes[0], &[&nodes[1]], 1000000);
-       let (_, our_payment_hash) = route_payment(&nodes[0], &[&nodes[1]], 1000000);
+       let (our_payment_preimage, _, _) = route_payment(&nodes[0], &[&nodes[1]], 1000000);
+       let (_, our_payment_hash, _) = route_payment(&nodes[0], &[&nodes[1]], 1000000);
 
        nodes[1].node.peer_disconnected(&nodes[0].node.get_our_node_id(), false);
 
@@ -4498,7 +4497,7 @@ fn test_manager_serialize_deserialize_inconsistent_monitor() {
                node_0_stale_monitors_serialized.push(writer.0);
        }
 
-       let (our_payment_preimage, _) = route_payment(&nodes[2], &[&nodes[0], &nodes[1]], 1000000);
+       let (our_payment_preimage, _, _) = route_payment(&nodes[2], &[&nodes[0], &nodes[1]], 1000000);
 
        // Serialize the ChannelManager here, but the monitor we keep up-to-date
        let nodes_0_serialized = nodes[0].node.encode();
@@ -4778,7 +4777,7 @@ fn test_static_spendable_outputs_timeout_tx() {
        // Rebalance the network a bit by relaying one payment through all the channels ...
        send_payment(&nodes[0], &vec!(&nodes[1])[..], 8000000, 8_000_000);
 
-       let (_, our_payment_hash) = route_payment(&nodes[1], &vec!(&nodes[0])[..], 3_000_000);
+       let (_, our_payment_hash, _) = route_payment(&nodes[1], &vec!(&nodes[0])[..], 3_000_000);
 
        let commitment_tx = get_local_commitment_txn!(nodes[0], chan_1.2);
        assert_eq!(commitment_tx[0].input.len(), 1);
@@ -5013,7 +5012,7 @@ fn test_onchain_to_onchain_claim() {
        send_payment(&nodes[0], &vec!(&nodes[1], &nodes[2])[..], 8000000, 8_000_000);
        send_payment(&nodes[0], &vec!(&nodes[1], &nodes[2])[..], 8000000, 8_000_000);
 
-       let (payment_preimage, _payment_hash) = route_payment(&nodes[0], &vec!(&nodes[1], &nodes[2]), 3000000);
+       let (payment_preimage, _payment_hash, _payment_secret) = route_payment(&nodes[0], &vec!(&nodes[1], &nodes[2]), 3000000);
        let commitment_tx = get_local_commitment_txn!(nodes[2], chan_2.2);
        check_spends!(commitment_tx[0], chan_2.3);
        nodes[2].node.claim_funds(payment_preimage, &None, 3_000_000);
@@ -5108,9 +5107,11 @@ fn test_duplicate_payment_hash_one_failure_one_success() {
        create_announced_chan_between_nodes(&nodes, 0, 1, InitFeatures::known(), InitFeatures::known());
        let chan_2 = create_announced_chan_between_nodes(&nodes, 1, 2, InitFeatures::known(), InitFeatures::known());
 
-       let (our_payment_preimage, duplicate_payment_hash) = route_payment(&nodes[0], &vec!(&nodes[1], &nodes[2])[..], 900000);
-       *nodes[0].network_payment_count.borrow_mut() -= 1;
-       assert_eq!(route_payment(&nodes[0], &vec!(&nodes[1], &nodes[2])[..], 900000).1, duplicate_payment_hash);
+       let (our_payment_preimage, duplicate_payment_hash, _) = route_payment(&nodes[0], &vec!(&nodes[1], &nodes[2])[..], 900000);
+
+       let route = get_route(&nodes[0].node.get_our_node_id(), &nodes[0].net_graph_msg_handler.network_graph.read().unwrap(),
+               &nodes[2].node.get_our_node_id(), None, None, &Vec::new(), 900000, TEST_FINAL_CLTV, nodes[0].logger).unwrap();
+       send_along_route_with_hash(&nodes[0], route, &[&nodes[1], &nodes[2]], 900000, duplicate_payment_hash);
 
        let commitment_txn = get_local_commitment_txn!(nodes[2], chan_2.2);
        assert_eq!(commitment_txn[0].input.len(), 1);
@@ -5294,9 +5295,9 @@ fn do_test_fail_backwards_unrevoked_remote_announce(deliver_last_raa: bool, anno
 
        let ds_dust_limit = nodes[3].node.channel_state.lock().unwrap().by_id.get(&chan.2).unwrap().holder_dust_limit_satoshis;
        // 0th HTLC:
-       let (_, payment_hash_1) = route_payment(&nodes[0], &[&nodes[2], &nodes[3], &nodes[4]], ds_dust_limit*1000); // not added < dust limit + HTLC tx fee
+       let (_, payment_hash_1, _) = route_payment(&nodes[0], &[&nodes[2], &nodes[3], &nodes[4]], ds_dust_limit*1000); // not added < dust limit + HTLC tx fee
        // 1st HTLC:
-       let (_, payment_hash_2) = route_payment(&nodes[0], &[&nodes[2], &nodes[3], &nodes[4]], ds_dust_limit*1000); // not added < dust limit + HTLC tx fee
+       let (_, payment_hash_2, payment_secret_2) = route_payment(&nodes[0], &[&nodes[2], &nodes[3], &nodes[4]], ds_dust_limit*1000); // not added < dust limit + HTLC tx fee
        let net_graph_msg_handler = &nodes[1].net_graph_msg_handler;
        let our_node_id = &nodes[1].node.get_our_node_id();
        let route = get_route(our_node_id, &net_graph_msg_handler.network_graph.read().unwrap(), &nodes[5].node.get_our_node_id(), None, None, &Vec::new(), ds_dust_limit*1000, TEST_FINAL_CLTV, &logger).unwrap();
@@ -5305,9 +5306,9 @@ fn do_test_fail_backwards_unrevoked_remote_announce(deliver_last_raa: bool, anno
        // 3rd HTLC:
        send_along_route_with_hash(&nodes[1], route, &[&nodes[2], &nodes[3], &nodes[5]], ds_dust_limit*1000, payment_hash_2); // not added < dust limit + HTLC tx fee
        // 4th HTLC:
-       let (_, payment_hash_3) = route_payment(&nodes[0], &[&nodes[2], &nodes[3], &nodes[4]], 1000000);
+       let (_, payment_hash_3, _) = route_payment(&nodes[0], &[&nodes[2], &nodes[3], &nodes[4]], 1000000);
        // 5th HTLC:
-       let (_, payment_hash_4) = route_payment(&nodes[0], &[&nodes[2], &nodes[3], &nodes[4]], 1000000);
+       let (_, payment_hash_4, payment_secret_4) = route_payment(&nodes[0], &[&nodes[2], &nodes[3], &nodes[4]], 1000000);
        let route = get_route(our_node_id, &net_graph_msg_handler.network_graph.read().unwrap(), &nodes[5].node.get_our_node_id(), None, None, &Vec::new(), 1000000, TEST_FINAL_CLTV, &logger).unwrap();
        // 6th HTLC:
        send_along_route_with_hash(&nodes[1], route.clone(), &[&nodes[2], &nodes[3], &nodes[5]], 1000000, payment_hash_3);
@@ -5315,13 +5316,13 @@ fn do_test_fail_backwards_unrevoked_remote_announce(deliver_last_raa: bool, anno
        send_along_route_with_hash(&nodes[1], route, &[&nodes[2], &nodes[3], &nodes[5]], 1000000, payment_hash_4);
 
        // 8th HTLC:
-       let (_, payment_hash_5) = route_payment(&nodes[0], &[&nodes[2], &nodes[3], &nodes[4]], 1000000);
+       let (_, payment_hash_5, _) = route_payment(&nodes[0], &[&nodes[2], &nodes[3], &nodes[4]], 1000000);
        // 9th HTLC:
        let route = get_route(our_node_id, &net_graph_msg_handler.network_graph.read().unwrap(), &nodes[5].node.get_our_node_id(), None, None, &Vec::new(), ds_dust_limit*1000, TEST_FINAL_CLTV, &logger).unwrap();
        send_along_route_with_hash(&nodes[1], route, &[&nodes[2], &nodes[3], &nodes[5]], ds_dust_limit*1000, payment_hash_5); // not added < dust limit + HTLC tx fee
 
        // 10th HTLC:
-       let (_, payment_hash_6) = route_payment(&nodes[0], &[&nodes[2], &nodes[3], &nodes[4]], ds_dust_limit*1000); // not added < dust limit + HTLC tx fee
+       let (_, payment_hash_6, _) = route_payment(&nodes[0], &[&nodes[2], &nodes[3], &nodes[4]], ds_dust_limit*1000); // not added < dust limit + HTLC tx fee
        // 11th HTLC:
        let route = get_route(our_node_id, &net_graph_msg_handler.network_graph.read().unwrap(), &nodes[5].node.get_our_node_id(), None, None, &Vec::new(), 1000000, TEST_FINAL_CLTV, &logger).unwrap();
        send_along_route_with_hash(&nodes[1], route, &[&nodes[2], &nodes[3], &nodes[5]], 1000000, payment_hash_6);
@@ -5527,7 +5528,7 @@ fn test_dynamic_spendable_outputs_local_htlc_timeout_tx() {
        // Create some initial channels
        let chan_1 = create_announced_chan_between_nodes(&nodes, 0, 1, InitFeatures::known(), InitFeatures::known());
 
-       let (_, our_payment_hash) = route_payment(&nodes[0], &vec!(&nodes[1])[..], 9000000);
+       let (_, our_payment_hash, _) = route_payment(&nodes[0], &vec!(&nodes[1])[..], 9000000);
        let local_txn = get_local_commitment_txn!(nodes[0], chan_1.2);
        assert_eq!(local_txn[0].input.len(), 1);
        check_spends!(local_txn[0], chan_1.3);
@@ -5584,7 +5585,7 @@ fn test_key_derivation_params() {
        let chan_1 = create_announced_chan_between_nodes(&nodes, 0, 1, InitFeatures::known(), InitFeatures::known());
        assert_ne!(chan_0.3.output[0].script_pubkey, chan_1.3.output[0].script_pubkey);
 
-       let (_, our_payment_hash) = route_payment(&nodes[0], &vec!(&nodes[1])[..], 9000000);
+       let (_, our_payment_hash, _) = route_payment(&nodes[0], &vec!(&nodes[1])[..], 9000000);
        let local_txn_0 = get_local_commitment_txn!(nodes[0], chan_0.2);
        let local_txn_1 = get_local_commitment_txn!(nodes[0], chan_1.2);
        assert_eq!(local_txn_1[0].input.len(), 1);
@@ -5660,7 +5661,7 @@ fn do_htlc_claim_local_commitment_only(use_dust: bool) {
        let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
        let chan = create_announced_chan_between_nodes(&nodes, 0, 1, InitFeatures::known(), InitFeatures::known());
 
-       let (our_payment_preimage, _) = route_payment(&nodes[0], &[&nodes[1]], if use_dust { 50000 } else { 3000000 });
+       let (our_payment_preimage, _, _) = route_payment(&nodes[0], &[&nodes[1]], if use_dust { 50000 } else { 3000000 });
 
        // Claim the payment, but don't deliver A's commitment_signed, resulting in the HTLC only being
        // present in B's local commitment transaction, but none of A's commitment transactions.
@@ -5706,7 +5707,7 @@ fn do_htlc_claim_current_remote_commitment_only(use_dust: bool) {
        let chan = create_announced_chan_between_nodes(&nodes, 0, 1, InitFeatures::known(), InitFeatures::known());
        let logger = test_utils::TestLogger::new();
 
-       let (_, payment_hash) = get_payment_preimage_hash!(nodes[0]);
+       let (_, payment_hash, payment_secret) = get_payment_preimage_hash!(nodes[1]);
        let net_graph_msg_handler = &nodes[0].net_graph_msg_handler;
        let route = get_route(&nodes[0].node.get_our_node_id(), &net_graph_msg_handler.network_graph.read().unwrap(), &nodes[1].node.get_our_node_id(), None, None, &Vec::new(), if use_dust { 50000 } else { 3000000 }, TEST_FINAL_CLTV, &logger).unwrap();
        nodes[0].node.send_payment(&route, payment_hash, &None).unwrap();
@@ -5742,7 +5743,7 @@ fn do_htlc_claim_previous_remote_commitment_only(use_dust: bool, check_revoke_no
        // Also optionally test that we *don't* fail the channel in case the commitment transaction was
        // actually revoked.
        let htlc_value = if use_dust { 50000 } else { 3000000 };
-       let (_, our_payment_hash) = route_payment(&nodes[0], &[&nodes[1]], htlc_value);
+       let (_, our_payment_hash, _) = route_payment(&nodes[0], &[&nodes[1]], htlc_value);
        assert!(nodes[1].node.fail_htlc_backwards(&our_payment_hash, &None));
        expect_pending_htlcs_forwardable!(nodes[1]);
        check_added_monitors!(nodes[1], 1);
@@ -5911,7 +5912,7 @@ fn test_fail_holding_cell_htlc_upon_free() {
        let feerate = get_feerate!(nodes[0], chan.2);
 
        // 2* and +1 HTLCs on the commit tx fee calculation for the fee spike reserve.
-       let (_, our_payment_hash) = get_payment_preimage_hash!(nodes[0]);
+       let (_, our_payment_hash, our_payment_secret) = get_payment_preimage_hash!(nodes[1]);
        let max_can_send = 5000000 - channel_reserve - 2*commit_tx_fee_msat(feerate, 1 + 1);
        let net_graph_msg_handler = &nodes[0].net_graph_msg_handler;
        let route = get_route(&nodes[0].node.get_our_node_id(), &net_graph_msg_handler.network_graph.read().unwrap(), &nodes[1].node.get_our_node_id(), None, None, &[], max_can_send, TEST_FINAL_CLTV, &logger).unwrap();
@@ -5984,9 +5985,9 @@ fn test_free_and_fail_holding_cell_htlcs() {
        let feerate = get_feerate!(nodes[0], chan.2);
 
        // 2* and +1 HTLCs on the commit tx fee calculation for the fee spike reserve.
-       let (payment_preimage_1, payment_hash_1) = get_payment_preimage_hash!(nodes[0]);
+       let (payment_preimage_1, payment_hash_1, payment_secret_1) = get_payment_preimage_hash!(nodes[1]);
        let amt_1 = 20000;
-       let (_, payment_hash_2) = get_payment_preimage_hash!(nodes[0]);
+       let (_, payment_hash_2, payment_secret_2) = get_payment_preimage_hash!(nodes[1]);
        let amt_2 = 5000000 - channel_reserve - 2*commit_tx_fee_msat(feerate, 2 + 1) - amt_1;
        let net_graph_msg_handler = &nodes[0].net_graph_msg_handler;
        let route_1 = get_route(&nodes[0].node.get_our_node_id(), &net_graph_msg_handler.network_graph.read().unwrap(), &nodes[1].node.get_our_node_id(), None, None, &[], amt_1, TEST_FINAL_CLTV, &logger).unwrap();
@@ -6109,7 +6110,7 @@ fn test_fail_holding_cell_htlc_upon_free_multihop() {
        // Send a payment which passes reserve checks but gets stuck in the holding cell.
        let feemsat = 239;
        let total_routing_fee_msat = (nodes.len() - 2) as u64 * feemsat;
-       let (_, our_payment_hash) = get_payment_preimage_hash!(nodes[0]);
+       let (_, our_payment_hash, our_payment_secret) = get_payment_preimage_hash!(nodes[2]);
        let max_can_send = 5000000 - channel_reserve - 2*commit_tx_fee_msat(feerate, 1 + 1) - total_routing_fee_msat;
        let payment_event = {
                let net_graph_msg_handler = &nodes[0].net_graph_msg_handler;
@@ -6226,7 +6227,7 @@ fn test_update_add_htlc_bolt2_sender_value_below_minimum_msat() {
        let mut nodes = create_network(2, &node_cfgs, &node_chanmgrs);
        let _chan = create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 100000, 95000000, InitFeatures::known(), InitFeatures::known());
 
-       let (_, our_payment_hash) = get_payment_preimage_hash!(nodes[0]);
+       let (_, our_payment_hash, our_payment_secret) = get_payment_preimage_hash!(nodes[1]);
        let net_graph_msg_handler = &nodes[0].net_graph_msg_handler;
        let logger = test_utils::TestLogger::new();
        let mut route = get_route(&nodes[0].node.get_our_node_id(), &net_graph_msg_handler.network_graph.read().unwrap(), &nodes[1].node.get_our_node_id(), None, None, &[], 100000, TEST_FINAL_CLTV, &logger).unwrap();
@@ -6246,7 +6247,7 @@ fn test_update_add_htlc_bolt2_sender_zero_value_msat() {
        let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
        let mut nodes = create_network(2, &node_cfgs, &node_chanmgrs);
        let _chan = create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 100000, 95000000, InitFeatures::known(), InitFeatures::known());
-       let (_, our_payment_hash) = get_payment_preimage_hash!(nodes[0]);
+       let (_, our_payment_hash, our_payment_secret) = get_payment_preimage_hash!(nodes[1]);
 
        let net_graph_msg_handler = &nodes[0].net_graph_msg_handler;
        let logger = test_utils::TestLogger::new();
@@ -6268,7 +6269,7 @@ fn test_update_add_htlc_bolt2_receiver_zero_value_msat() {
        let mut nodes = create_network(2, &node_cfgs, &node_chanmgrs);
        let _chan = create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 100000, 95000000, InitFeatures::known(), InitFeatures::known());
 
-       let (_, our_payment_hash) = get_payment_preimage_hash!(nodes[0]);
+       let (_, our_payment_hash, our_payment_secret) = get_payment_preimage_hash!(nodes[1]);
        let net_graph_msg_handler = &nodes[0].net_graph_msg_handler;
        let logger = test_utils::TestLogger::new();
        let route = get_route(&nodes[0].node.get_our_node_id(), &net_graph_msg_handler.network_graph.read().unwrap(), &nodes[1].node.get_our_node_id(), None, None, &[], 100000, TEST_FINAL_CLTV, &logger).unwrap();
@@ -6294,7 +6295,7 @@ fn test_update_add_htlc_bolt2_sender_cltv_expiry_too_high() {
        let _chan = create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 1000000, 0, InitFeatures::known(), InitFeatures::known());
        let logger = test_utils::TestLogger::new();
 
-       let (_, our_payment_hash) = get_payment_preimage_hash!(nodes[0]);
+       let (_, our_payment_hash, our_payment_secret) = get_payment_preimage_hash!(nodes[1]);
 
        let net_graph_msg_handler = &nodes[0].net_graph_msg_handler;
        let route = get_route(&nodes[0].node.get_our_node_id(), &net_graph_msg_handler.network_graph.read().unwrap(), &nodes[1].node.get_our_node_id(), None, None, &[], 100000000, 500000001, &logger).unwrap();
@@ -6316,7 +6317,7 @@ fn test_update_add_htlc_bolt2_sender_exceed_max_htlc_num_and_htlc_id_increment()
 
        let logger = test_utils::TestLogger::new();
        for i in 0..max_accepted_htlcs {
-               let (_, our_payment_hash) = get_payment_preimage_hash!(nodes[0]);
+               let (_, our_payment_hash, our_payment_secret) = get_payment_preimage_hash!(nodes[1]);
                let payment_event = {
                        let net_graph_msg_handler = &nodes[0].net_graph_msg_handler;
                        let route = get_route(&nodes[0].node.get_our_node_id(), &net_graph_msg_handler.network_graph.read().unwrap(), &nodes[1].node.get_our_node_id(), None, None, &[], 100000, TEST_FINAL_CLTV, &logger).unwrap();
@@ -6339,7 +6340,7 @@ fn test_update_add_htlc_bolt2_sender_exceed_max_htlc_num_and_htlc_id_increment()
                expect_pending_htlcs_forwardable!(nodes[1]);
                expect_payment_received!(nodes[1], our_payment_hash, 100000);
        }
-       let (_, our_payment_hash) = get_payment_preimage_hash!(nodes[0]);
+       let (_, our_payment_hash, our_payment_secret) = get_payment_preimage_hash!(nodes[1]);
        let net_graph_msg_handler = &nodes[0].net_graph_msg_handler;
        let route = get_route(&nodes[0].node.get_our_node_id(), &net_graph_msg_handler.network_graph.read().unwrap(), &nodes[1].node.get_our_node_id(), None, None, &[], 100000, TEST_FINAL_CLTV, &logger).unwrap();
        unwrap_send_err!(nodes[0].node.send_payment(&route, our_payment_hash, &None), true, APIError::ChannelUnavailable { ref err },
@@ -6362,7 +6363,7 @@ fn test_update_add_htlc_bolt2_sender_exceed_max_htlc_value_in_flight() {
 
        send_payment(&nodes[0], &vec!(&nodes[1])[..], max_in_flight, max_in_flight);
 
-       let (_, our_payment_hash) = get_payment_preimage_hash!(nodes[0]);
+       let (_, our_payment_hash, our_payment_secret) = get_payment_preimage_hash!(nodes[1]);
        // Manually create a route over our max in flight (which our router normally automatically
        // limits us to.
        let route = Route { paths: vec![vec![RouteHop {
@@ -6395,7 +6396,7 @@ fn test_update_add_htlc_bolt2_receiver_check_amount_received_more_than_min() {
                htlc_minimum_msat = channel.get_holder_htlc_minimum_msat();
        }
 
-       let (_, our_payment_hash) = get_payment_preimage_hash!(nodes[0]);
+       let (_, our_payment_hash, our_payment_secret) = get_payment_preimage_hash!(nodes[1]);
        let net_graph_msg_handler = &nodes[0].net_graph_msg_handler;
        let logger = test_utils::TestLogger::new();
        let route = get_route(&nodes[0].node.get_our_node_id(), &net_graph_msg_handler.network_graph.read().unwrap(), &nodes[1].node.get_our_node_id(), None, None, &[], htlc_minimum_msat, TEST_FINAL_CLTV, &logger).unwrap();
@@ -6427,7 +6428,7 @@ fn test_update_add_htlc_bolt2_receiver_sender_can_afford_amount_sent() {
        let commit_tx_fee_outbound = 2 * commit_tx_fee_msat(feerate, 1 + 1);
 
        let max_can_send = 5000000 - channel_reserve - commit_tx_fee_outbound;
-       let (_, our_payment_hash) = get_payment_preimage_hash!(nodes[0]);
+       let (_, our_payment_hash, our_payment_secret) = get_payment_preimage_hash!(nodes[1]);
        let net_graph_msg_handler = &nodes[0].net_graph_msg_handler;
        let route = get_route(&nodes[0].node.get_our_node_id(), &net_graph_msg_handler.network_graph.read().unwrap(), &nodes[1].node.get_our_node_id(), None, None, &[], max_can_send, TEST_FINAL_CLTV, &logger).unwrap();
        nodes[0].node.send_payment(&route, our_payment_hash, &None).unwrap();
@@ -6457,7 +6458,7 @@ fn test_update_add_htlc_bolt2_receiver_check_max_htlc_limit() {
        let chan = create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 100000, 95000000, InitFeatures::known(), InitFeatures::known());
        let logger = test_utils::TestLogger::new();
 
-       let (_, our_payment_hash) = get_payment_preimage_hash!(nodes[0]);
+       let (_, our_payment_hash, our_payment_secret) = get_payment_preimage_hash!(nodes[1]);
        let session_priv = SecretKey::from_slice(&[42; 32]).unwrap();
 
        let net_graph_msg_handler = &nodes[0].net_graph_msg_handler;
@@ -6500,7 +6501,7 @@ fn test_update_add_htlc_bolt2_receiver_check_max_in_flight_msat() {
        let chan = create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 1000000, 1000000, InitFeatures::known(), InitFeatures::known());
        let logger = test_utils::TestLogger::new();
 
-       let (_, our_payment_hash) = get_payment_preimage_hash!(nodes[0]);
+       let (_, our_payment_hash, our_payment_secret) = get_payment_preimage_hash!(nodes[1]);
        let net_graph_msg_handler = &nodes[0].net_graph_msg_handler;
        let route = get_route(&nodes[0].node.get_our_node_id(), &net_graph_msg_handler.network_graph.read().unwrap(), &nodes[1].node.get_our_node_id(), None, None, &[], 1000000, TEST_FINAL_CLTV, &logger).unwrap();
        nodes[0].node.send_payment(&route, our_payment_hash, &None).unwrap();
@@ -6525,7 +6526,7 @@ fn test_update_add_htlc_bolt2_receiver_check_cltv_expiry() {
        let logger = test_utils::TestLogger::new();
 
        create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 100000, 95000000, InitFeatures::known(), InitFeatures::known());
-       let (_, our_payment_hash) = get_payment_preimage_hash!(nodes[0]);
+       let (_, our_payment_hash, our_payment_secret) = get_payment_preimage_hash!(nodes[1]);
        let net_graph_msg_handler = &nodes[0].net_graph_msg_handler;
        let route = get_route(&nodes[0].node.get_our_node_id(), &net_graph_msg_handler.network_graph.read().unwrap(), &nodes[1].node.get_our_node_id(), None, None, &[], 1000000, TEST_FINAL_CLTV, &logger).unwrap();
        nodes[0].node.send_payment(&route, our_payment_hash, &None).unwrap();
@@ -6552,7 +6553,7 @@ fn test_update_add_htlc_bolt2_receiver_check_repeated_id_ignore() {
        let logger = test_utils::TestLogger::new();
 
        create_announced_chan_between_nodes(&nodes, 0, 1, InitFeatures::known(), InitFeatures::known());
-       let (_, our_payment_hash) = get_payment_preimage_hash!(nodes[0]);
+       let (_, our_payment_hash, our_payment_secret) = get_payment_preimage_hash!(nodes[1]);
        let net_graph_msg_handler = &nodes[0].net_graph_msg_handler;
        let route = get_route(&nodes[0].node.get_our_node_id(), &net_graph_msg_handler.network_graph.read().unwrap(), &nodes[1].node.get_our_node_id(), None, None, &[], 1000000, TEST_FINAL_CLTV, &logger).unwrap();
        nodes[0].node.send_payment(&route, our_payment_hash, &None).unwrap();
@@ -6599,7 +6600,7 @@ fn test_update_fulfill_htlc_bolt2_update_fulfill_htlc_before_commitment() {
        let mut nodes = create_network(2, &node_cfgs, &node_chanmgrs);
        let logger = test_utils::TestLogger::new();
        let chan = create_announced_chan_between_nodes(&nodes, 0, 1, InitFeatures::known(), InitFeatures::known());
-       let (our_payment_preimage, our_payment_hash) = get_payment_preimage_hash!(nodes[0]);
+       let (our_payment_preimage, our_payment_hash, our_payment_secret) = get_payment_preimage_hash!(nodes[1]);
        let net_graph_msg_handler = &nodes[0].net_graph_msg_handler;
        let route = get_route(&nodes[0].node.get_our_node_id(), &net_graph_msg_handler.network_graph.read().unwrap(), &nodes[1].node.get_our_node_id(), None, None, &[], 1000000, TEST_FINAL_CLTV, &logger).unwrap();
        nodes[0].node.send_payment(&route, our_payment_hash, &None).unwrap();
@@ -6633,7 +6634,7 @@ fn test_update_fulfill_htlc_bolt2_update_fail_htlc_before_commitment() {
        let chan = create_announced_chan_between_nodes(&nodes, 0, 1, InitFeatures::known(), InitFeatures::known());
        let logger = test_utils::TestLogger::new();
 
-       let (_, our_payment_hash) = get_payment_preimage_hash!(nodes[0]);
+       let (_, our_payment_hash, our_payment_secret) = get_payment_preimage_hash!(nodes[1]);
        let net_graph_msg_handler = &nodes[0].net_graph_msg_handler;
        let route = get_route(&nodes[0].node.get_our_node_id(), &net_graph_msg_handler.network_graph.read().unwrap(), &nodes[1].node.get_our_node_id(), None, None, &[], 1000000, TEST_FINAL_CLTV, &logger).unwrap();
        nodes[0].node.send_payment(&route, our_payment_hash, &None).unwrap();
@@ -6666,7 +6667,7 @@ fn test_update_fulfill_htlc_bolt2_update_fail_malformed_htlc_before_commitment()
        let chan = create_announced_chan_between_nodes(&nodes, 0, 1, InitFeatures::known(), InitFeatures::known());
        let logger = test_utils::TestLogger::new();
 
-       let (_, our_payment_hash) = get_payment_preimage_hash!(nodes[0]);
+       let (_, our_payment_hash, our_payment_secret) = get_payment_preimage_hash!(nodes[1]);
        let net_graph_msg_handler = &nodes[0].net_graph_msg_handler;
        let route = get_route(&nodes[0].node.get_our_node_id(), &net_graph_msg_handler.network_graph.read().unwrap(), &nodes[1].node.get_our_node_id(), None, None, &[], 1000000, TEST_FINAL_CLTV, &logger).unwrap();
        nodes[0].node.send_payment(&route, our_payment_hash, &None).unwrap();
@@ -6781,7 +6782,7 @@ fn test_update_fulfill_htlc_bolt2_missing_badonion_bit_for_malformed_htlc_messag
        create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 1000000, 1000000, InitFeatures::known(), InitFeatures::known());
        let logger = test_utils::TestLogger::new();
 
-       let (_, our_payment_hash) = get_payment_preimage_hash!(nodes[0]);
+       let (_, our_payment_hash, our_payment_secret) = get_payment_preimage_hash!(nodes[1]);
        let net_graph_msg_handler = &nodes[0].net_graph_msg_handler;
        let route = get_route(&nodes[0].node.get_our_node_id(), &net_graph_msg_handler.network_graph.read().unwrap(), &nodes[1].node.get_our_node_id(), None, None, &[], 1000000, TEST_FINAL_CLTV, &logger).unwrap();
        nodes[0].node.send_payment(&route, our_payment_hash, &None).unwrap();
@@ -6831,7 +6832,7 @@ fn test_update_fulfill_htlc_bolt2_after_malformed_htlc_message_must_forward_upda
        create_announced_chan_between_nodes_with_value(&nodes, 1, 2, 1000000, 1000000, InitFeatures::known(), InitFeatures::known());
        let logger = test_utils::TestLogger::new();
 
-       let (_, our_payment_hash) = get_payment_preimage_hash!(nodes[0]);
+       let (_, our_payment_hash, our_payment_secret) = get_payment_preimage_hash!(nodes[2]);
 
        //First hop
        let mut payment_event = {
@@ -6913,8 +6914,8 @@ fn do_test_failure_delay_dust_htlc_local_commitment(announce_latest: bool) {
        let bs_dust_limit = nodes[1].node.channel_state.lock().unwrap().by_id.get(&chan.2).unwrap().holder_dust_limit_satoshis;
 
        // We route 2 dust-HTLCs between A and B
-       let (_, payment_hash_1) = route_payment(&nodes[0], &[&nodes[1]], bs_dust_limit*1000);
-       let (_, payment_hash_2) = route_payment(&nodes[0], &[&nodes[1]], bs_dust_limit*1000);
+       let (_, payment_hash_1, _) = route_payment(&nodes[0], &[&nodes[1]], bs_dust_limit*1000);
+       let (_, payment_hash_2, _) = route_payment(&nodes[0], &[&nodes[1]], bs_dust_limit*1000);
        route_payment(&nodes[0], &[&nodes[1]], 1000000);
 
        // Cache one local commitment tx as previous
@@ -7002,15 +7003,15 @@ fn do_test_sweep_outbound_htlc_failure_update(revoked: bool, local: bool) {
 
        let bs_dust_limit = nodes[1].node.channel_state.lock().unwrap().by_id.get(&chan.2).unwrap().holder_dust_limit_satoshis;
 
-       let (_payment_preimage_1, dust_hash) = route_payment(&nodes[0], &[&nodes[1]], bs_dust_limit*1000);
-       let (_payment_preimage_2, non_dust_hash) = route_payment(&nodes[0], &[&nodes[1]], 1000000);
+       let (_payment_preimage_1, dust_hash, _payment_secret_1) = route_payment(&nodes[0], &[&nodes[1]], bs_dust_limit*1000);
+       let (_payment_preimage_2, non_dust_hash, _payment_secret_2) = route_payment(&nodes[0], &[&nodes[1]], 1000000);
 
        let as_commitment_tx = get_local_commitment_txn!(nodes[0], chan.2);
        let bs_commitment_tx = get_local_commitment_txn!(nodes[1], chan.2);
 
        // We revoked bs_commitment_tx
        if revoked {
-               let (payment_preimage_3, _) = route_payment(&nodes[0], &[&nodes[1]], 1000000);
+               let (payment_preimage_3, _, _) = route_payment(&nodes[0], &[&nodes[1]], 1000000);
                claim_payment(&nodes[0], &vec!(&nodes[1])[..], payment_preimage_3, 1_000_000);
        }
 
@@ -7482,7 +7483,7 @@ fn test_check_htlc_underpaying() {
        // Create some initial channels
        create_announced_chan_between_nodes(&nodes, 0, 1, InitFeatures::known(), InitFeatures::known());
 
-       let (payment_preimage, payment_hash) = route_payment(&nodes[0], &[&nodes[1]], 10_000);
+       let (payment_preimage, payment_hash, _) = route_payment(&nodes[0], &[&nodes[1]], 10_000);
 
        // Node 3 is expecting payment of 100_000 but receive 10_000,
        // fail htlc like we didn't know the preimage.
@@ -8088,8 +8089,7 @@ fn test_simple_payment_secret() {
        create_announced_chan_between_nodes(&nodes, 1, 2, InitFeatures::known(), InitFeatures::known());
        let logger = test_utils::TestLogger::new();
 
-       let (payment_preimage, payment_hash) = get_payment_preimage_hash!(&nodes[0]);
-       let payment_secret = PaymentSecret([0xdb; 32]);
+       let (payment_preimage, payment_hash, payment_secret) = get_payment_preimage_hash!(&nodes[0]);
        let net_graph_msg_handler = &nodes[0].net_graph_msg_handler;
        let route = get_route(&nodes[0].node.get_our_node_id(), &net_graph_msg_handler.network_graph.read().unwrap(), &nodes[2].node.get_our_node_id(), None, None, &[], 100000, TEST_FINAL_CLTV, &logger).unwrap();
        send_along_route_with_secret(&nodes[0], route, &[&[&nodes[1], &nodes[2]]], 100000, payment_hash, Some(payment_secret.clone()));
@@ -8114,8 +8114,7 @@ fn test_simple_mpp() {
        let chan_4_id = create_announced_chan_between_nodes(&nodes, 2, 3, InitFeatures::known(), InitFeatures::known()).0.contents.short_channel_id;
        let logger = test_utils::TestLogger::new();
 
-       let (payment_preimage, payment_hash) = get_payment_preimage_hash!(&nodes[0]);
-       let payment_secret = PaymentSecret([0xdb; 32]);
+       let (payment_preimage, payment_hash, payment_secret) = get_payment_preimage_hash!(&nodes[3]);
        let net_graph_msg_handler = &nodes[0].net_graph_msg_handler;
        let mut route = get_route(&nodes[0].node.get_our_node_id(), &net_graph_msg_handler.network_graph.read().unwrap(), &nodes[3].node.get_our_node_id(), None, None, &[], 100000, TEST_FINAL_CLTV, &logger).unwrap();
        let path = route.paths[0].clone();
@@ -8264,7 +8263,7 @@ fn test_concurrent_monitor_claim() {
        watchtower_bob.chain_monitor.block_connected(&Block { header, txdata: vec![] }, CHAN_CONFIRM_DEPTH + TEST_FINAL_CLTV + LATENCY_GRACE_PERIOD_BLOCKS);
 
        // Route another payment to generate another update with still previous HTLC pending
-       let (_, payment_hash) = get_payment_preimage_hash!(nodes[0]);
+       let (_, payment_hash, payment_secret) = get_payment_preimage_hash!(nodes[0]);
        {
                let net_graph_msg_handler = &nodes[1].net_graph_msg_handler;
                let route = get_route(&nodes[1].node.get_our_node_id(), &net_graph_msg_handler.network_graph.read().unwrap(), &nodes[0].node.get_our_node_id(), None, None, &Vec::new(), 3000000 , TEST_FINAL_CLTV, &logger).unwrap();
@@ -8367,7 +8366,7 @@ fn test_htlc_no_detection() {
        let chan_1 = create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 100000, 10001, InitFeatures::known(), InitFeatures::known());
 
        send_payment(&nodes[0], &vec!(&nodes[1])[..], 1_000_000, 1_000_000);
-       let (_, our_payment_hash) = route_payment(&nodes[0], &vec!(&nodes[1])[..], 2_000_000);
+       let (_, our_payment_hash, _) = route_payment(&nodes[0], &vec!(&nodes[1])[..], 2_000_000);
        let local_txn = get_local_commitment_txn!(nodes[0], chan_1.2);
        assert_eq!(local_txn[0].input.len(), 1);
        assert_eq!(local_txn[0].output.len(), 3);
@@ -8421,7 +8420,7 @@ fn do_test_onchain_htlc_settlement_after_close(broadcast_alice: bool, go_onchain
 
        // Steps (1) and (2):
        // Send an HTLC Alice --> Bob --> Carol, but Carol doesn't settle the HTLC back.
-       let (payment_preimage, _payment_hash) = route_payment(&nodes[0], &vec!(&nodes[1], &nodes[2]), 3_000_000);
+       let (payment_preimage, _payment_hash, _payment_secret) = route_payment(&nodes[0], &vec!(&nodes[1], &nodes[2]), 3_000_000);
 
        // Check that Alice's commitment transaction now contains an output for this HTLC.
        let alice_txn = get_local_commitment_txn!(nodes[0], chan_ab.2);
index 147ac73105e26bdf9c2c6b02f8d6519a053cc9cf..8aeda04dabea957228682cb4265eb32d83731798 100644 (file)
@@ -267,7 +267,7 @@ fn test_onion_failure() {
                *node.keys_manager.override_session_priv.lock().unwrap() = Some([3; 32]);
        }
        let channels = [create_announced_chan_between_nodes(&nodes, 0, 1, InitFeatures::known(), InitFeatures::known()), create_announced_chan_between_nodes(&nodes, 1, 2, InitFeatures::known(), InitFeatures::known())];
-       let (_, payment_hash) = get_payment_preimage_hash!(nodes[0]);
+       let (_, payment_hash, payment_secret) = get_payment_preimage_hash!(nodes[0]);
        let net_graph_msg_handler = &nodes[0].net_graph_msg_handler;
        let logger = test_utils::TestLogger::new();
        let route = get_route(&nodes[0].node.get_our_node_id(), &net_graph_msg_handler.network_graph.read().unwrap(), &nodes[2].node.get_our_node_id(), None, None, &Vec::new(), 40000, TEST_FINAL_CLTV, &logger).unwrap();
@@ -415,7 +415,7 @@ fn test_onion_failure() {
 
        // Test a positive test-case with one extra msat, meeting the minimum.
        bogus_route.paths[0][route_len-1].fee_msat = amt_to_forward + 1;
-       let (preimage, _) = send_along_route(&nodes[0], bogus_route, &[&nodes[1], &nodes[2]], amt_to_forward+1);
+       let (preimage, _, _) = send_along_route(&nodes[0], bogus_route, &[&nodes[1], &nodes[2]], amt_to_forward+1);
        claim_payment(&nodes[0], &[&nodes[1], &nodes[2]], preimage, amt_to_forward+1);
 
        //TODO: with new config API, we will be able to generate both valid and
index 05001d69e0c72a5c1765b5fec23bffe6344cf132..012d480f2186500914e4296b390674f7986ee639 100644 (file)
@@ -56,7 +56,7 @@ fn do_test_onchain_htlc_reorg(local_commitment: bool, claim: bool) {
        connect_blocks(&nodes[1], 2*CHAN_CONFIRM_DEPTH + 1 - nodes[1].best_block_info().1);
        connect_blocks(&nodes[2], 2*CHAN_CONFIRM_DEPTH + 1 - nodes[2].best_block_info().1);
 
-       let (our_payment_preimage, our_payment_hash) = route_payment(&nodes[0], &[&nodes[1], &nodes[2]], 1000000);
+       let (our_payment_preimage, our_payment_hash, _) = route_payment(&nodes[0], &[&nodes[1], &nodes[2]], 1000000);
 
        // Provide preimage to node 2 by claiming payment
        nodes[2].node.claim_funds(our_payment_preimage, &None, 1000000);