source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf9ff0bbfd639f15c74af777d81383cf53efb7c93613f6cab67c6c11e05bbf8b"
+[[package]]
+name = "bech32"
+version = "0.9.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "d86b93f97252c47b41663388e6d155714a9d0c398b99f1005cbc5f978b29f445"
+
[[package]]
name = "bitcoin"
-version = "0.28.1"
+version = "0.29.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "05bba324e6baf655b882df672453dbbc527bc938cadd27750ae510aaccc3a66a"
+checksum = "9cb36de3b18ad25f396f9168302e36fb7e1e8923298ab3127da252d288d5af9d"
dependencies = [
- "bech32",
+ "bech32 0.9.1",
"bitcoin_hashes",
"secp256k1",
]
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "754eb4c7f35c031f33c95cc257b4c4192a5c9d3de637d3ee78ab052a3f35da57"
dependencies = [
- "bech32",
+ "bech32 0.8.1",
]
[[package]]
name = "bitcoin_hashes"
-version = "0.10.0"
+version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "006cc91e1a1d99819bc5b8214be3555c1f0611b169f527a1fdc54ed1f2b745b0"
+checksum = "90064b8dee6815a6470d60bad07bbbaee885c0e12d04177138fa3291a01b7bc4"
[[package]]
name = "bytes"
version = "0.1.0"
dependencies = [
"base64",
- "bech32",
+ "bech32 0.8.1",
"bitcoin",
"bitcoin-bech32",
"chrono",
[[package]]
name = "lightning"
-version = "0.0.110"
+version = "0.0.111"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2dce6da860338d5a9ddc3fd42432465310cfab93b342bbd23b41b7c1f7c509d3"
+checksum = "d86c207bcbca1c9dfb3668b81e2ad35b81370e583f2f8c5ee642a9f07925b05e"
dependencies = [
"bitcoin",
]
[[package]]
name = "lightning-background-processor"
-version = "0.0.110"
+version = "0.0.111"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e8de9d0de42bb933ffb8d33c6b0a75302f08b35126bfc74398ba01ad0c201f8d"
+checksum = "0dfef23242b3656fa54a050b5cc4f1f7938d27cbf940c6c9e5b9a08f198f8d86"
dependencies = [
"bitcoin",
"lightning",
[[package]]
name = "lightning-block-sync"
-version = "0.0.110"
+version = "0.0.111"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4cee1ad5df24c87e5d09a655af9d36e12c193961c908b71fd1a5fa39f01cfa0d"
+checksum = "1d1bb816be90f9b182627822ba3ed0b68cbf29315228fe54e4436fe5ad12df25"
dependencies = [
"bitcoin",
"chunked_transfer",
[[package]]
name = "lightning-invoice"
-version = "0.18.0"
+version = "0.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "32aa02b7fd0bd95e40b6ca8d9d9232b162d5e23b41bd2bc42abe9e9c78d34d72"
+checksum = "023d5bd83191e13281b877526efb503a96aaae7ef97c7ba6359ba73f9c1bee11"
dependencies = [
- "bech32",
+ "bech32 0.9.1",
"bitcoin_hashes",
"lightning",
"num-traits",
[[package]]
name = "lightning-net-tokio"
-version = "0.0.110"
+version = "0.0.111"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ce57d093fbc643835bc64c0501b52a3531d2511dcb1237d0495d68fea3adc47d"
+checksum = "1ce3c24e8e3d2c34ec503d3a0f76c07b0f4815705737a6a739058638c774580a"
dependencies = [
"bitcoin",
"lightning",
[[package]]
name = "lightning-persister"
-version = "0.0.110"
+version = "0.0.111"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9abe8137de42431ed344f64821c12cf02f934c7869f5f8febaa1b3cb851e1fc1"
+checksum = "235c5419f4f1b699176f51709317c88651c6bcfe3104be87294e1b0ba11a16af"
dependencies = [
"bitcoin",
"libc",
[[package]]
name = "lightning-rapid-gossip-sync"
-version = "0.0.110"
+version = "0.0.111"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "391732631b14f7a1d9dc84dc3f644484d9b73190a31087b3856505cf0525bea0"
+checksum = "ff55ab0918a12e5eecf511a0ae924340361dd64213139af689da51c0759f59b8"
dependencies = [
"bitcoin",
"lightning",
[[package]]
name = "secp256k1"
-version = "0.22.1"
+version = "0.24.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "26947345339603ae8395f68e2f3d85a6b0a8ddfe6315818e80b8504415099db0"
+checksum = "b7649a0b3ffb32636e60c7ce0d70511eda9c52c658cd0634e194d5a19943aeff"
dependencies = [
+ "bitcoin_hashes",
"secp256k1-sys",
]
[[package]]
name = "secp256k1-sys"
-version = "0.5.2"
+version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "152e20a0fd0519390fc43ab404663af8a0b794273d2a91d60ad4a39f13ffe110"
+checksum = "7058dc8eaf3f2810d7828680320acda0b25a288f6d288e19278e249bbf74226b"
dependencies = [
"cc",
]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
-lightning = { version = "0.0.110", features = ["max_level_trace"] }
-lightning-block-sync = { version = "0.0.110", features = [ "rpc-client" ] }
-lightning-invoice = { version = "0.18" }
-lightning-net-tokio = { version = "0.0.110" }
-lightning-persister = { version = "0.0.110" }
-lightning-background-processor = { version = "0.0.110" }
-lightning-rapid-gossip-sync = { version = "0.0.110" }
+lightning = { version = "0.0.111", features = ["max_level_trace"] }
+lightning-block-sync = { version = "0.0.111", features = [ "rpc-client" ] }
+lightning-invoice = { version = "0.19" }
+lightning-net-tokio = { version = "0.0.111" }
+lightning-persister = { version = "0.0.111" }
+lightning-background-processor = { version = "0.0.111" }
+lightning-rapid-gossip-sync = { version = "0.0.111" }
base64 = "0.13.0"
-bitcoin = "0.28.1"
+bitcoin = "0.29.0"
bitcoin-bech32 = "0.12"
bech32 = "0.8"
hex = "0.3"
use crate::disk;
use crate::hex_utils;
use crate::{
- ChannelManager, HTLCStatus, InvoicePayer, MillisatAmount, NetworkGraph, PaymentInfo,
- PaymentInfoStorage, PeerManager,
+ ChannelManager, HTLCStatus, InvoicePayer, MillisatAmount, NetworkGraph, OnionMessenger,
+ PaymentInfo, PaymentInfoStorage, PeerManager,
};
use bitcoin::hashes::sha256::Hash as Sha256;
use bitcoin::hashes::Hash;
use lightning::chain::keysinterface::{KeysInterface, KeysManager, Recipient};
use lightning::ln::msgs::NetAddress;
use lightning::ln::{PaymentHash, PaymentPreimage};
+use lightning::onion_message::Destination;
use lightning::routing::gossip::NodeId;
use lightning::util::config::{ChannelHandshakeConfig, ChannelHandshakeLimits, UserConfig};
use lightning::util::events::EventHandler;
pub(crate) async fn poll_for_user_input<E: EventHandler>(
invoice_payer: Arc<InvoicePayer<E>>, peer_manager: Arc<PeerManager>,
channel_manager: Arc<ChannelManager>, keys_manager: Arc<KeysManager>,
- network_graph: Arc<NetworkGraph>, inbound_payments: PaymentInfoStorage,
- outbound_payments: PaymentInfoStorage, ldk_data_dir: String, network: Network,
+ network_graph: Arc<NetworkGraph>, onion_messenger: Arc<OnionMessenger>,
+ inbound_payments: PaymentInfoStorage, outbound_payments: PaymentInfoStorage,
+ ldk_data_dir: String, 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");
)
);
}
+ "sendonionmessage" => {
+ let path_pks_str = words.next();
+ if path_pks_str.is_none() {
+ println!(
+ "ERROR: sendonionmessage requires at least one node id for the path"
+ );
+ continue;
+ }
+ let mut node_pks = Vec::new();
+ let mut errored = false;
+ for pk_str in path_pks_str.unwrap().split(",") {
+ let node_pubkey_vec = match hex_utils::to_vec(pk_str) {
+ Some(peer_pubkey_vec) => peer_pubkey_vec,
+ None => {
+ println!("ERROR: couldn't parse peer_pubkey");
+ errored = true;
+ break;
+ }
+ };
+ let node_pubkey = match PublicKey::from_slice(&node_pubkey_vec) {
+ Ok(peer_pubkey) => peer_pubkey,
+ Err(_) => {
+ println!("ERROR: couldn't parse peer_pubkey");
+ errored = true;
+ break;
+ }
+ };
+ node_pks.push(node_pubkey);
+ }
+ if errored {
+ continue;
+ }
+ let destination_pk = node_pks.pop().unwrap();
+ match onion_messenger.send_onion_message(
+ &node_pks,
+ Destination::Node(destination_pk),
+ None,
+ ) {
+ Ok(()) => println!("SUCCESS: forwarded onion message to first hop"),
+ Err(e) => println!("ERROR: failed to send onion message: {:?}", e),
+ }
+ }
_ => println!("Unknown command. See `\"help\" for available commands."),
}
}
println!("nodeinfo");
println!("listpeers");
println!("signmessage <message>");
+ println!("sendonionmessage <node_id_1,node_id_2,..,destination_node_id>");
}
fn node_info(channel_manager: &Arc<ChannelManager>, peer_manager: &Arc<PeerManager>) {
};
use lightning::ln::peer_handler::{IgnoringMessageHandler, MessageHandler, SimpleArcPeerManager};
use lightning::ln::{PaymentHash, PaymentPreimage, PaymentSecret};
+use lightning::onion_message::SimpleArcOnionMessenger;
use lightning::routing::gossip;
use lightning::routing::gossip::{NodeId, P2PGossipSync};
use lightning::routing::scoring::ProbabilisticScorer;
pub(crate) type NetworkGraph = gossip::NetworkGraph<Arc<FilesystemLogger>>;
+type OnionMessenger = SimpleArcOnionMessenger<FilesystemLogger>;
+
async fn handle_ldk_events(
channel_manager: &Arc<ChannelManager>, bitcoind_client: &BitcoindClient,
network_graph: &NetworkGraph, keys_manager: &KeysManager,
// Step 12: Initialize the PeerManager
let channel_manager: Arc<ChannelManager> = Arc::new(channel_manager);
+ let onion_messenger: Arc<OnionMessenger> =
+ Arc::new(OnionMessenger::new(keys_manager.clone(), logger.clone()));
let mut ephemeral_bytes = [0; 32];
+ let current_time = SystemTime::now().duration_since(SystemTime::UNIX_EPOCH).unwrap().as_secs();
rand::thread_rng().fill_bytes(&mut ephemeral_bytes);
let lightning_msg_handler = MessageHandler {
chan_handler: channel_manager.clone(),
route_handler: gossip_sync.clone(),
+ onion_message_handler: onion_messenger.clone(),
};
let peer_manager: Arc<PeerManager> = Arc::new(PeerManager::new(
lightning_msg_handler,
keys_manager.get_node_secret(Recipient::Node).unwrap(),
+ current_time,
&ephemeral_bytes,
logger.clone(),
- Arc::new(IgnoringMessageHandler {}),
+ IgnoringMessageHandler {},
));
// ## Running LDK
// some public channels, and is only useful if we have public listen address(es) to announce.
// In a production environment, this should occur only after the announcement of new channels
// to avoid churn in the global network graph.
- let chan_manager = Arc::clone(&channel_manager);
+ let peer_man = Arc::clone(&peer_manager);
let network = args.network;
if !args.ldk_announced_listen_addr.is_empty() {
tokio::spawn(async move {
let mut interval = tokio::time::interval(Duration::from_secs(60));
loop {
interval.tick().await;
- chan_manager.broadcast_node_announcement(
+ peer_man.broadcast_node_announcement(
[0; 3],
args.ldk_announced_node_name,
args.ldk_announced_listen_addr.clone(),
Arc::clone(&channel_manager),
Arc::clone(&keys_manager),
Arc::clone(&network_graph),
+ Arc::clone(&onion_messenger),
inbound_payments,
outbound_payments,
ldk_data_dir.clone(),