Skip to content

Commit 913d56e

Browse files
committed
Macro-DRY HTLC back-fails for revoked remote transaction broadcast
1 parent e344b0a commit 913d56e

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

src/ln/channelmonitor.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,22 +1188,22 @@ impl ChannelMonitor {
11881188
// TODO: We really should only fail backwards after our revocation claims have been
11891189
// confirmed, but we also need to do more other tracking of in-flight pre-confirm
11901190
// on-chain claims, so we can do that at the same time.
1191-
if let Storage::Local { ref current_remote_commitment_txid, ref prev_remote_commitment_txid, .. } = self.key_storage {
1192-
if let &Some(ref txid) = current_remote_commitment_txid {
1193-
if let Some(&(_, ref latest_outpoints)) = self.remote_claimable_outpoints.get(&txid) {
1194-
for &(ref payment_hash, ref source, _) in latest_outpoints.iter() {
1195-
log_trace!(self, "Failing HTLC with payment_hash {} from current remote commitment tx due to broadcast of revoked remote commitment transaction", log_bytes!(payment_hash.0));
1191+
macro_rules! check_htlc_fails {
1192+
($txid: expr, $commitment_tx: expr) => {
1193+
if let Some(&(_, ref outpoints)) = self.remote_claimable_outpoints.get(&$txid) {
1194+
for &(ref payment_hash, ref source, _) in outpoints.iter() {
1195+
log_trace!(self, "Failing HTLC with payment_hash {} from {} remote commitment tx due to broadcast of revoked remote commitment transaction", log_bytes!(payment_hash.0), $commitment_tx);
11961196
htlc_updated.push(((*source).clone(), None, payment_hash.clone()));
11971197
}
11981198
}
11991199
}
1200+
}
1201+
if let Storage::Local { ref current_remote_commitment_txid, ref prev_remote_commitment_txid, .. } = self.key_storage {
1202+
if let &Some(ref txid) = current_remote_commitment_txid {
1203+
check_htlc_fails!(txid, "current");
1204+
}
12001205
if let &Some(ref txid) = prev_remote_commitment_txid {
1201-
if let Some(&(_, ref prev_outpoint)) = self.remote_claimable_outpoints.get(&txid) {
1202-
for &(ref payment_hash, ref source, _) in prev_outpoint.iter() {
1203-
log_trace!(self, "Failing HTLC with payment_hash {} from previous remote commitment tx due to broadcast of revoked remote commitment transaction", log_bytes!(payment_hash.0));
1204-
htlc_updated.push(((*source).clone(), None, payment_hash.clone()));
1205-
}
1206-
}
1206+
check_htlc_fails!(txid, "remote");
12071207
}
12081208
}
12091209
// No need to check local commitment txn, symmetric HTLCSource must be present as per-htlc data on remote commitment tx

0 commit comments

Comments
 (0)