Skip to content

Expose channel fees in ChannelDetails #824

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions fuzz/src/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,8 @@ pub fn do_test<Out: test_logger::Output>(data: &[u8], out: Out) {
inbound_capacity_msat: 0,
is_live: true,
outbound_capacity_msat: 0,
fee_base_msat: 0,
fee_proportional_millionths: 0,
});
}
Some(&first_hops_vec[..])
Expand Down
6 changes: 6 additions & 0 deletions lightning/src/ln/channelmanager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,10 @@ pub struct ChannelDetails {
/// True if the channel is (a) confirmed and funding_locked messages have been exchanged, (b)
/// the peer is connected, and (c) no monitor update failure is pending resolution.
pub is_live: bool,
/// Fee charged by this node per transaction.
pub fee_base_msat: u32,
/// Fee charged by this node proportional to the amount routed.
pub fee_proportional_millionths: u32,
}

/// If a payment fails to send, it can be in one of several states. This enum is returned as the
Expand Down Expand Up @@ -863,6 +867,8 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
outbound_capacity_msat,
user_id: channel.get_user_id(),
is_live: channel.is_live(),
fee_base_msat: channel.get_holder_fee_base_msat(&self.fee_estimator),
fee_proportional_millionths: channel.get_fee_proportional_millionths(),
});
}
}
Expand Down
14 changes: 14 additions & 0 deletions lightning/src/routing/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1443,6 +1443,8 @@ mod tests {
outbound_capacity_msat: 100000,
inbound_capacity_msat: 100000,
is_live: true,
fee_base_msat: 0,
fee_proportional_millionths: 0,
}];

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)) {
Expand Down Expand Up @@ -1757,6 +1759,8 @@ mod tests {
outbound_capacity_msat: 250_000_000,
inbound_capacity_msat: 0,
is_live: true,
fee_base_msat: 0,
fee_proportional_millionths: 0,
}];
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();
assert_eq!(route.paths[0].len(), 2);
Expand Down Expand Up @@ -1804,6 +1808,8 @@ mod tests {
outbound_capacity_msat: 250_000_000,
inbound_capacity_msat: 0,
is_live: true,
fee_base_msat: 0,
fee_proportional_millionths: 0,
}];
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();
assert_eq!(route.paths[0].len(), 2);
Expand Down Expand Up @@ -1868,6 +1874,8 @@ mod tests {
outbound_capacity_msat: 250_000_000,
inbound_capacity_msat: 0,
is_live: true,
fee_base_msat: 0,
fee_proportional_millionths: 0,
}];
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();
assert_eq!(route.paths[0].len(), 2);
Expand Down Expand Up @@ -2004,6 +2012,8 @@ mod tests {
outbound_capacity_msat: 250_000_000,
inbound_capacity_msat: 0,
is_live: true,
fee_base_msat: 0,
fee_proportional_millionths: 0,
}];
let mut last_hops = last_hops(&nodes);
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();
Expand Down Expand Up @@ -2132,6 +2142,8 @@ mod tests {
outbound_capacity_msat: 100000,
inbound_capacity_msat: 100000,
is_live: true,
fee_base_msat: 0,
fee_proportional_millionths: 0,
}];
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();

Expand Down Expand Up @@ -2261,6 +2273,8 @@ mod tests {
outbound_capacity_msat: 200_000_000,
inbound_capacity_msat: 0,
is_live: true,
fee_base_msat: 0,
fee_proportional_millionths: 0,
}];

{
Expand Down