@@ -210,7 +210,7 @@ where
210210/// # Ok(OnionMessagePath {
211211/// # intermediate_nodes: vec![hop_node_id1, hop_node_id2],
212212/// # destination,
213- /// # first_node_addresses: None ,
213+ /// # first_node_addresses: Vec::new() ,
214214/// # })
215215/// # }
216216/// # fn create_blinded_paths<T: secp256k1::Signing + secp256k1::Verification>(
@@ -681,7 +681,7 @@ where
681681 Ok ( OnionMessagePath {
682682 intermediate_nodes : vec ! [ ] ,
683683 destination,
684- first_node_addresses : None ,
684+ first_node_addresses : vec ! [ ] ,
685685 } )
686686 } else {
687687 let node_details = network_graph
@@ -695,11 +695,19 @@ where
695695 Some ( ( features, addresses) )
696696 if features. supports_onion_messages ( ) && addresses. len ( ) > 0 =>
697697 {
698- let first_node_addresses = Some ( addresses. to_vec ( ) ) ;
699698 Ok ( OnionMessagePath {
700699 intermediate_nodes : vec ! [ ] ,
701700 destination,
702- first_node_addresses,
701+ first_node_addresses : addresses. to_vec ( ) ,
702+ } )
703+ } ,
704+ None => {
705+ // If the destination is an unannounced node, they may be a known peer that is offline and
706+ // can be woken by the sender.
707+ Ok ( OnionMessagePath {
708+ intermediate_nodes : vec ! [ ] ,
709+ destination,
710+ first_node_addresses : vec ! [ ] ,
703711 } )
704712 } ,
705713 _ => Err ( ( ) ) ,
@@ -841,9 +849,9 @@ pub struct OnionMessagePath {
841849
842850 /// Addresses that may be used to connect to [`OnionMessagePath::first_node`].
843851 ///
844- /// Only needs to be set if a connection to the node is required. [`OnionMessenger`] may use
845- /// this to initiate such a connection.
846- pub first_node_addresses : Option < Vec < SocketAddress > > ,
852+ /// Only needs to be filled in if a connection to the node is required and it is not a known peer.
853+ /// [`OnionMessenger`] may use this to initiate such a connection.
854+ pub first_node_addresses : Vec < SocketAddress > ,
847855}
848856
849857impl OnionMessagePath {
@@ -1021,7 +1029,7 @@ pub fn create_onion_message_resolving_destination<
10211029 entropy_source : & ES , node_signer : & NS , node_id_lookup : & NL ,
10221030 network_graph : & ReadOnlyNetworkGraph , secp_ctx : & Secp256k1 < secp256k1:: All > ,
10231031 mut path : OnionMessagePath , contents : T , reply_path : Option < BlindedMessagePath > ,
1024- ) -> Result < ( PublicKey , OnionMessage , Option < Vec < SocketAddress > > ) , SendError >
1032+ ) -> Result < ( PublicKey , OnionMessage , Vec < SocketAddress > ) , SendError >
10251033where
10261034 ES :: Target : EntropySource ,
10271035 NS :: Target : NodeSigner ,
@@ -1054,7 +1062,7 @@ pub fn create_onion_message<ES: Deref, NS: Deref, NL: Deref, T: OnionMessageCont
10541062 entropy_source : & ES , node_signer : & NS , node_id_lookup : & NL ,
10551063 secp_ctx : & Secp256k1 < secp256k1:: All > , path : OnionMessagePath , contents : T ,
10561064 reply_path : Option < BlindedMessagePath > ,
1057- ) -> Result < ( PublicKey , OnionMessage , Option < Vec < SocketAddress > > ) , SendError >
1065+ ) -> Result < ( PublicKey , OnionMessage , Vec < SocketAddress > ) , SendError >
10581066where
10591067 ES :: Target : EntropySource ,
10601068 NS :: Target : NodeSigner ,
@@ -1515,7 +1523,7 @@ where
15151523 // If this onion message is being treated as a forward, we shouldn't pathfind to the next hop.
15161524 OnionMessagePath {
15171525 intermediate_nodes : Vec :: new ( ) ,
1518- first_node_addresses : None ,
1526+ first_node_addresses : Vec :: new ( ) ,
15191527 destination,
15201528 }
15211529 } else {
@@ -1633,23 +1641,19 @@ where
16331641 }
16341642
16351643 fn enqueue_outbound_onion_message (
1636- & self , onion_message : OnionMessage , first_node_id : PublicKey ,
1637- addresses : Option < Vec < SocketAddress > > ,
1644+ & self , onion_message : OnionMessage , first_node_id : PublicKey , addresses : Vec < SocketAddress > ,
16381645 ) -> Result < SendSuccess , SendError > {
16391646 let mut message_recipients = self . message_recipients . lock ( ) . unwrap ( ) ;
16401647 if outbound_buffer_full ( & first_node_id, & message_recipients) {
16411648 return Err ( SendError :: BufferFull ) ;
16421649 }
16431650
16441651 match message_recipients. entry ( first_node_id) {
1645- hash_map:: Entry :: Vacant ( e) => match addresses {
1646- None => Err ( SendError :: InvalidFirstHop ( first_node_id) ) ,
1647- Some ( addresses) => {
1648- e. insert ( OnionMessageRecipient :: pending_connection ( addresses) )
1649- . enqueue_message ( onion_message) ;
1650- self . event_notifier . notify ( ) ;
1651- Ok ( SendSuccess :: BufferedAwaitingConnection ( first_node_id) )
1652- } ,
1652+ hash_map:: Entry :: Vacant ( e) => {
1653+ e. insert ( OnionMessageRecipient :: pending_connection ( addresses) )
1654+ . enqueue_message ( onion_message) ;
1655+ self . event_notifier . notify ( ) ;
1656+ Ok ( SendSuccess :: BufferedAwaitingConnection ( first_node_id) )
16531657 } ,
16541658 hash_map:: Entry :: Occupied ( mut e) => {
16551659 e. get_mut ( ) . enqueue_message ( onion_message) ;
0 commit comments