Skip to content

Commit 80d6250

Browse files
committed
f - reuse public_introduction_node_id
1 parent e0607b0 commit 80d6250

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

lightning/src/onion_message/messenger.rs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use bitcoin::hashes::hmac::{Hmac, HmacEngine};
1515
use bitcoin::hashes::sha256::Hash as Sha256;
1616
use bitcoin::secp256k1::{self, PublicKey, Scalar, Secp256k1, SecretKey};
1717

18-
use crate::blinded_path::{BlindedPath, Direction, IntroductionNode};
18+
use crate::blinded_path::{BlindedPath, IntroductionNode};
1919
use crate::blinded_path::message::{advance_path_by_one, ForwardTlvs, NextHop, ReceiveTlvs};
2020
use crate::blinded_path::utils;
2121
use crate::events::{Event, EventHandler, EventsProvider};
@@ -445,17 +445,12 @@ impl Destination {
445445
/// provided [`ReadOnlyNetworkGraph`].
446446
pub fn resolve(&mut self, network_graph: &ReadOnlyNetworkGraph) {
447447
if let Destination::BlindedPath(path) = self {
448-
let introduction_node = &mut path.introduction_node;
449-
if let IntroductionNode::DirectedShortChannelId(direction, scid) = introduction_node {
450-
let pubkey = network_graph
451-
.channel(*scid)
452-
.map(|c| match direction {
453-
Direction::NodeOne => c.node_one,
454-
Direction::NodeTwo => c.node_two,
455-
})
456-
.and_then(|node_id| node_id.as_pubkey().ok());
457-
if let Some(pubkey) = pubkey {
458-
*introduction_node = IntroductionNode::NodeId(pubkey);
448+
if let IntroductionNode::DirectedShortChannelId(..) = path.introduction_node {
449+
if let Some(pubkey) = path
450+
.public_introduction_node_id(network_graph)
451+
.and_then(|node_id| node_id.as_pubkey().ok())
452+
{
453+
path.introduction_node = IntroductionNode::NodeId(pubkey);
459454
}
460455
}
461456
}

0 commit comments

Comments
 (0)