Skip to content

Commit 6946254

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 60ea7b0 commit 6946254

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
@@ -1820,7 +1820,10 @@ impl ChannelMonitor {
18201820
// to broadcast solving backward
18211821
if payment_data.0.is_some() && payment_data.1.is_some() {
18221822
let mut payment_preimage = PaymentPreimage([0; 32]);
1823-
if input.witness.len() == 5 && input.witness[4].len() == ACCEPTED_HTLC_SCRIPT_WEIGHT {
1823+
if (input.witness.len() == 3 && input.witness[2].len() == OFFERED_HTLC_SCRIPT_WEIGHT && input.witness[1].len() == 33)
1824+
|| (input.witness.len() == 3 && input.witness[2].len() == ACCEPTED_HTLC_SCRIPT_WEIGHT && input.witness[1].len() == 33) {
1825+
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);
1826+
} else if input.witness.len() == 5 && input.witness[4].len() == ACCEPTED_HTLC_SCRIPT_WEIGHT {
18241827
payment_preimage.0.copy_from_slice(&tx.input[0].witness[3]);
18251828
htlc_updated.push((payment_data.0.unwrap(), Some(payment_preimage), payment_data.1.unwrap()));
18261829
} else if input.witness.len() == 3 && input.witness[2].len() == OFFERED_HTLC_SCRIPT_WEIGHT {

0 commit comments

Comments
 (0)