Skip to content

Commit 43999b4

Browse files
Thread htlc hold time to monitor on fail
Recently, we began generating monitor events when HTLCs fail off-chain. In upcoming commits, we'll begin relying on those events to resolve forwarded HTLC fails on the inbound edge. As such, we need to thread the hold time to the monitor so the generated event is correct.
1 parent 4a6bc66 commit 43999b4

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

lightning/src/ln/channel.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8789,7 +8789,7 @@ where
87898789
attribution_data: None,
87908790
};
87918791
mem::swap(outcome, &mut reason);
8792-
match reason {
8792+
match &mut reason {
87938793
OutboundHTLCOutcome::Success { preimage, .. } => {
87948794
// If a user (a) receives an HTLC claim using LDK 0.0.104 or before, then (b)
87958795
// upgrades to LDK 0.0.114 or later before the HTLC is fully resolved, we could
@@ -8799,11 +8799,16 @@ where
87998799
// claim anyway.
88008800
claimed_htlcs.push(OutboundHTLCClaim {
88018801
htlc_id: SentHTLCId::from_source(&htlc.source),
8802-
preimage,
8802+
preimage: *preimage,
88038803
skimmed_fee_msat: htlc.skimmed_fee_msat,
88048804
});
88058805
},
8806-
OutboundHTLCOutcome::Failure(ref fail_reason) => {
8806+
OutboundHTLCOutcome::Failure(fail_reason) => {
8807+
// The monitor needs the HTLC hold time to correctly resolve the HTLC when generating a
8808+
// monitor event for its failure.
8809+
hold_time_since(htlc.send_timestamp).map(|hold_time| {
8810+
fail_reason.set_hold_time(hold_time);
8811+
});
88078812
failed_htlcs.push(OutboundHTLCFail {
88088813
htlc_id: SentHTLCId::from_source(&htlc.source),
88098814
failure_reason: fail_reason.clone(),

0 commit comments

Comments
 (0)