Add BlindedPath::introduction_node_id method
[rust-lightning] / lightning / src / blinded_path / mod.rs
index e70f310f5e1d8b00875ff58e069f432bd69526cf..5d199269520e16c9c79464a01a86a2d55b098d8b 100644 (file)
@@ -17,6 +17,7 @@ use bitcoin::secp256k1::{self, PublicKey, Secp256k1, SecretKey};
 
 use crate::ln::msgs::DecodeError;
 use crate::offers::invoice::BlindedPayInfo;
+use crate::routing::gossip::{NodeId, ReadOnlyNetworkGraph};
 use crate::sign::EntropySource;
 use crate::util::ser::{Readable, Writeable, Writer};
 
@@ -125,6 +126,14 @@ impl BlindedPath {
                        ).map_err(|_| ())?,
                }))
        }
+
+       /// Returns the introduction [`NodeId`] of the blinded path.
+       pub fn public_introduction_node_id<'a>(
+               &self, network_graph: &'a ReadOnlyNetworkGraph
+       ) -> Option<&'a NodeId> {
+               let node_id = NodeId::from_pubkey(&self.introduction_node_id);
+               network_graph.nodes().get_key_value(&node_id).map(|(key, _)| key)
+       }
 }
 
 impl Writeable for BlindedPath {