From: Valentine Wallace Date: Fri, 9 Aug 2024 19:19:12 +0000 (-0700) Subject: Move NextMessageHop into blinded_path::message X-Git-Tag: v0.0.124-beta~10^2~2 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=55de90af934d95439bae7bd8a6ae502ade4cb9d4;p=rust-lightning Move NextMessageHop into blinded_path::message It's only used for onion messages, not payments. --- diff --git a/lightning/src/blinded_path/message.rs b/lightning/src/blinded_path/message.rs index c48e5d3cc..cbb4a8bbf 100644 --- a/lightning/src/blinded_path/message.rs +++ b/lightning/src/blinded_path/message.rs @@ -16,7 +16,7 @@ use crate::prelude::*; use bitcoin::hashes::hmac::Hmac; use bitcoin::hashes::sha256::Hash as Sha256; -use crate::blinded_path::{BlindedHop, BlindedPath, Direction, IntroductionNode, NextMessageHop, NodeIdLookUp}; +use crate::blinded_path::{BlindedHop, BlindedPath, Direction, IntroductionNode, NodeIdLookUp}; use crate::blinded_path::utils; use crate::io; use crate::io::Cursor; @@ -159,6 +159,17 @@ impl BlindedMessagePath { } } +/// The next hop to forward an onion message along its path. +/// +/// Note that payment blinded paths always specify their next hop using an explicit node id. +#[derive(Clone, Debug, Hash, PartialEq, Eq)] +pub enum NextMessageHop { + /// The node id of the next hop. + NodeId(PublicKey), + /// The short channel id leading to the next hop. + ShortChannelId(u64), +} + /// An intermediate node, and possibly a short channel id leading to the next node. #[derive(Clone, Copy, Debug, Hash, PartialEq, Eq)] pub struct ForwardNode { diff --git a/lightning/src/blinded_path/mod.rs b/lightning/src/blinded_path/mod.rs index 08a30f589..6a278b7fd 100644 --- a/lightning/src/blinded_path/mod.rs +++ b/lightning/src/blinded_path/mod.rs @@ -23,17 +23,6 @@ use crate::util::ser::{Readable, Writeable, Writer}; use crate::io; use crate::prelude::*; -/// The next hop to forward an onion message along its path. -/// -/// Note that payment blinded paths always specify their next hop using an explicit node id. -#[derive(Clone, Debug, Hash, PartialEq, Eq)] -pub enum NextMessageHop { - /// The node id of the next hop. - NodeId(PublicKey), - /// The short channel id leading to the next hop. - ShortChannelId(u64), -} - /// Onion messages and payments can be sent and received to blinded paths, which serve to hide the /// identity of the recipient. #[derive(Clone, Debug, Hash, PartialEq, Eq)] diff --git a/lightning/src/onion_message/messenger.rs b/lightning/src/onion_message/messenger.rs index 7330ab6bf..8dba54d81 100644 --- a/lightning/src/onion_message/messenger.rs +++ b/lightning/src/onion_message/messenger.rs @@ -15,8 +15,8 @@ use bitcoin::hashes::hmac::{Hmac, HmacEngine}; use bitcoin::hashes::sha256::Hash as Sha256; use bitcoin::secp256k1::{self, PublicKey, Scalar, Secp256k1, SecretKey}; -use crate::blinded_path::{IntroductionNode, NextMessageHop, NodeIdLookUp}; -use crate::blinded_path::message::{advance_path_by_one, BlindedMessagePath, ForwardNode, ForwardTlvs, MessageContext, ReceiveTlvs}; +use crate::blinded_path::{IntroductionNode, NodeIdLookUp}; +use crate::blinded_path::message::{advance_path_by_one, BlindedMessagePath, ForwardNode, ForwardTlvs, MessageContext, NextMessageHop, ReceiveTlvs}; use crate::blinded_path::utils; use crate::events::{Event, EventHandler, EventsProvider, ReplayEvent}; use crate::sign::{EntropySource, NodeSigner, Recipient}; diff --git a/lightning/src/onion_message/packet.rs b/lightning/src/onion_message/packet.rs index 88302b106..553d70216 100644 --- a/lightning/src/onion_message/packet.rs +++ b/lightning/src/onion_message/packet.rs @@ -12,8 +12,7 @@ use bitcoin::secp256k1::PublicKey; use bitcoin::secp256k1::ecdh::SharedSecret; -use crate::blinded_path::NextMessageHop; -use crate::blinded_path::message::{BlindedMessagePath, ForwardTlvs, ReceiveTlvs}; +use crate::blinded_path::message::{BlindedMessagePath, ForwardTlvs, NextMessageHop, ReceiveTlvs}; use crate::blinded_path::utils::Padding; use crate::ln::msgs::DecodeError; use crate::ln::onion_utils;