Skip to content

Commit 9bd1cc7

Browse files
committed
Explicitly reject routes that double-back
- If a path within a route passes through the same channelID twice, that shows the path is looped and will be rejected by nodes. - Add a check to explicitly reject such payment before trying to send them.
1 parent 870a0f1 commit 9bd1cc7

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lightning/src/ln/outbound_payment.rs

+7
Original file line numberDiff line numberDiff line change
@@ -1337,6 +1337,13 @@ impl OutboundPayments {
13371337
continue 'path_check;
13381338
}
13391339
}
1340+
for (i, hop) in path.hops.iter().enumerate() {
1341+
// Check for duplicate channel_id in the remaining hops of the path
1342+
if path.hops.iter().skip(i + 1).any(|other_hop| other_hop.short_channel_id == hop.short_channel_id) {
1343+
path_errs.push(Err(APIError::InvalidRoute{err: "Path went through the same channel twice".to_owned()}));
1344+
continue 'path_check;
1345+
}
1346+
}
13401347
total_value += path.final_value_msat();
13411348
path_errs.push(Ok(()));
13421349
}

0 commit comments

Comments
 (0)