Skip to content

Commit 9a84f66

Browse files
committed
Assert that we only have skimmed fees for single htlc forwards
1 parent 9b8cbbf commit 9a84f66

1 file changed

Lines changed: 16 additions & 12 deletions

File tree

src/event.rs

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1426,20 +1426,24 @@ where
14261426
}
14271427
}
14281428

1429-
// We only allow multiple HTLCs in/out for trampoline forwards, which have not yet
1430-
// been fully implemented in LDK, so we do not lose any information by just
1431-
// reporting the first HTLC in each vec.
1432-
debug_assert_eq!(prev_htlcs.len(), 1, "unexpected number of prev_htlcs");
1433-
debug_assert_eq!(next_htlcs.len(), 1, "unexpected number of next_htlcs");
1434-
let next_htlc = next_htlcs
1435-
.first()
1436-
.expect("we expect at least one next_htlc for PaymentForwarded");
1437-
1429+
// We only expect multiple next_htlcs when we have a trampoline forward, and we do
1430+
// not support JIT channels in combination with trampoline. We're not at risk of
1431+
// double-reporting a skimmed fee when we have multiple next_htlcs because we
1432+
// expect our skimmed fee to be zero.
1433+
if skimmed_fee_msat.is_some() {
1434+
debug_assert_eq!(
1435+
next_htlcs.len(),
1436+
1,
1437+
"unexpected skimmed fee for trampoline forward, fee may be double counted"
1438+
);
1439+
}
14381440
if let Some(liquidity_source) = self.liquidity_source.as_ref() {
14391441
let skimmed_fee_msat = skimmed_fee_msat.unwrap_or(0);
1440-
liquidity_source
1441-
.handle_payment_forwarded(Some(next_htlc.channel_id), skimmed_fee_msat)
1442-
.await;
1442+
for next_htlc in next_htlcs.iter() {
1443+
liquidity_source
1444+
.handle_payment_forwarded(Some(next_htlc.channel_id), skimmed_fee_msat)
1445+
.await;
1446+
}
14431447
}
14441448

14451449
let event = Event::PaymentForwarded {

0 commit comments

Comments
 (0)