Skip to content

Commit 21b030a

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 4e96147 commit 21b030a

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12285,7 +12285,20 @@ where
1228512285
&self, _message: HeldHtlcAvailable, _context: AsyncPaymentsContext,
1228612286
_responder: Option<Responder>
1228712287
) -> Option<(ReleaseHeldHtlc, ResponseInstruction)> {
12288-
None
12288+
#[cfg(async_payments)] {
12289+
match _context {
12290+
AsyncPaymentsContext::InboundPayment { nonce, hmac, path_absolute_expiry } => {
12291+
if let Err(()) = signer::verify_held_htlc_available_context(
12292+
nonce, hmac, &self.inbound_payment_key
12293+
) { return None }
12294+
if self.duration_since_epoch() > path_absolute_expiry { return None }
12295+
},
12296+
_ => return None
12297+
}
12298+
return _responder.map(|responder| (ReleaseHeldHtlc {}, responder.respond()))
12299+
}
12300+
#[cfg(not(async_payments))]
12301+
return None
1228912302
}
1229012303

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

lightning/src/offers/signer.rs

Lines changed: 7 additions & 0 deletions
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)