Skip to content

Commit d379f2f

Browse files
committed
Implement finding paths for MPP
1 parent 6f829d3 commit d379f2f

File tree

3 files changed

+2027
-204
lines changed

3 files changed

+2027
-204
lines changed

lightning/src/ln/functional_tests.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1960,7 +1960,8 @@ fn test_channel_reserve_holding_cell_htlcs() {
19601960

19611961
// attempt to send amt_msat > their_max_htlc_value_in_flight_msat
19621962
{
1963-
let (route, our_payment_hash, _) = get_route_and_payment_hash!(recv_value_0 + 1);
1963+
let (mut route, our_payment_hash, _) = get_route_and_payment_hash!(recv_value_0);
1964+
route.paths[0].last_mut().unwrap().fee_msat += 1;
19641965
assert!(route.paths[0].iter().rev().skip(1).all(|h| h.fee_msat == feemsat));
19651966
unwrap_send_err!(nodes[0].node.send_payment(&route, our_payment_hash, &None), true, APIError::ChannelUnavailable { ref err },
19661967
assert!(regex::Regex::new(r"Cannot send value that would put us over the max HTLC value in flight our peer will accept \(\d+\)").unwrap().is_match(err)));
@@ -6472,7 +6473,7 @@ fn test_update_add_htlc_bolt2_sender_cltv_expiry_too_high() {
64726473
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
64736474
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
64746475
let mut nodes = create_network(2, &node_cfgs, &node_chanmgrs);
6475-
let _chan = create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 100000, 0, InitFeatures::known(), InitFeatures::known());
6476+
let _chan = create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 1000000, 0, InitFeatures::known(), InitFeatures::known());
64766477
let logger = test_utils::TestLogger::new();
64776478

64786479
let (_, our_payment_hash) = get_payment_preimage_hash!(nodes[0]);
@@ -6544,9 +6545,13 @@ fn test_update_add_htlc_bolt2_sender_exceed_max_htlc_value_in_flight() {
65446545
send_payment(&nodes[0], &vec!(&nodes[1])[..], max_in_flight, max_in_flight);
65456546

65466547
let (_, our_payment_hash) = get_payment_preimage_hash!(nodes[0]);
6547-
let net_graph_msg_handler = &nodes[0].net_graph_msg_handler;
6548-
let logger = test_utils::TestLogger::new();
6549-
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, &[], max_in_flight+1, TEST_FINAL_CLTV, &logger).unwrap();
6548+
// Manually create a route over our max in flight (which our router normally automatically
6549+
// limits us to.
6550+
let route = Route { paths: vec![vec![RouteHop {
6551+
pubkey: nodes[1].node.get_our_node_id(), node_features: NodeFeatures::known(), channel_features: ChannelFeatures::known(),
6552+
short_channel_id: nodes[1].node.list_usable_channels()[0].short_channel_id.unwrap(),
6553+
fee_msat: max_in_flight + 1, cltv_expiry_delta: TEST_FINAL_CLTV
6554+
}]] };
65506555
unwrap_send_err!(nodes[0].node.send_payment(&route, our_payment_hash, &None), true, APIError::ChannelUnavailable { ref err },
65516556
assert!(regex::Regex::new(r"Cannot send value that would put us over the max HTLC value in flight our peer will accept \(\d+\)").unwrap().is_match(err)));
65526557

lightning/src/routing/network_graph.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,13 @@ impl<C: Deref, L: Deref> NetGraphMsgHandler<C, L> where C::Target: chain::Access
9898
}
9999
}
100100

101+
/// Adds a provider used to check new announcements. Does not affect
102+
/// existing announcements unless they are updated.
103+
/// Add, update or remove the provider would replace the current one.
104+
pub fn add_chain_access(&mut self, chain_access: Option<C>) {
105+
self.chain_access = chain_access;
106+
}
107+
101108
/// Take a read lock on the network_graph and return it in the C-bindings
102109
/// newtype helper. This is likely only useful when called via the C
103110
/// bindings as you can call `self.network_graph.read().unwrap()` in Rust

0 commit comments

Comments
 (0)