Skip to content

Commit 7064d27

Browse files
Expose channel fees in ChannelDetails
We need this to make route hints for invoices.
1 parent 4894d52 commit 7064d27

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,10 @@ pub struct ChannelDetails {
544544
/// True if the channel is (a) confirmed and funding_locked messages have been exchanged, (b)
545545
/// the peer is connected, and (c) no monitor update failure is pending resolution.
546546
pub is_live: bool,
547+
/// Fee charged by this node per transaction.
548+
pub fee_base_msat: u32,
549+
/// Fee charged by this node proportional to the amount routed.
550+
pub fee_proportional_millionths: u32,
547551
}
548552

549553
/// If a payment fails to send, it can be in one of several states. This enum is returned as the
@@ -863,6 +867,8 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
863867
outbound_capacity_msat,
864868
user_id: channel.get_user_id(),
865869
is_live: channel.is_live(),
870+
fee_base_msat: channel.get_holder_fee_base_msat(&self.fee_estimator),
871+
fee_proportional_millionths: channel.get_fee_proportional_millionths(),
866872
});
867873
}
868874
}

lightning/src/routing/router.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1443,6 +1443,8 @@ mod tests {
14431443
outbound_capacity_msat: 100000,
14441444
inbound_capacity_msat: 100000,
14451445
is_live: true,
1446+
fee_base_msat: 0,
1447+
fee_proportional_millionths: 0,
14461448
}];
14471449

14481450
if let Err(LightningError{err, action: ErrorAction::IgnoreError}) = get_route(&our_id, &net_graph_msg_handler.network_graph.read().unwrap(), &nodes[2], Some(&our_chans.iter().collect::<Vec<_>>()), &Vec::new(), 100, 42, Arc::clone(&logger)) {
@@ -1757,6 +1759,8 @@ mod tests {
17571759
outbound_capacity_msat: 250_000_000,
17581760
inbound_capacity_msat: 0,
17591761
is_live: true,
1762+
fee_base_msat: 0,
1763+
fee_proportional_millionths: 0,
17601764
}];
17611765
let route = get_route(&our_id, &net_graph_msg_handler.network_graph.read().unwrap(), &nodes[2], Some(&our_chans.iter().collect::<Vec<_>>()), &Vec::new(), 100, 42, Arc::clone(&logger)).unwrap();
17621766
assert_eq!(route.paths[0].len(), 2);
@@ -1804,6 +1808,8 @@ mod tests {
18041808
outbound_capacity_msat: 250_000_000,
18051809
inbound_capacity_msat: 0,
18061810
is_live: true,
1811+
fee_base_msat: 0,
1812+
fee_proportional_millionths: 0,
18071813
}];
18081814
let route = get_route(&our_id, &net_graph_msg_handler.network_graph.read().unwrap(), &nodes[2], Some(&our_chans.iter().collect::<Vec<_>>()), &Vec::new(), 100, 42, Arc::clone(&logger)).unwrap();
18091815
assert_eq!(route.paths[0].len(), 2);
@@ -1868,6 +1874,8 @@ mod tests {
18681874
outbound_capacity_msat: 250_000_000,
18691875
inbound_capacity_msat: 0,
18701876
is_live: true,
1877+
fee_base_msat: 0,
1878+
fee_proportional_millionths: 0,
18711879
}];
18721880
let route = get_route(&our_id, &net_graph_msg_handler.network_graph.read().unwrap(), &nodes[2], Some(&our_chans.iter().collect::<Vec<_>>()), &Vec::new(), 100, 42, Arc::clone(&logger)).unwrap();
18731881
assert_eq!(route.paths[0].len(), 2);
@@ -2004,6 +2012,8 @@ mod tests {
20042012
outbound_capacity_msat: 250_000_000,
20052013
inbound_capacity_msat: 0,
20062014
is_live: true,
2015+
fee_base_msat: 0,
2016+
fee_proportional_millionths: 0,
20072017
}];
20082018
let mut last_hops = last_hops(&nodes);
20092019
let route = get_route(&our_id, &net_graph_msg_handler.network_graph.read().unwrap(), &nodes[6], Some(&our_chans.iter().collect::<Vec<_>>()), &last_hops.iter().collect::<Vec<_>>(), 100, 42, Arc::clone(&logger)).unwrap();
@@ -2132,6 +2142,8 @@ mod tests {
21322142
outbound_capacity_msat: 100000,
21332143
inbound_capacity_msat: 100000,
21342144
is_live: true,
2145+
fee_base_msat: 0,
2146+
fee_proportional_millionths: 0,
21352147
}];
21362148
let route = get_route(&source_node_id, &NetworkGraph::new(genesis_block(Network::Testnet).header.block_hash()), &target_node_id, Some(&our_chans.iter().collect::<Vec<_>>()), &last_hops.iter().collect::<Vec<_>>(), 100, 42, Arc::new(test_utils::TestLogger::new())).unwrap();
21372149

@@ -2261,6 +2273,8 @@ mod tests {
22612273
outbound_capacity_msat: 200_000_000,
22622274
inbound_capacity_msat: 0,
22632275
is_live: true,
2276+
fee_base_msat: 0,
2277+
fee_proportional_millionths: 0,
22642278
}];
22652279

22662280
{

0 commit comments

Comments
 (0)