Skip to content

Commit 6f8d6ae

Browse files
authored
Merge pull request #646 from naumenkogs/2020-06-router-mpp
MPP on the router side
2 parents 9fba7c9 + e0600e5 commit 6f8d6ae

File tree

5 files changed

+2277
-205
lines changed

5 files changed

+2277
-205
lines changed

fuzz/src/router.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,8 @@ pub fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {
231231
proportional_millionths: slice_to_be32(get_slice!(4)),
232232
},
233233
cltv_expiry_delta: slice_to_be16(get_slice!(2)),
234-
htlc_minimum_msat: slice_to_be64(get_slice!(8)),
234+
htlc_minimum_msat: Some(slice_to_be64(get_slice!(8))),
235+
htlc_maximum_msat: None,
235236
});
236237
}
237238
}

lightning/src/ln/channel.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3325,7 +3325,7 @@ impl<Signer: Sign> Channel<Signer> {
33253325
// Upper bound by capacity. We make it a bit less than full capacity to prevent attempts
33263326
// to use full capacity. This is an effort to reduce routing failures, because in many cases
33273327
// channel might have been used to route very small values (either by honest users or as DoS).
3328-
self.channel_value_satoshis * 9 / 10,
3328+
self.channel_value_satoshis * 1000 * 9 / 10,
33293329

33303330
Channel::<Signer>::get_holder_max_htlc_value_in_flight_msat(self.channel_value_satoshis)
33313331
);

lightning/src/ln/functional_tests.rs

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

19701970
// attempt to send amt_msat > their_max_htlc_value_in_flight_msat
19711971
{
1972-
let (route, our_payment_hash, _) = get_route_and_payment_hash!(recv_value_0 + 1);
1972+
let (mut route, our_payment_hash, _) = get_route_and_payment_hash!(recv_value_0);
1973+
route.paths[0].last_mut().unwrap().fee_msat += 1;
19731974
assert!(route.paths[0].iter().rev().skip(1).all(|h| h.fee_msat == feemsat));
19741975
unwrap_send_err!(nodes[0].node.send_payment(&route, our_payment_hash, &None), true, APIError::ChannelUnavailable { ref err },
19751976
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)));
@@ -6384,7 +6385,7 @@ fn test_update_add_htlc_bolt2_sender_cltv_expiry_too_high() {
63846385
let node_cfgs = create_node_cfgs(2, &chanmon_cfgs);
63856386
let node_chanmgrs = create_node_chanmgrs(2, &node_cfgs, &[None, None]);
63866387
let mut nodes = create_network(2, &node_cfgs, &node_chanmgrs);
6387-
let _chan = create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 100000, 0, InitFeatures::known(), InitFeatures::known());
6388+
let _chan = create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 1000000, 0, InitFeatures::known(), InitFeatures::known());
63886389
let logger = test_utils::TestLogger::new();
63896390

63906391
let (_, our_payment_hash) = get_payment_preimage_hash!(nodes[0]);
@@ -6456,9 +6457,13 @@ fn test_update_add_htlc_bolt2_sender_exceed_max_htlc_value_in_flight() {
64566457
send_payment(&nodes[0], &vec!(&nodes[1])[..], max_in_flight, max_in_flight);
64576458

64586459
let (_, our_payment_hash) = get_payment_preimage_hash!(nodes[0]);
6459-
let net_graph_msg_handler = &nodes[0].net_graph_msg_handler;
6460-
let logger = test_utils::TestLogger::new();
6461-
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();
6460+
// Manually create a route over our max in flight (which our router normally automatically
6461+
// limits us to.
6462+
let route = Route { paths: vec![vec![RouteHop {
6463+
pubkey: nodes[1].node.get_our_node_id(), node_features: NodeFeatures::known(), channel_features: ChannelFeatures::known(),
6464+
short_channel_id: nodes[1].node.list_usable_channels()[0].short_channel_id.unwrap(),
6465+
fee_msat: max_in_flight + 1, cltv_expiry_delta: TEST_FINAL_CLTV
6466+
}]] };
64626467
unwrap_send_err!(nodes[0].node.send_payment(&route, our_payment_hash, &None), true, APIError::ChannelUnavailable { ref err },
64636468
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)));
64646469

lightning/src/routing/network_graph.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,13 @@ impl<C: Deref, L: Deref> NetGraphMsgHandler<C, L> where C::Target: chain::Access
102102
}
103103
}
104104

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

0 commit comments

Comments
 (0)