projects
/
rust-lightning
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Implement non-strict forwarding
[rust-lightning]
/
lightning
/
src
/
onion_message
/
packet.rs
diff --git
a/lightning/src/onion_message/packet.rs
b/lightning/src/onion_message/packet.rs
index 7483888d137132ec2b0bdd3719a461280c4aa6cb..75ec3cd90ab83c811b18b1283eab668ca7ddcb1d 100644
(file)
--- a/
lightning/src/onion_message/packet.rs
+++ b/
lightning/src/onion_message/packet.rs
@@
-12,8
+12,8
@@
use bitcoin::secp256k1::PublicKey;
use bitcoin::secp256k1::ecdh::SharedSecret;
use bitcoin::secp256k1::PublicKey;
use bitcoin::secp256k1::ecdh::SharedSecret;
-use crate::blinded_path::
BlindedPath
;
-use crate::blinded_path::message::{ForwardTlvs,
NextHop,
ReceiveTlvs};
+use crate::blinded_path::
{BlindedPath, NextMessageHop}
;
+use crate::blinded_path::message::{ForwardTlvs, ReceiveTlvs};
use crate::blinded_path::utils::Padding;
use crate::ln::msgs::DecodeError;
use crate::ln::onion_utils;
use crate::blinded_path::utils::Padding;
use crate::ln::msgs::DecodeError;
use crate::ln::onion_utils;
@@
-124,7
+124,7
@@
pub(super) enum Payload<T: OnionMessageContents> {
/// The contents of an [`OnionMessage`] as read from the wire.
///
/// [`OnionMessage`]: crate::ln::msgs::OnionMessage
/// The contents of an [`OnionMessage`] as read from the wire.
///
/// [`OnionMessage`]: crate::ln::msgs::OnionMessage
-#[derive(Debug)]
+#[derive(
Clone,
Debug)]
pub enum ParsedOnionMessageContents<T: OnionMessageContents> {
/// A message related to BOLT 12 Offers.
Offers(OffersMessage),
pub enum ParsedOnionMessageContents<T: OnionMessageContents> {
/// A message related to BOLT 12 Offers.
Offers(OffersMessage),
@@
-142,6
+142,12
@@
impl<T: OnionMessageContents> OnionMessageContents for ParsedOnionMessageContent
&ParsedOnionMessageContents::Custom(ref msg) => msg.tlv_type(),
}
}
&ParsedOnionMessageContents::Custom(ref msg) => msg.tlv_type(),
}
}
+ fn msg_type(&self) -> &'static str {
+ match self {
+ ParsedOnionMessageContents::Offers(ref msg) => msg.msg_type(),
+ ParsedOnionMessageContents::Custom(ref msg) => msg.msg_type(),
+ }
+ }
}
impl<T: OnionMessageContents> Writeable for ParsedOnionMessageContents<T> {
}
impl<T: OnionMessageContents> Writeable for ParsedOnionMessageContents<T> {
@@
-157,6
+163,9
@@
impl<T: OnionMessageContents> Writeable for ParsedOnionMessageContents<T> {
pub trait OnionMessageContents: Writeable + core::fmt::Debug {
/// Returns the TLV type identifying the message contents. MUST be >= 64.
fn tlv_type(&self) -> u64;
pub trait OnionMessageContents: Writeable + core::fmt::Debug {
/// Returns the TLV type identifying the message contents. MUST be >= 64.
fn tlv_type(&self) -> u64;
+
+ /// Returns the message type
+ fn msg_type(&self) -> &'static str;
}
/// Forward control TLVs in their blinded and unblinded form.
}
/// Forward control TLVs in their blinded and unblinded form.
@@
-300,8
+309,8
@@
impl Readable for ControlTlvs {
let next_hop = match (short_channel_id, next_node_id) {
(Some(_), Some(_)) => return Err(DecodeError::InvalidValue),
let next_hop = match (short_channel_id, next_node_id) {
(Some(_), Some(_)) => return Err(DecodeError::InvalidValue),
- (Some(scid), None) => Some(NextHop::ShortChannelId(scid)),
- (None, Some(pubkey)) => Some(NextHop::NodeId(pubkey)),
+ (Some(scid), None) => Some(Next
Message
Hop::ShortChannelId(scid)),
+ (None, Some(pubkey)) => Some(Next
Message
Hop::NodeId(pubkey)),
(None, None) => None,
};
(None, None) => None,
};