Skip to content

Commit 12163b5

Browse files
author
Antoine Riard
committed
Add detection of HTLC outputs resolved by remote peer justice tx
In case of broadcast of revoked local commitment tx, we may be interested that we've screwed up
1 parent 5d9b69b commit 12163b5

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/ln/channelmonitor.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1770,7 +1770,10 @@ impl ChannelMonitor {
17701770
// to broadcast solving backward
17711771
if payment_data.0.is_some() && payment_data.1.is_some() {
17721772
let mut payment_preimage = PaymentPreimage([0; 32]);
1773-
if input.witness.len() == 5 && input.witness[4].len() == ACCEPTED_HTLC_SCRIPT_WEIGHT {
1773+
if (input.witness.len() == 3 && input.witness[2].len() == OFFERED_HTLC_SCRIPT_WEIGHT && input.witness[1].len() == 33)
1774+
|| (input.witness.len() == 3 && input.witness[2].len() == ACCEPTED_HTLC_SCRIPT_WEIGHT && input.witness[1].len() == 33) {
1775+
log_debug!(self, "Remote used revocation sig to take a {} HTLC output at index {} from commitment_tx {}", if input.witness[2].len() == OFFERED_HTLC_SCRIPT_WEIGHT { "offered" } else { "accepted" }, input.previous_output.vout, input.previous_output.txid);
1776+
} else if input.witness.len() == 5 && input.witness[4].len() == ACCEPTED_HTLC_SCRIPT_WEIGHT {
17741777
payment_preimage.0.copy_from_slice(&tx.input[0].witness[3]);
17751778
htlc_updated.push((payment_data.0.unwrap(), Some(payment_preimage), payment_data.1.unwrap()));
17761779
} else if input.witness.len() == 3 && input.witness[2].len() == OFFERED_HTLC_SCRIPT_WEIGHT {

0 commit comments

Comments
 (0)