From: Matt Corallo Date: Thu, 7 Jul 2022 14:41:14 +0000 (+0000) Subject: Update code and Cargo.toml to LDK 0.0.109 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=c45a4b94c1c60e599105565cf1055e0413f0e856;p=ldk-sample Update code and Cargo.toml to LDK 0.0.109 --- diff --git a/Cargo.toml b/Cargo.toml index ed5ad9c..74ce48b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,13 +8,13 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -lightning = { version = "0.0.108", features = ["max_level_trace"] } -lightning-block-sync = { version = "0.0.108", features = [ "rpc-client" ] } -lightning-invoice = { version = "0.16" } -lightning-net-tokio = { version = "0.0.108" } -lightning-persister = { version = "0.0.108" } -lightning-background-processor = { version = "0.0.108" } -lightning-rapid-gossip-sync = { version = "0.0.108" } +lightning = { version = "0.0.109", features = ["max_level_trace"] } +lightning-block-sync = { version = "0.0.109", features = [ "rpc-client" ] } +lightning-invoice = { version = "0.17" } +lightning-net-tokio = { version = "0.0.109" } +lightning-persister = { version = "0.0.109" } +lightning-background-processor = { version = "0.0.109" } +lightning-rapid-gossip-sync = { version = "0.0.109" } base64 = "0.13.0" bitcoin = "0.28.1" diff --git a/src/cli.rs b/src/cli.rs index bf2f792..6c0b756 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -1,7 +1,7 @@ use crate::disk; use crate::hex_utils; use crate::{ - ChannelManager, HTLCStatus, InvoicePayer, MillisatAmount, NetworkGraph, NodeAlias, PaymentInfo, + ChannelManager, HTLCStatus, InvoicePayer, MillisatAmount, NetworkGraph, PaymentInfo, PaymentInfoStorage, PeerManager, }; use bitcoin::hashes::sha256::Hash as Sha256; @@ -12,7 +12,7 @@ use lightning::chain::keysinterface::{KeysInterface, KeysManager, Recipient}; use lightning::ln::msgs::NetAddress; use lightning::ln::{PaymentHash, PaymentPreimage}; use lightning::routing::gossip::NodeId; -use lightning::util::config::{ChannelConfig, ChannelHandshakeLimits, UserConfig}; +use lightning::util::config::{ChannelHandshakeConfig, ChannelHandshakeLimits, UserConfig}; use lightning::util::events::EventHandler; use lightning_invoice::payment::PaymentError; use lightning_invoice::{utils, Currency, Invoice}; @@ -477,7 +477,7 @@ fn list_channels(channel_manager: &Arc, network_graph: &Arc, ) -> Result<(), ()> { let config = UserConfig { - peer_channel_config_limits: ChannelHandshakeLimits { + channel_handshake_limits: ChannelHandshakeLimits { // lnd's max to_self_delay is 2016, so we want to be compatible. their_to_self_delay: 2016, ..Default::default() }, - channel_options: ChannelConfig { announced_channel, ..Default::default() }, + channel_handshake_config: ChannelHandshakeConfig { + announced_channel, + ..Default::default() + }, ..Default::default() }; @@ -747,7 +750,7 @@ fn close_channel( fn force_close_channel( channel_id: [u8; 32], counterparty_node_id: PublicKey, channel_manager: Arc, ) { - match channel_manager.force_close_channel(&channel_id, &counterparty_node_id) { + match channel_manager.force_close_broadcasting_latest_txn(&channel_id, &counterparty_node_id) { Ok(()) => println!("EVENT: initiating channel force-close"), Err(e) => println!("ERROR: failed to force-close channel: {:?}", e), } diff --git a/src/disk.rs b/src/disk.rs index fe61418..681d742 100644 --- a/src/disk.rs +++ b/src/disk.rs @@ -88,7 +88,7 @@ pub(crate) fn read_scorer( ) -> ProbabilisticScorer, Arc> { let params = ProbabilisticScoringParameters::default(); if let Ok(file) = File::open(path) { - let args = (params, Arc::clone(&graph), Arc::clone(&logger)); + let args = (params.clone(), Arc::clone(&graph), Arc::clone(&logger)); if let Ok(scorer) = ProbabilisticScorer::read(&mut BufReader::new(file), args) { return scorer; } diff --git a/src/main.rs b/src/main.rs index 202b551..bfe5bff 100644 --- a/src/main.rs +++ b/src/main.rs @@ -116,21 +116,6 @@ type GossipSync = pub(crate) type NetworkGraph = gossip::NetworkGraph>; -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::(); - write!(f, "{}", alias) - } -} - async fn handle_ldk_events( channel_manager: &Arc, bitcoind_client: &BitcoindClient, network_graph: &NetworkGraph, keys_manager: &KeysManager, @@ -294,7 +279,7 @@ async fn handle_ldk_events( Some(node) => match &node.announcement_info { None => " from unnamed node".to_string(), Some(announcement) => { - format!(" from node {}", NodeAlias(&announcement.alias)) + format!(" from node {}", announcement.alias) } }, } @@ -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())) {