X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Fln%2Fmsgs.rs;h=83f5a861559a7d443729afb52db543f2e925ed20;hb=refs%2Fheads%2F2024-01-om-direct-export;hp=689058c7e4a14ea7e52f73c794d1127581181650;hpb=f5e87d8441f2e873114fd3b310a04be0a2a9181f;p=rust-lightning diff --git a/lightning/src/ln/msgs.rs b/lightning/src/ln/msgs.rs index 689058c7..83f5a861 100644 --- a/lightning/src/ln/msgs.rs +++ b/lightning/src/ln/msgs.rs @@ -695,7 +695,7 @@ pub struct OnionMessage { /// Used in decrypting the onion packet's payload. pub blinding_point: PublicKey, /// The full onion packet including hop data, pubkey, and hmac - pub onion_routing_packet: onion_message::Packet, + pub onion_routing_packet: onion_message::packet::Packet, } /// An [`update_fulfill_htlc`] message to be sent to or received from a peer. @@ -1668,23 +1668,31 @@ pub trait OnionMessageHandler: EventsProvider { fn provided_init_features(&self, their_node_id: &PublicKey) -> InitFeatures; } +#[derive(Clone)] +#[cfg_attr(test, derive(Debug, PartialEq))] +/// Information communicated in the onion to the recipient for multi-part tracking and proof that +/// the payment is associated with an invoice. +pub struct FinalOnionHopData { + /// When sending a multi-part payment, this secret is used to identify a payment across HTLCs. + /// Because it is generated by the recipient and included in the invoice, it also provides + /// proof to the recipient that the payment was sent by someone with the generated invoice. + pub payment_secret: PaymentSecret, + /// The intended total amount that this payment is for. + /// + /// Message serialization may panic if this value is more than 21 million Bitcoin. + pub total_msat: u64, +} + mod fuzzy_internal_msgs { use bitcoin::secp256k1::PublicKey; use crate::blinded_path::payment::{PaymentConstraints, PaymentRelay}; use crate::prelude::*; use crate::ln::{PaymentPreimage, PaymentSecret}; use crate::ln::features::BlindedHopFeatures; + use super::FinalOnionHopData; // These types aren't intended to be pub, but are exposed for direct fuzzing (as we deserialize // them from untrusted input): - #[derive(Clone)] - #[cfg_attr(test, derive(Debug, PartialEq))] - pub struct FinalOnionHopData { - pub payment_secret: PaymentSecret, - /// The total value, in msat, of the payment as received by the ultimate recipient. - /// Message serialization may panic if this value is more than 21 million Bitcoin. - pub total_msat: u64, - } pub enum InboundOnionPayload { Forward { @@ -2237,7 +2245,8 @@ impl Readable for OnionMessage { let blinding_point: PublicKey = Readable::read(r)?; let len: u16 = Readable::read(r)?; let mut packet_reader = FixedLengthReader::new(r, len as u64); - let onion_routing_packet: onion_message::Packet = ::read(&mut packet_reader)?; + let onion_routing_packet: onion_message::packet::Packet = + ::read(&mut packet_reader)?; Ok(Self { blinding_point, onion_routing_packet,