Skip to content

Commit 6d171e0

Browse files
committed
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.
1 parent eb7ba30 commit 6d171e0

File tree

1 file changed

+0
-81
lines changed

1 file changed

+0
-81
lines changed

src/cli.rs

Lines changed: 0 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ use lightning::ln::channelmanager::{PaymentId, RecipientOnionFields, Retry};
1212
use lightning::ln::msgs::SocketAddress;
1313
use lightning::ln::{ChannelId, PaymentHash, PaymentPreimage};
1414
use lightning::offers::offer::{self, Offer};
15-
use lightning::onion_message::messenger::Destination;
16-
use lightning::onion_message::packet::OnionMessageContents;
1715
use lightning::routing::gossip::NodeId;
1816
use lightning::routing::router::{PaymentParameters, RouteParameters};
1917
use lightning::sign::{EntropySource, KeysManager};
@@ -45,24 +43,6 @@ pub(crate) struct LdkUserInfo {
4543
pub(crate) network: Network,
4644
}
4745

48-
#[derive(Debug)]
49-
struct UserOnionMessageContents {
50-
tlv_type: u64,
51-
data: Vec<u8>,
52-
}
53-
54-
impl OnionMessageContents for UserOnionMessageContents {
55-
fn tlv_type(&self) -> u64 {
56-
self.tlv_type
57-
}
58-
}
59-
60-
impl Writeable for UserOnionMessageContents {
61-
fn write<W: Writer>(&self, w: &mut W) -> Result<(), std::io::Error> {
62-
w.write_all(&self.data)
63-
}
64-
}
65-
6646
pub(crate) fn poll_for_user_input(
6747
peer_manager: Arc<PeerManager>, channel_manager: Arc<ChannelManager>,
6848
keys_manager: Arc<KeysManager>, network_graph: Arc<NetworkGraph>,
@@ -496,64 +476,6 @@ pub(crate) fn poll_for_user_input(
496476
)
497477
);
498478
},
499-
"sendonionmessage" => {
500-
let path_pks_str = words.next();
501-
if path_pks_str.is_none() {
502-
println!(
503-
"ERROR: sendonionmessage requires at least one node id for the path"
504-
);
505-
continue;
506-
}
507-
let mut intermediate_nodes = Vec::new();
508-
let mut errored = false;
509-
for pk_str in path_pks_str.unwrap().split(",") {
510-
let node_pubkey_vec = match hex_utils::to_vec(pk_str) {
511-
Some(peer_pubkey_vec) => peer_pubkey_vec,
512-
None => {
513-
println!("ERROR: couldn't parse peer_pubkey");
514-
errored = true;
515-
break;
516-
},
517-
};
518-
let node_pubkey = match PublicKey::from_slice(&node_pubkey_vec) {
519-
Ok(peer_pubkey) => peer_pubkey,
520-
Err(_) => {
521-
println!("ERROR: couldn't parse peer_pubkey");
522-
errored = true;
523-
break;
524-
},
525-
};
526-
intermediate_nodes.push(node_pubkey);
527-
}
528-
if errored {
529-
continue;
530-
}
531-
let tlv_type = match words.next().map(|ty_str| ty_str.parse()) {
532-
Some(Ok(ty)) if ty >= 64 => ty,
533-
_ => {
534-
println!("Need an integral message type above 64");
535-
continue;
536-
},
537-
};
538-
let data = match words.next().map(|s| hex_utils::to_vec(s)) {
539-
Some(Some(data)) => data,
540-
_ => {
541-
println!("Need a hex data string");
542-
continue;
543-
},
544-
};
545-
let destination = Destination::Node(intermediate_nodes.pop().unwrap());
546-
match onion_messenger.send_onion_message(
547-
UserOnionMessageContents { tlv_type, data },
548-
destination,
549-
None,
550-
) {
551-
Ok(success) => {
552-
println!("SUCCESS: forwarded onion message to first hop {:?}", success)
553-
},
554-
Err(e) => println!("ERROR: failed to send onion message: {:?}", e),
555-
}
556-
},
557479
"quit" | "exit" => break,
558480
_ => println!("Unknown command. See `\"help\" for available commands."),
559481
}
@@ -589,9 +511,6 @@ fn help() {
589511
println!(" getoffer [<amt_msats>]");
590512
println!("\n Other:");
591513
println!(" signmessage <message>");
592-
println!(
593-
" sendonionmessage <node_id_1,node_id_2,..,destination_node_id> <type> <hex_bytes>"
594-
);
595514
println!(" nodeinfo");
596515
}
597516

0 commit comments

Comments
 (0)