@@ -210,7 +210,7 @@ where
210
210
/// # Ok(OnionMessagePath {
211
211
/// # intermediate_nodes: vec![hop_node_id1, hop_node_id2],
212
212
/// # destination,
213
- /// # first_node_addresses: None ,
213
+ /// # first_node_addresses: Vec::new() ,
214
214
/// # })
215
215
/// # }
216
216
/// # fn create_blinded_paths<T: secp256k1::Signing + secp256k1::Verification>(
@@ -681,7 +681,7 @@ where
681
681
Ok ( OnionMessagePath {
682
682
intermediate_nodes : vec ! [ ] ,
683
683
destination,
684
- first_node_addresses : None ,
684
+ first_node_addresses : vec ! [ ] ,
685
685
} )
686
686
} else {
687
687
let node_details = network_graph
@@ -695,11 +695,19 @@ where
695
695
Some ( ( features, addresses) )
696
696
if features. supports_onion_messages ( ) && addresses. len ( ) > 0 =>
697
697
{
698
- let first_node_addresses = Some ( addresses. to_vec ( ) ) ;
699
698
Ok ( OnionMessagePath {
700
699
intermediate_nodes : vec ! [ ] ,
701
700
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 ! [ ] ,
703
711
} )
704
712
} ,
705
713
_ => Err ( ( ) ) ,
@@ -841,9 +849,9 @@ pub struct OnionMessagePath {
841
849
842
850
/// Addresses that may be used to connect to [`OnionMessagePath::first_node`].
843
851
///
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 > ,
847
855
}
848
856
849
857
impl OnionMessagePath {
@@ -1021,7 +1029,7 @@ pub fn create_onion_message_resolving_destination<
1021
1029
entropy_source : & ES , node_signer : & NS , node_id_lookup : & NL ,
1022
1030
network_graph : & ReadOnlyNetworkGraph , secp_ctx : & Secp256k1 < secp256k1:: All > ,
1023
1031
mut path : OnionMessagePath , contents : T , reply_path : Option < BlindedMessagePath > ,
1024
- ) -> Result < ( PublicKey , OnionMessage , Option < Vec < SocketAddress > > ) , SendError >
1032
+ ) -> Result < ( PublicKey , OnionMessage , Vec < SocketAddress > ) , SendError >
1025
1033
where
1026
1034
ES :: Target : EntropySource ,
1027
1035
NS :: Target : NodeSigner ,
@@ -1054,7 +1062,7 @@ pub fn create_onion_message<ES: Deref, NS: Deref, NL: Deref, T: OnionMessageCont
1054
1062
entropy_source : & ES , node_signer : & NS , node_id_lookup : & NL ,
1055
1063
secp_ctx : & Secp256k1 < secp256k1:: All > , path : OnionMessagePath , contents : T ,
1056
1064
reply_path : Option < BlindedMessagePath > ,
1057
- ) -> Result < ( PublicKey , OnionMessage , Option < Vec < SocketAddress > > ) , SendError >
1065
+ ) -> Result < ( PublicKey , OnionMessage , Vec < SocketAddress > ) , SendError >
1058
1066
where
1059
1067
ES :: Target : EntropySource ,
1060
1068
NS :: Target : NodeSigner ,
@@ -1515,7 +1523,7 @@ where
1515
1523
// If this onion message is being treated as a forward, we shouldn't pathfind to the next hop.
1516
1524
OnionMessagePath {
1517
1525
intermediate_nodes : Vec :: new ( ) ,
1518
- first_node_addresses : None ,
1526
+ first_node_addresses : Vec :: new ( ) ,
1519
1527
destination,
1520
1528
}
1521
1529
} else {
@@ -1633,23 +1641,19 @@ where
1633
1641
}
1634
1642
1635
1643
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 > ,
1638
1645
) -> Result < SendSuccess , SendError > {
1639
1646
let mut message_recipients = self . message_recipients . lock ( ) . unwrap ( ) ;
1640
1647
if outbound_buffer_full ( & first_node_id, & message_recipients) {
1641
1648
return Err ( SendError :: BufferFull ) ;
1642
1649
}
1643
1650
1644
1651
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) )
1653
1657
} ,
1654
1658
hash_map:: Entry :: Occupied ( mut e) => {
1655
1659
e. get_mut ( ) . enqueue_message ( onion_message) ;
0 commit comments