From 2ff6524da40cd82fc259140e49d7bd51f94868c0 Mon Sep 17 00:00:00 2001 From: Valentine Wallace Date: Tue, 17 Sep 2024 20:32:14 -0400 Subject: [PATCH] Prefix AsyncPaymentsMessageHandler methods with handle_* "Release" is overloaded in the trait's release_pending_messages method, since the latter releases pending async payments onion messages to the peer manager, vs the release_held_htlc method handles the release_held_htlc onion message by attempting to send an HTLC to the recipient. --- fuzz/src/onion_message.rs | 4 ++-- lightning/src/ln/channelmanager.rs | 4 ++-- lightning/src/ln/peer_handler.rs | 4 ++-- lightning/src/onion_message/async_payments.rs | 4 ++-- lightning/src/onion_message/functional_tests.rs | 4 ++-- lightning/src/onion_message/messenger.rs | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/fuzz/src/onion_message.rs b/fuzz/src/onion_message.rs index a586cd61a..edf304b54 100644 --- a/fuzz/src/onion_message.rs +++ b/fuzz/src/onion_message.rs @@ -121,7 +121,7 @@ impl OffersMessageHandler for TestOffersMessageHandler { struct TestAsyncPaymentsMessageHandler {} impl AsyncPaymentsMessageHandler for TestAsyncPaymentsMessageHandler { - fn held_htlc_available( + fn handle_held_htlc_available( &self, _message: HeldHtlcAvailable, responder: Option, ) -> Option<(ReleaseHeldHtlc, ResponseInstruction)> { let responder = match responder { @@ -130,7 +130,7 @@ impl AsyncPaymentsMessageHandler for TestAsyncPaymentsMessageHandler { }; Some((ReleaseHeldHtlc {}, responder.respond())) } - fn release_held_htlc(&self, _message: ReleaseHeldHtlc, _context: AsyncPaymentsContext) {} + fn handle_release_held_htlc(&self, _message: ReleaseHeldHtlc, _context: AsyncPaymentsContext) {} } #[derive(Debug)] diff --git a/lightning/src/ln/channelmanager.rs b/lightning/src/ln/channelmanager.rs index 6a3fd2275..691223fd3 100644 --- a/lightning/src/ln/channelmanager.rs +++ b/lightning/src/ln/channelmanager.rs @@ -11327,13 +11327,13 @@ where MR::Target: MessageRouter, L::Target: Logger, { - fn held_htlc_available( + fn handle_held_htlc_available( &self, _message: HeldHtlcAvailable, _responder: Option ) -> Option<(ReleaseHeldHtlc, ResponseInstruction)> { None } - fn release_held_htlc(&self, _message: ReleaseHeldHtlc, _context: AsyncPaymentsContext) { + fn handle_release_held_htlc(&self, _message: ReleaseHeldHtlc, _context: AsyncPaymentsContext) { #[cfg(async_payments)] { let AsyncPaymentsContext::OutboundPayment { payment_id, hmac, nonce } = _context; if payment_id.verify_for_async_payment(hmac, nonce, &self.inbound_payment_key).is_err() { return } diff --git a/lightning/src/ln/peer_handler.rs b/lightning/src/ln/peer_handler.rs index b5fc3443b..99c2e001c 100644 --- a/lightning/src/ln/peer_handler.rs +++ b/lightning/src/ln/peer_handler.rs @@ -148,12 +148,12 @@ impl OffersMessageHandler for IgnoringMessageHandler { } } impl AsyncPaymentsMessageHandler for IgnoringMessageHandler { - fn held_htlc_available( + fn handle_held_htlc_available( &self, _message: HeldHtlcAvailable, _responder: Option, ) -> Option<(ReleaseHeldHtlc, ResponseInstruction)> { None } - fn release_held_htlc(&self, _message: ReleaseHeldHtlc, _context: AsyncPaymentsContext) {} + fn handle_release_held_htlc(&self, _message: ReleaseHeldHtlc, _context: AsyncPaymentsContext) {} } impl DNSResolverMessageHandler for IgnoringMessageHandler { fn handle_dnssec_query( diff --git a/lightning/src/onion_message/async_payments.rs b/lightning/src/onion_message/async_payments.rs index cc4ca5edf..d81010e5d 100644 --- a/lightning/src/onion_message/async_payments.rs +++ b/lightning/src/onion_message/async_payments.rs @@ -27,13 +27,13 @@ const RELEASE_HELD_HTLC_TLV_TYPE: u64 = 74; pub trait AsyncPaymentsMessageHandler { /// Handle a [`HeldHtlcAvailable`] message. A [`ReleaseHeldHtlc`] should be returned to release /// the held funds. - fn held_htlc_available( + fn handle_held_htlc_available( &self, message: HeldHtlcAvailable, responder: Option, ) -> Option<(ReleaseHeldHtlc, ResponseInstruction)>; /// Handle a [`ReleaseHeldHtlc`] message. If authentication of the message succeeds, an HTLC /// should be released to the corresponding payee. - fn release_held_htlc(&self, message: ReleaseHeldHtlc, context: AsyncPaymentsContext); + fn handle_release_held_htlc(&self, message: ReleaseHeldHtlc, context: AsyncPaymentsContext); /// Release any [`AsyncPaymentsMessage`]s that need to be sent. /// diff --git a/lightning/src/onion_message/functional_tests.rs b/lightning/src/onion_message/functional_tests.rs index 23fd30c9e..f9d73f05f 100644 --- a/lightning/src/onion_message/functional_tests.rs +++ b/lightning/src/onion_message/functional_tests.rs @@ -84,12 +84,12 @@ impl OffersMessageHandler for TestOffersMessageHandler { struct TestAsyncPaymentsMessageHandler {} impl AsyncPaymentsMessageHandler for TestAsyncPaymentsMessageHandler { - fn held_htlc_available( + fn handle_held_htlc_available( &self, _message: HeldHtlcAvailable, _responder: Option, ) -> Option<(ReleaseHeldHtlc, ResponseInstruction)> { None } - fn release_held_htlc(&self, _message: ReleaseHeldHtlc, _context: AsyncPaymentsContext) {} + fn handle_release_held_htlc(&self, _message: ReleaseHeldHtlc, _context: AsyncPaymentsContext) {} } struct TestDNSResolverMessageHandler {} diff --git a/lightning/src/onion_message/messenger.rs b/lightning/src/onion_message/messenger.rs index 8162c55ac..0331a1060 100644 --- a/lightning/src/onion_message/messenger.rs +++ b/lightning/src/onion_message/messenger.rs @@ -1623,7 +1623,7 @@ where }, #[cfg(async_payments)] ParsedOnionMessageContents::AsyncPayments(AsyncPaymentsMessage::HeldHtlcAvailable(msg)) => { - let response_instructions = self.async_payments_handler.held_htlc_available( + let response_instructions = self.async_payments_handler.handle_held_htlc_available( msg, responder ); if let Some((msg, instructions)) = response_instructions { @@ -1640,7 +1640,7 @@ where }, None => return, }; - self.async_payments_handler.release_held_htlc(msg, context); + self.async_payments_handler.handle_release_held_htlc(msg, context); }, ParsedOnionMessageContents::DNSResolver(DNSResolverMessage::DNSSECQuery(msg)) => { let response_instructions = self.dns_resolver_handler.handle_dnssec_query(msg, responder); -- 2.39.5