Skip to content

Commit

Permalink
Drop use of now-deprecated create_invoice_from_channelmanager
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBlueMatt committed Jan 10, 2025
1 parent ceba92d commit 5c2a151
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 26 deletions.
30 changes: 8 additions & 22 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ 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};
Expand All @@ -23,7 +22,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;
Expand All @@ -50,7 +49,7 @@ pub(crate) fn poll_for_user_input(
chain_monitor: Arc<ChainMonitor>, keys_manager: Arc<KeysManager>,
network_graph: Arc<NetworkGraph>, inbound_payments: Arc<Mutex<InboundPaymentInfoStorage>>,
outbound_payments: Arc<Mutex<OutboundPaymentInfoStorage>>, ldk_data_dir: String,
network: Network, logger: Arc<disk::FilesystemLogger>, fs_store: Arc<FilesystemStore>,
fs_store: Arc<FilesystemStore>,
) {
println!(
"LDK startup successful. Enter \"help\" to view available commands. Press Ctrl-D to quit."
Expand Down Expand Up @@ -325,10 +324,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())
Expand Down Expand Up @@ -848,22 +844,12 @@ fn keysend<E: EntropySource>(

fn get_invoice(
amt_msat: u64, inbound_payments: &mut InboundPaymentInfoStorage,
channel_manager: &ChannelManager, keys_manager: Arc<KeysManager>, network: Network,
expiry_secs: u32, logger: Arc<disk::FilesystemLogger>,
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
Expand Down
4 changes: 0 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1059,7 +1059,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;
Expand Down Expand Up @@ -1093,7 +1092,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(
Expand All @@ -1105,8 +1103,6 @@ async fn start_ldk() {
inbound_payments,
outbound_payments,
ldk_data_dir,
network,
cli_logger,
cli_persister,
)
});
Expand Down

0 comments on commit 5c2a151

Please sign in to comment.