From d8085b1c8309ae3b91d9b67d363fbef342fe0f12 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Fri, 10 Jan 2025 19:55:53 +0000 Subject: [PATCH] Drop use of now-deprecated `create_invoice_from_channelmanager` --- src/cli.rs | 32 ++++++++++---------------------- src/main.rs | 4 ---- 2 files changed, 10 insertions(+), 26 deletions(-) diff --git a/src/cli.rs b/src/cli.rs index ff705b1..169b11e 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -11,8 +11,9 @@ use bitcoin::secp256k1::PublicKey; use lightning::chain::channelmonitor::Balance; use lightning::ln::bolt11_payment::payment_parameters_from_invoice; use lightning::ln::bolt11_payment::payment_parameters_from_variable_amount_invoice; -use lightning::ln::channelmanager::{PaymentId, RecipientOnionFields, Retry}; -use lightning::ln::invoice_utils as utils; +use lightning::ln::channelmanager::{ + Bolt11InvoiceParameters, PaymentId, RecipientOnionFields, Retry +}; use lightning::ln::msgs::SocketAddress; use lightning::ln::types::ChannelId; use lightning::offers::offer::{self, Offer}; @@ -23,7 +24,7 @@ use lightning::types::payment::{PaymentHash, PaymentPreimage}; use lightning::util::config::{ChannelHandshakeConfig, ChannelHandshakeLimits, UserConfig}; use lightning::util::persist::KVStore; use lightning::util::ser::Writeable; -use lightning_invoice::{Bolt11Invoice, Currency}; +use lightning_invoice::Bolt11Invoice; use lightning_persister::fs_store::FilesystemStore; use std::env; use std::io::Write; @@ -50,7 +51,7 @@ pub(crate) fn poll_for_user_input( chain_monitor: Arc, keys_manager: Arc, network_graph: Arc, inbound_payments: Arc>, outbound_payments: Arc>, ldk_data_dir: String, - network: Network, logger: Arc, fs_store: Arc, + fs_store: Arc, ) { println!( "LDK startup successful. Enter \"help\" to view available commands. Press Ctrl-D to quit." @@ -325,10 +326,7 @@ pub(crate) fn poll_for_user_input( amt_msat.unwrap(), &mut inbound_payments, &channel_manager, - Arc::clone(&keys_manager), - network, expiry_secs.unwrap(), - Arc::clone(&logger), ); fs_store .write("", "", INBOUND_PAYMENTS_FNAME, &inbound_payments.encode()) @@ -848,22 +846,12 @@ fn keysend( fn get_invoice( amt_msat: u64, inbound_payments: &mut InboundPaymentInfoStorage, - channel_manager: &ChannelManager, keys_manager: Arc, network: Network, - expiry_secs: u32, logger: Arc, + channel_manager: &ChannelManager, expiry_secs: u32, ) { - let currency = match network { - Network::Bitcoin => Currency::Bitcoin, - Network::Regtest => Currency::Regtest, - Network::Signet => Currency::Signet, - Network::Testnet | _ => Currency::BitcoinTestnet, - }; - let invoice = match utils::create_invoice_from_channelmanager( - channel_manager, - Some(amt_msat), - "ldk-tutorial-node".to_string(), - expiry_secs, - None, - ) { + let mut invoice_params: Bolt11InvoiceParameters = Default::default(); + invoice_params.amount_msats = Some(amt_msat); + invoice_params.invoice_expiry_delta_secs = Some(expiry_secs); + let invoice = match channel_manager.create_bolt11_invoice(invoice_params) { Ok(inv) => { println!("SUCCESS: generated invoice: {}", inv); inv diff --git a/src/main.rs b/src/main.rs index ae2840b..608f36c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1049,7 +1049,6 @@ async fn start_ldk() { // some public channels. let peer_man = Arc::clone(&peer_manager); let chan_man = Arc::clone(&channel_manager); - let network = args.network; tokio::spawn(async move { // First wait a minute until we have some peers and maybe have opened a channel. tokio::time::sleep(Duration::from_secs(60)).await; @@ -1083,7 +1082,6 @@ async fn start_ldk() { let cli_channel_manager = Arc::clone(&channel_manager); let cli_chain_monitor = Arc::clone(&chain_monitor); let cli_persister = Arc::clone(&persister); - let cli_logger = Arc::clone(&logger); let cli_peer_manager = Arc::clone(&peer_manager); let cli_poll = tokio::task::spawn_blocking(move || { cli::poll_for_user_input( @@ -1095,8 +1093,6 @@ async fn start_ldk() { inbound_payments, outbound_payments, ldk_data_dir, - network, - cli_logger, cli_persister, ) });