]> git.bitcoin.ninja Git - ldk-sample/commitdiff
Update to LDK 0.0.123.
authorValentine Wallace <vwallace@protonmail.com>
Mon, 6 May 2024 16:25:51 +0000 (12:25 -0400)
committerValentine Wallace <vwallace@protonmail.com>
Tue, 28 May 2024 16:56:51 +0000 (12:56 -0400)
Cargo.lock
Cargo.toml
src/cli.rs
src/main.rs
src/sweep.rs

index 20f8866bfdf452b8c32068b885b06111ad5d340f..c20c11970704a298852b298eea2cd877ba2a3677 100644 (file)
@@ -306,9 +306,9 @@ checksum = "302d7ab3130588088d277783b1e2d2e10c9e9e4a16dd9050e6ec93fb3e7048f4"
 
 [[package]]
 name = "lightning"
-version = "0.0.121"
+version = "0.0.123"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5b0c1f811ae288f86c6767055c55b5f7a721ca1e61bf1897a9ae2ec663e8aba1"
+checksum = "5fd92d4aa159374be430c7590e169b4a6c0fb79018f5bc4ea1bffde536384db3"
 dependencies = [
  "bitcoin",
  "hex-conservative",
@@ -316,9 +316,9 @@ dependencies = [
 
 [[package]]
 name = "lightning-background-processor"
-version = "0.0.121"
+version = "0.0.123"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "57d4711ad9cc33f30c2e8e876fcfd6255523fc250440abb8c374cd98e6c40e79"
+checksum = "fb1c2c64050e37cee7c3b6b022106523784055ac3ee572d360780a1d6fe8062c"
 dependencies = [
  "bitcoin",
  "lightning",
@@ -327,9 +327,9 @@ dependencies = [
 
 [[package]]
 name = "lightning-block-sync"
-version = "0.0.121"
+version = "0.0.123"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "dcb75d3aca909b77ee21b2e26714c370bdc3246734fa3d4355afa503cb3c0feb"
+checksum = "61e1e70fa351daccede0c366cf16320b16a3e42b05ae3c7ec9c0df6b5d3a3e18"
 dependencies = [
  "bitcoin",
  "chunked_transfer",
@@ -341,22 +341,21 @@ dependencies = [
 
 [[package]]
 name = "lightning-invoice"
-version = "0.29.0"
+version = "0.31.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5b186aca4a605d4db3b85979922be287b9ebd5dedd8132963bb9dbeb8f7d2a04"
+checksum = "26d07d01cf197bf2184b929b7dc94aa70d935aac6df896c256a3a9475b7e9d40"
 dependencies = [
  "bech32 0.9.1",
  "bitcoin",
  "lightning",
- "num-traits",
  "secp256k1",
 ]
 
 [[package]]
 name = "lightning-net-tokio"
-version = "0.0.121"
+version = "0.0.123"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4813cca14ed984924a6975895e80cde8673a0a105a1c7ddf3b0fb3d1ce59e6bf"
+checksum = "f9e6a4d49c50a1344916d080dc8c012ce3a778cdd45de8def75350b2b40fe018"
 dependencies = [
  "bitcoin",
  "lightning",
@@ -365,9 +364,9 @@ dependencies = [
 
 [[package]]
 name = "lightning-persister"
-version = "0.0.121"
+version = "0.0.123"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a82a633e4d08b75e16dc131af2961254b7005c30ab29577e215080d2943c0511"
+checksum = "8a8dd33971815fa074b05678e09a6d4b15c78225ea34d66ed4f17c35a53467a9"
 dependencies = [
  "bitcoin",
  "lightning",
@@ -376,9 +375,9 @@ dependencies = [
 
 [[package]]
 name = "lightning-rapid-gossip-sync"
-version = "0.0.121"
+version = "0.0.123"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "128d6c450cb698b46ecacc6645ebeb2b57d6f9458482635ab523863fa8378314"
+checksum = "9d861b0f0cd5f8fe8c63760023c4fd4fd32c384881b41780b62ced2a8a619f91"
 dependencies = [
  "bitcoin",
  "lightning",
index 99699ebef7e2928e27f337d5f269d5e3ee314cc2..172bcd1d03d41e2d63ca2541a33b7f794c48099a 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.121", features = ["max_level_trace"] }
-lightning-block-sync = { version = "0.0.121", features = [ "rpc-client", "tokio" ] }
-lightning-invoice = { version = "0.29.0" }
-lightning-net-tokio = { version = "0.0.121" }
-lightning-persister = { version = "0.0.121" }
-lightning-background-processor = { version = "0.0.121", features = [ "futures" ] }
-lightning-rapid-gossip-sync = { version = "0.0.121" }
+lightning = { version = "0.0.123", features = ["max_level_trace"] }
+lightning-block-sync = { version = "0.0.123", features = [ "rpc-client", "tokio" ] }
+lightning-invoice = { version = "0.31.0" }
+lightning-net-tokio = { version = "0.0.123" }
+lightning-persister = { version = "0.0.123" }
+lightning-background-processor = { version = "0.0.123", features = [ "futures" ] }
+lightning-rapid-gossip-sync = { version = "0.0.123" }
 
 base64 = "0.13.0"
 bitcoin = "0.30.2"
index fe1b286d7b4d7abaf424495a98dccd522bb56daf..4d64d89b63f51128bbf1e989256fae6993be6473 100644 (file)
@@ -286,7 +286,7 @@ pub(crate) fn poll_for_user_input(
                                        );
                                },
                                "getoffer" => {
-                                       let offer_builder = channel_manager.create_offer_builder(String::new());
+                                       let offer_builder = channel_manager.create_offer_builder();
                                        if let Err(e) = offer_builder {
                                                println!("ERROR: Failed to initiate offer building: {:?}", e);
                                                continue;
@@ -603,14 +603,14 @@ fn node_info(channel_manager: &Arc<ChannelManager>, peer_manager: &Arc<PeerManag
        println!("\t\t num_usable_channels: {}", chans.iter().filter(|c| c.is_usable).count());
        let local_balance_msat = chans.iter().map(|c| c.balance_msat).sum::<u64>();
        println!("\t\t local_balance_msat: {}", local_balance_msat);
-       println!("\t\t num_peers: {}", peer_manager.get_peer_node_ids().len());
+       println!("\t\t num_peers: {}", peer_manager.list_peers().len());
        println!("\t}},");
 }
 
 fn list_peers(peer_manager: Arc<PeerManager>) {
        println!("\t{{");
-       for (pubkey, _) in peer_manager.get_peer_node_ids() {
-               println!("\t\t pubkey: {}", pubkey);
+       for peer_details in peer_manager.list_peers() {
+               println!("\t\t pubkey: {}", peer_details.counterparty_node_id);
        }
        println!("\t}},");
 }
@@ -701,8 +701,8 @@ fn list_payments(
 pub(crate) async fn connect_peer_if_necessary(
        pubkey: PublicKey, peer_addr: SocketAddr, peer_manager: Arc<PeerManager>,
 ) -> Result<(), ()> {
-       for (node_pubkey, _) in peer_manager.get_peer_node_ids() {
-               if node_pubkey == pubkey {
+       for peer_details in peer_manager.list_peers() {
+               if peer_details.counterparty_node_id == pubkey {
                        return Ok(());
                }
        }
@@ -725,7 +725,7 @@ pub(crate) async fn do_connect_peer(
                                        _ = &mut connection_closed_future => return Err(()),
                                        _ = tokio::time::sleep(Duration::from_millis(10)) => {},
                                };
-                               if peer_manager.get_peer_node_ids().iter().find(|(id, _)| *id == pubkey).is_some() {
+                               if peer_manager.peer_by_node_id(&pubkey).is_some() {
                                        return Ok(());
                                }
                        }
@@ -747,8 +747,7 @@ fn do_disconnect_peer(
        }
 
        //check the pubkey matches a valid connected peer
-       let peers = peer_manager.get_peer_node_ids();
-       if !peers.iter().any(|(pk, _)| &pubkey == pk) {
+       if peer_manager.peer_by_node_id(&pubkey).is_none() {
                println!("Error: Could not find peer {}", pubkey);
                return Err(());
        }
index add6990056b03bedd823492f841e9b302164a47e..23697d33ac6e35b933598f74f62baccfaaea82b9 100644 (file)
@@ -247,7 +247,9 @@ async fn handle_ldk_events(
                        print!("> ");
                        io::stdout().flush().unwrap();
                        let payment_preimage = match purpose {
-                               PaymentPurpose::InvoicePayment { payment_preimage, .. } => payment_preimage,
+                               PaymentPurpose::Bolt11InvoicePayment { payment_preimage, .. } => payment_preimage,
+                               PaymentPurpose::Bolt12OfferPayment { payment_preimage, .. } => payment_preimage,
+                               PaymentPurpose::Bolt12RefundPayment { payment_preimage, .. } => payment_preimage,
                                PaymentPurpose::SpontaneousPayment(preimage) => Some(preimage),
                        };
                        channel_manager.claim_funds(payment_preimage.unwrap());
@@ -267,9 +269,15 @@ async fn handle_ldk_events(
                        print!("> ");
                        io::stdout().flush().unwrap();
                        let (payment_preimage, payment_secret) = match purpose {
-                               PaymentPurpose::InvoicePayment { payment_preimage, payment_secret, .. } => {
+                               PaymentPurpose::Bolt11InvoicePayment {
+                                       payment_preimage, payment_secret, ..
+                               } => (payment_preimage, Some(payment_secret)),
+                               PaymentPurpose::Bolt12OfferPayment { payment_preimage, payment_secret, .. } => {
                                        (payment_preimage, Some(payment_secret))
                                },
+                               PaymentPurpose::Bolt12RefundPayment {
+                                       payment_preimage, payment_secret, ..
+                               } => (payment_preimage, Some(payment_secret)),
                                PaymentPurpose::SpontaneousPayment(preimage) => (Some(preimage), None),
                        };
                        let mut inbound = inbound_payments.lock().unwrap();
@@ -381,9 +389,12 @@ async fn handle_ldk_events(
                Event::PaymentForwarded {
                        prev_channel_id,
                        next_channel_id,
-                       fee_earned_msat,
+                       total_fee_earned_msat,
                        claim_from_onchain_tx,
                        outbound_amount_forwarded_msat,
+                       skimmed_fee_msat: _,
+                       prev_user_channel_id: _,
+                       next_user_channel_id: _,
                } => {
                        let read_only_network_graph = network_graph.read_only();
                        let nodes = read_only_network_graph.nodes();
@@ -426,7 +437,7 @@ async fn handle_ldk_events(
                        } else {
                                "?".to_string()
                        };
-                       if let Some(fee_earned) = fee_earned_msat {
+                       if let Some(fee_earned) = total_fee_earned_msat {
                                println!(
                                        "\nEVENT: Forwarded payment for {} msat{}{}, earning {} msat {}",
                                        amt_args, from_prev_str, to_next_str, fee_earned, from_onchain_str
@@ -677,7 +688,7 @@ async fn start_ldk() {
        let router = Arc::new(DefaultRouter::new(
                network_graph.clone(),
                logger.clone(),
-               keys_manager.get_secure_random_bytes(),
+               keys_manager.clone(),
                scorer.clone(),
                scoring_fee_params,
        ));
@@ -712,7 +723,7 @@ async fn start_ldk() {
                        restarting_node = false;
 
                        let polled_best_block = polled_chain_tip.to_best_block();
-                       let polled_best_block_hash = polled_best_block.block_hash();
+                       let polled_best_block_hash = polled_best_block.block_hash;
                        let chain_params =
                                ChainParameters { network: args.network, best_block: polled_best_block };
                        let fresh_channel_manager = channelmanager::ChannelManager::new(
@@ -789,7 +800,8 @@ async fn start_ldk() {
                Arc::clone(&keys_manager),
                Arc::clone(&keys_manager),
                Arc::clone(&logger),
-               Arc::new(DefaultMessageRouter::new(Arc::clone(&network_graph))),
+               Arc::clone(&channel_manager),
+               Arc::new(DefaultMessageRouter::new(Arc::clone(&network_graph), Arc::clone(&keys_manager))),
                Arc::clone(&channel_manager),
                IgnoringMessageHandler {},
        ));
@@ -969,12 +981,11 @@ async fn start_ldk() {
                        interval.tick().await;
                        match disk::read_channel_peer_data(Path::new(&peer_data_path)) {
                                Ok(info) => {
-                                       let peers = connect_pm.get_peer_node_ids();
                                        for node_id in connect_cm
                                                .list_channels()
                                                .iter()
                                                .map(|chan| chan.counterparty.node_id)
-                                               .filter(|id| !peers.iter().any(|(pk, _)| id == pk))
+                                               .filter(|id| connect_pm.peer_by_node_id(id).is_none())
                                        {
                                                if stop_connect.load(Ordering::Acquire) {
                                                        return;
index fbfa62c97c41c1b6ab5d69bed5e83c6cc7e5ac22..a3d6f8fc0e986a861b3208651885550c444c9276 100644 (file)
@@ -5,7 +5,7 @@ use std::time::Duration;
 use std::{fs, io};
 
 use lightning::chain::chaininterface::{BroadcasterInterface, ConfirmationTarget, FeeEstimator};
-use lightning::sign::{EntropySource, KeysManager, SpendableOutputDescriptor};
+use lightning::sign::{EntropySource, KeysManager, OutputSpender, SpendableOutputDescriptor};
 use lightning::util::logger::Logger;
 use lightning::util::persist::KVStore;
 use lightning::util::ser::{Readable, WithoutLength, Writeable};
@@ -118,7 +118,7 @@ pub(crate) async fn periodic_sweep(
                                // e.g. high-latency mix networks and some CoinJoin implementations, have
                                // better privacy.
                                // Logic copied from core: https://github.com/bitcoin/bitcoin/blob/1d4846a8443be901b8a5deb0e357481af22838d0/src/wallet/spend.cpp#L936
-                               let mut cur_height = channel_manager.current_best_block().height();
+                               let mut cur_height = channel_manager.current_best_block().height;
 
                                // 10% of the time
                                if thread_rng().gen_range(0, 10) == 0 {