From: Jeffrey Czyz Date: Fri, 2 Jun 2023 13:08:59 +0000 (-0500) Subject: Pass logger to onion payload decoder X-Git-Tag: v0.0.116-alpha1~11^2~12 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=7533a3c42fea0ba08494b617a4f872dd04ef7f1e;p=rust-lightning Pass logger to onion payload decoder In an upcoming commit, messages for BOLT 12 offers are read from the onion payload. Passing a logger allows for logging semantic errors when parsing the messages. --- diff --git a/lightning/src/onion_message/messenger.rs b/lightning/src/onion_message/messenger.rs index 5171422cb..865700609 100644 --- a/lightning/src/onion_message/messenger.rs +++ b/lightning/src/onion_message/messenger.rs @@ -301,7 +301,7 @@ fn outbound_buffer_full(peer_node_id: &PublicKey, buffer: &HashMap OnionMessageHandler for OnionMessenger where ES::Target: EntropySource, NS::Target: NodeSigner, - L::Target: Logger, + L::Target: Logger + Sized, CMH::Target: CustomOnionMessageHandler + Sized, { /// Handle an incoming onion message. Currently, if a message was destined for us we will log, but @@ -331,9 +331,10 @@ impl OnionMessageHandler for OnionMe } } }; - match onion_utils::decode_next_untagged_hop(onion_decode_ss, &msg.onion_routing_packet.hop_data[..], - msg.onion_routing_packet.hmac, (control_tlvs_ss, &*self.custom_handler)) - { + match onion_utils::decode_next_untagged_hop( + onion_decode_ss, &msg.onion_routing_packet.hop_data[..], msg.onion_routing_packet.hmac, + (control_tlvs_ss, &*self.custom_handler, &*self.logger) + ) { Ok((Payload::Receive::<<::Target as CustomOnionMessageHandler>::CustomMessage> { message, control_tlvs: ReceiveControlTlvs::Unblinded(ReceiveTlvs { path_id }), reply_path, }, None)) => { diff --git a/lightning/src/onion_message/packet.rs b/lightning/src/onion_message/packet.rs index 2fb2407db..d4f08109c 100644 --- a/lightning/src/onion_message/packet.rs +++ b/lightning/src/onion_message/packet.rs @@ -17,6 +17,7 @@ use crate::ln::msgs::DecodeError; use crate::ln::onion_utils; use super::messenger::CustomOnionMessageHandler; use crate::util::chacha20poly1305rfc::{ChaChaPolyReadAdapter, ChaChaPolyWriteAdapter}; +use crate::util::logger::Logger; use crate::util::ser::{BigSize, FixedLengthReader, LengthRead, LengthReadable, LengthReadableArgs, Readable, ReadableArgs, Writeable, Writer}; use core::cmp; @@ -201,9 +202,10 @@ impl Writeable for (Payload, [u8; 32]) { } // Uses the provided secret to simultaneously decode and decrypt the control TLVs and data TLV. -impl ReadableArgs<(SharedSecret, &H)> for Payload<::CustomMessage> { - fn read(r: &mut R, args: (SharedSecret, &H)) -> Result { - let (encrypted_tlvs_ss, handler) = args; +impl +ReadableArgs<(SharedSecret, &H, &L)> for Payload<::CustomMessage> { + fn read(r: &mut R, args: (SharedSecret, &H, &L)) -> Result { + let (encrypted_tlvs_ss, handler, _logger) = args; let v: BigSize = Readable::read(r)?; let mut rd = FixedLengthReader::new(r, v.0);