From 6d171e062614029898d3289a92e77b36a74b1610 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Mon, 14 Oct 2024 00:27:14 +0000 Subject: [PATCH] Drop `sendonionmessage` custom message sending command Onion messages are now useful for various things so having a demo use for them isn't all that interesting anymore. --- src/cli.rs | 81 ------------------------------------------------------ 1 file changed, 81 deletions(-) diff --git a/src/cli.rs b/src/cli.rs index 4d64d89..902e652 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -12,8 +12,6 @@ use lightning::ln::channelmanager::{PaymentId, RecipientOnionFields, Retry}; use lightning::ln::msgs::SocketAddress; use lightning::ln::{ChannelId, PaymentHash, PaymentPreimage}; use lightning::offers::offer::{self, Offer}; -use lightning::onion_message::messenger::Destination; -use lightning::onion_message::packet::OnionMessageContents; use lightning::routing::gossip::NodeId; use lightning::routing::router::{PaymentParameters, RouteParameters}; use lightning::sign::{EntropySource, KeysManager}; @@ -45,24 +43,6 @@ pub(crate) struct LdkUserInfo { pub(crate) network: Network, } -#[derive(Debug)] -struct UserOnionMessageContents { - tlv_type: u64, - data: Vec, -} - -impl OnionMessageContents for UserOnionMessageContents { - fn tlv_type(&self) -> u64 { - self.tlv_type - } -} - -impl Writeable for UserOnionMessageContents { - fn write(&self, w: &mut W) -> Result<(), std::io::Error> { - w.write_all(&self.data) - } -} - pub(crate) fn poll_for_user_input( peer_manager: Arc, channel_manager: Arc, keys_manager: Arc, network_graph: Arc, @@ -496,64 +476,6 @@ pub(crate) fn poll_for_user_input( ) ); }, - "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 intermediate_nodes = 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; - }, - }; - intermediate_nodes.push(node_pubkey); - } - if errored { - continue; - } - let tlv_type = match words.next().map(|ty_str| ty_str.parse()) { - Some(Ok(ty)) if ty >= 64 => ty, - _ => { - println!("Need an integral message type above 64"); - continue; - }, - }; - let data = match words.next().map(|s| hex_utils::to_vec(s)) { - Some(Some(data)) => data, - _ => { - println!("Need a hex data string"); - continue; - }, - }; - let destination = Destination::Node(intermediate_nodes.pop().unwrap()); - match onion_messenger.send_onion_message( - UserOnionMessageContents { tlv_type, data }, - destination, - None, - ) { - Ok(success) => { - println!("SUCCESS: forwarded onion message to first hop {:?}", success) - }, - Err(e) => println!("ERROR: failed to send onion message: {:?}", e), - } - }, "quit" | "exit" => break, _ => println!("Unknown command. See `\"help\" for available commands."), } @@ -589,9 +511,6 @@ fn help() { println!(" getoffer []"); println!("\n Other:"); println!(" signmessage "); - println!( - " sendonionmessage " - ); println!(" nodeinfo"); }