Correct logging on forwarded HTLCs
[ldk-sample] / src / main.rs
index 202b551f140ad177c67f49f4d95262e3999d4514..08bedc70c1b0d4adc3b4bae3ead8def147eb6928 100644 (file)
@@ -116,21 +116,6 @@ type GossipSync<P, G, A, L> =
 
 pub(crate) type NetworkGraph = gossip::NetworkGraph<Arc<FilesystemLogger>>;
 
-struct NodeAlias<'a>(&'a [u8; 32]);
-
-impl fmt::Display for NodeAlias<'_> {
-       fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-               let alias = self
-                       .0
-                       .iter()
-                       .map(|b| *b as char)
-                       .take_while(|c| *c != '\0')
-                       .filter(|c| c.is_ascii_graphic() || *c == ' ')
-                       .collect::<String>();
-               write!(f, "{}", alias)
-       }
-}
-
 async fn handle_ldk_events(
        channel_manager: &Arc<ChannelManager>, bitcoind_client: &BitcoindClient,
        network_graph: &NetworkGraph, keys_manager: &KeysManager,
@@ -290,11 +275,11 @@ async fn handle_ldk_events(
                                        None => String::new(),
                                        Some(channel) => {
                                                match nodes.get(&NodeId::from_pubkey(&channel.counterparty.node_id)) {
-                                                       None => " from private node".to_string(),
+                                                       None => "private node".to_string(),
                                                        Some(node) => match &node.announcement_info {
-                                                               None => " from unnamed node".to_string(),
+                                                               None => "unnamed node".to_string(),
                                                                Some(announcement) => {
-                                                                       format!(" from node {}", NodeAlias(&announcement.alias))
+                                                                       format!("node {}", announcement.alias)
                                                                }
                                                        },
                                                }
@@ -307,9 +292,9 @@ async fn handle_ldk_events(
                                        .unwrap_or_default()
                        };
                        let from_prev_str =
-                               format!("{}{}", node_str(prev_channel_id), channel_str(prev_channel_id));
+                               format!(" from {}{}", node_str(prev_channel_id), channel_str(prev_channel_id));
                        let to_next_str =
-                               format!("{}{}", node_str(next_channel_id), channel_str(next_channel_id));
+                               format!(" to {}{}", node_str(next_channel_id), channel_str(next_channel_id));
 
                        let from_onchain_str = if *claim_from_onchain_tx {
                                "from onchain downstream claim"
@@ -474,7 +459,7 @@ async fn start_ldk() {
 
        // Step 8: Initialize the ChannelManager
        let mut user_config = UserConfig::default();
-       user_config.peer_channel_config_limits.force_announced_channel_preference = false;
+       user_config.channel_handshake_limits.force_announced_channel_preference = false;
        let mut restarting_node = true;
        let (channel_manager_blockhash, channel_manager) = {
                if let Ok(mut f) = fs::File::open(format!("{}/manager", ldk_data_dir.clone())) {