]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Prefix AsyncPaymentsMessageHandler methods with handle_*
authorValentine Wallace <vwallace@protonmail.com>
Wed, 18 Sep 2024 00:32:14 +0000 (20:32 -0400)
committerValentine Wallace <vwallace@protonmail.com>
Wed, 30 Oct 2024 20:14:03 +0000 (16:14 -0400)
"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
lightning/src/ln/channelmanager.rs
lightning/src/ln/peer_handler.rs
lightning/src/onion_message/async_payments.rs
lightning/src/onion_message/functional_tests.rs
lightning/src/onion_message/messenger.rs

index a586cd61a86325e0251f3da74a292672c2257fef..edf304b5467ff3595132ee1a7f4179bc3c30e76a 100644 (file)
@@ -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<Responder>,
        ) -> 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)]
index 6a3fd22751b76285c0938f875227b4de0b18733d..691223fd3cfb111a33221a631192891bee5aa169 100644 (file)
@@ -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<Responder>
        ) -> 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 }
index b5fc3443be5b16e7f898719c3650eb1c1ada02bb..99c2e001c4f8daae8cd6fd263e6d171c985e4202 100644 (file)
@@ -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<Responder>,
        ) -> 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(
index cc4ca5edfb0cf433efe6f28f1fee62bc4638c338..d81010e5d5fdca5d671006e362e1d7a56dcb1f51 100644 (file)
@@ -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<Responder>,
        ) -> 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.
        ///
index 23fd30c9ec8c747a108d0e3615397b3378d923b1..f9d73f05ff3f42dd9d418f5fb429de8269259082 100644 (file)
@@ -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<Responder>,
        ) -> 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 {}
index 8162c55ac0807d2f6b0fba410811bc5cb767e575..0331a1060b864591af9a4b2694fa67a28ba8ee32 100644 (file)
@@ -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);