use lightning::ln::{PaymentHash, PaymentSecret};
use lightning::routing::network_graph::NetGraphMsgHandler;
use lightning::routing::router;
-use lightning::routing::router::RouteHintHop;
+use lightning::routing::router::RouteHint;
use lightning::util::config::UserConfig;
use lightning_invoice::{utils, Currency, Invoice};
use std::env;
use std::str::FromStr;
use std::sync::Arc;
use std::time::Duration;
-use tokio::sync::mpsc;
pub(crate) struct LdkUserInfo {
pub(crate) bitcoind_rpc_username: String,
keys_manager: Arc<KeysManager>,
router: Arc<NetGraphMsgHandler<Arc<dyn chain::Access + Send + Sync>, Arc<FilesystemLogger>>>,
inbound_payments: PaymentInfoStorage, outbound_payments: PaymentInfoStorage,
- event_notifier: mpsc::Sender<()>, ldk_data_dir: String, logger: Arc<FilesystemLogger>,
- network: Network,
+ ldk_data_dir: String, logger: Arc<FilesystemLogger>, network: Network,
) {
println!("LDK startup successful. To view available commands: \"help\".");
println!("LDK logs are available at <your-supplied-ldk-data-dir-path>/.ldk/logs");
print!("> ");
io::stdout().flush().unwrap(); // Without flushing, the `>` doesn't print
for line in stdin.lock().lines() {
- let _ = event_notifier.try_send(());
let line = line.unwrap();
let mut words = line.split_whitespace();
if let Some(word) = words.next() {
continue;
}
- if connect_peer_if_necessary(
- pubkey,
- peer_addr,
- peer_manager.clone(),
- event_notifier.clone(),
- )
- .await
- .is_err()
+ if connect_peer_if_necessary(pubkey, peer_addr, peer_manager.clone())
+ .await
+ .is_err()
{
print!("> ");
io::stdout().flush().unwrap();
continue;
}
};
- let mut route_hints = invoice.routes().clone();
- let mut last_hops = Vec::new();
- for hint in route_hints.drain(..) {
- last_hops.push(hint[hint.len() - 1].clone());
- }
+ let last_hops = invoice.route_hints();
let amt_pico_btc = invoice.amount_pico_btc();
if amt_pico_btc.is_none() {
continue;
}
};
- if connect_peer_if_necessary(
- pubkey,
- peer_addr,
- peer_manager.clone(),
- event_notifier.clone(),
- )
- .await
- .is_ok()
+ if connect_peer_if_necessary(pubkey, peer_addr, peer_manager.clone())
+ .await
+ .is_ok()
{
println!("SUCCESS: connected to peer {}", pubkey);
}
pub(crate) async fn connect_peer_if_necessary(
pubkey: PublicKey, peer_addr: SocketAddr, peer_manager: Arc<PeerManager>,
- event_notifier: mpsc::Sender<()>,
) -> Result<(), ()> {
for node_pubkey in peer_manager.get_peer_node_ids() {
if node_pubkey == pubkey {
return Ok(());
}
}
- match lightning_net_tokio::connect_outbound(
- Arc::clone(&peer_manager),
- event_notifier,
- pubkey,
- peer_addr,
- )
- .await
+ match lightning_net_tokio::connect_outbound(Arc::clone(&peer_manager), pubkey, peer_addr).await
{
Some(conn_closed_fut) => {
let mut closed_fut_box = Box::pin(conn_closed_fut);
fn send_payment(
payee: PublicKey, amt_msat: u64, final_cltv: u32, payment_hash: PaymentHash,
payment_secret: Option<PaymentSecret>, payee_features: Option<InvoiceFeatures>,
- route_hints: Vec<RouteHintHop>,
+ route_hints: Vec<&RouteHint>,
router: Arc<NetGraphMsgHandler<Arc<dyn chain::Access + Send + Sync>, Arc<FilesystemLogger>>>,
channel_manager: Arc<ChannelManager>, payment_storage: PaymentInfoStorage,
logger: Arc<FilesystemLogger>,
&payee,
payee_features,
Some(&first_hops.iter().collect::<Vec<_>>()),
- &route_hints.iter().collect::<Vec<_>>(),
+ &route_hints,
amt_msat,
final_cltv,
logger,
if peer_addr_str.is_none() || peer_addr_str.is_none() {
return Err(std::io::Error::new(
std::io::ErrorKind::Other,
- "ERROR: incorrectly formatted peer
- info. Should be formatted as: `pubkey@host:port`",
+ "ERROR: incorrectly formatted peer info. Should be formatted as: `pubkey@host:port`",
));
}