Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support receiving async payments #3440

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Release async payment HTLCs held upstream via OM
If we receive a message that an HTLC is being held upstream for us, send a
reply onion message back releasing it since we are online to receive the
corresponding payment.
valentinewallace committed Jan 30, 2025
commit 6448a0d70c2ca592c600d7653a7cd4cc82876514
15 changes: 14 additions & 1 deletion lightning/src/ln/channelmanager.rs
Original file line number Diff line number Diff line change
@@ -12188,7 +12188,20 @@ where
&self, _message: HeldHtlcAvailable, _context: AsyncPaymentsContext,
_responder: Option<Responder>
) -> Option<(ReleaseHeldHtlc, ResponseInstruction)> {
None
#[cfg(async_payments)] {
match _context {
AsyncPaymentsContext::InboundPayment { nonce, hmac, path_absolute_expiry } => {
if let Err(()) = signer::verify_held_htlc_available_context(
nonce, hmac, &self.inbound_payment_key
) { return None }
if self.duration_since_epoch() > path_absolute_expiry { return None }
},
_ => return None
}
return _responder.map(|responder| (ReleaseHeldHtlc {}, responder.respond()))
}
#[cfg(not(async_payments))]
return None
}

fn handle_release_held_htlc(&self, _message: ReleaseHeldHtlc, _context: AsyncPaymentsContext) {
7 changes: 7 additions & 0 deletions lightning/src/offers/signer.rs
Original file line number Diff line number Diff line change
@@ -501,3 +501,10 @@ pub(crate) fn hmac_for_held_htlc_available_context(

Hmac::from_engine(hmac)
}

#[cfg(async_payments)]
pub(crate) fn verify_held_htlc_available_context(
nonce: Nonce, hmac: Hmac<Sha256>, expanded_key: &ExpandedKey,
) -> Result<(), ()> {
if hmac_for_held_htlc_available_context(nonce, expanded_key) == hmac { Ok(()) } else { Err(()) }
}