Skip to content

Commit 2c52690

Browse files
committed
ln: handle trampoline claims on restart
This commit uses the existing outbound payment claims replay logic to restore trampoline claims. If any single previous hop in a htlc source with multiple previous hops requires claim, we represent this with a single outbound claimed htlc because we assume that *all* of the incoming htlcs are represented in the source, and will be appropriately claimed (rather than submitting multiple claims, which will end up being duplicates of each other). This is the case for trampoline payments, where the htlc_source stores all previous hops.
1 parent 6a2421f commit 2c52690

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18462,6 +18462,9 @@ where
1846218462

1846318463
let prev_htlcs = match &htlc_source {
1846418464
HTLCSource::PreviousHopData(prev_hop) => vec![prev_hop],
18465+
HTLCSource::TrampolineForward { previous_hop_data, .. } => {
18466+
previous_hop_data.iter().collect()
18467+
},
1846518468
// If it was an outbound payment, we've handled it above - if a preimage
1846618469
// came in and we persisted the `ChannelManager` we either handled it
1846718470
// and are good to go or the channel force-closed - we don't have to
@@ -18495,6 +18498,10 @@ where
1849518498

1849618499
fail_read |= fail_claim_read;
1849718500
return Some((
18501+
// When we have multiple prev_htlcs we assume that they all
18502+
// share the same htlc_source which contains all previous hops,
18503+
// so we can exit on the first claimable prev_hop because this
18504+
// will result in all prev_hops being claimed.
1849818505
htlc_source,
1849918506
payment_preimage,
1850018507
htlc.amount_msat,

0 commit comments

Comments
 (0)