Skip to content

Commit

Permalink
Prefix AsyncPaymentsMessageHandler methods with handle_*
Browse files Browse the repository at this point in the history
"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.
  • Loading branch information
valentinewallace committed Oct 24, 2024
1 parent f0bb1c2 commit 064c7ae
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions fuzz/src/onion_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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)]
Expand Down
4 changes: 2 additions & 2 deletions lightning/src/ln/channelmanager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
4 changes: 2 additions & 2 deletions lightning/src/ln/peer_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions lightning/src/onion_message/async_payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
///
Expand Down
4 changes: 2 additions & 2 deletions lightning/src/onion_message/functional_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}
Expand Down
4 changes: 2 additions & 2 deletions lightning/src/onion_message/messenger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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);
Expand Down

0 comments on commit 064c7ae

Please sign in to comment.