Skip to content

Commit 6448a0d

Browse files
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.
1 parent ffef1c3 commit 6448a0d

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

lightning/src/ln/channelmanager.rs

+14-1
Original file line numberDiff line numberDiff line change
@@ -12188,7 +12188,20 @@ where
1218812188
&self, _message: HeldHtlcAvailable, _context: AsyncPaymentsContext,
1218912189
_responder: Option<Responder>
1219012190
) -> Option<(ReleaseHeldHtlc, ResponseInstruction)> {
12191-
None
12191+
#[cfg(async_payments)] {
12192+
match _context {
12193+
AsyncPaymentsContext::InboundPayment { nonce, hmac, path_absolute_expiry } => {
12194+
if let Err(()) = signer::verify_held_htlc_available_context(
12195+
nonce, hmac, &self.inbound_payment_key
12196+
) { return None }
12197+
if self.duration_since_epoch() > path_absolute_expiry { return None }
12198+
},
12199+
_ => return None
12200+
}
12201+
return _responder.map(|responder| (ReleaseHeldHtlc {}, responder.respond()))
12202+
}
12203+
#[cfg(not(async_payments))]
12204+
return None
1219212205
}
1219312206

1219412207
fn handle_release_held_htlc(&self, _message: ReleaseHeldHtlc, _context: AsyncPaymentsContext) {

lightning/src/offers/signer.rs

+7
Original file line numberDiff line numberDiff line change
@@ -501,3 +501,10 @@ pub(crate) fn hmac_for_held_htlc_available_context(
501501

502502
Hmac::from_engine(hmac)
503503
}
504+
505+
#[cfg(async_payments)]
506+
pub(crate) fn verify_held_htlc_available_context(
507+
nonce: Nonce, hmac: Hmac<Sha256>, expanded_key: &ExpandedKey,
508+
) -> Result<(), ()> {
509+
if hmac_for_held_htlc_available_context(nonce, expanded_key) == hmac { Ok(()) } else { Err(()) }
510+
}

0 commit comments

Comments
 (0)