]> git.bitcoin.ninja Git - ldk-sample/commitdiff
Update code and Cargo.toml to LDK 0.0.109
authorMatt Corallo <git@bluematt.me>
Thu, 7 Jul 2022 14:41:14 +0000 (14:41 +0000)
committerMatt Corallo <git@bluematt.me>
Thu, 7 Jul 2022 14:56:32 +0000 (14:56 +0000)
Cargo.toml
src/cli.rs
src/disk.rs
src/main.rs

index ed5ad9ca14741f16b9542a207c064a79c830d05a..74ce48b40325f7804d358fd00e039452389e0b39 100644 (file)
@@ -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"
index bf2f7929434de90f1fe9d9fd5f9f7fe9fb59a8df..6c0b756d771d965f0769f72f595b096dede8b2c9 100644 (file)
@@ -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<ChannelManager>, network_graph: &Arc<Netw
                        .get(&NodeId::from_pubkey(&chan_info.counterparty.node_id))
                {
                        if let Some(announcement) = &node_info.announcement_info {
-                               println!("\t\tpeer_alias: {}", NodeAlias(&announcement.alias));
+                               println!("\t\tpeer_alias: {}", announcement.alias);
                        }
                }
 
@@ -585,12 +585,15 @@ fn open_channel(
        channel_manager: Arc<ChannelManager>,
 ) -> 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<ChannelManager>,
 ) {
-       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),
        }
index fe614184502d30e5259c6249cfd9eb55bae9a60c..681d742d5444438784e488d95b09348211b6cf0e 100644 (file)
@@ -88,7 +88,7 @@ pub(crate) fn read_scorer(
 ) -> ProbabilisticScorer<Arc<NetworkGraph>, Arc<FilesystemLogger>> {
        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;
                }
index 202b551f140ad177c67f49f4d95262e3999d4514..bfe5bff311517794daa5f7a0207e34955a49af3f 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,
@@ -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())) {