X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Fln%2Fchannelmonitor.rs;h=e3cea97716d35061aa34469c209eec8e094e1cba;hb=82d40eefb2e6887c6667d1672bfe1e078936dad8;hp=514a95d27db9339edc8b78989a0477695ae102ab;hpb=32d62ada96faab954bbcee4fc5d9ec58d2eff482;p=rust-lightning diff --git a/lightning/src/ln/channelmonitor.rs b/lightning/src/ln/channelmonitor.rs index 514a95d2..e3cea977 100644 --- a/lightning/src/ln/channelmonitor.rs +++ b/lightning/src/ln/channelmonitor.rs @@ -2278,19 +2278,23 @@ impl ChannelMonitor { if let Some((source, payment_hash)) = payment_data { let mut payment_preimage = PaymentPreimage([0; 32]); if accepted_preimage_claim { - payment_preimage.0.copy_from_slice(&input.witness[3]); - self.pending_htlcs_updated.push(HTLCUpdate { - source, - payment_preimage: Some(payment_preimage), - payment_hash - }); + if !self.pending_htlcs_updated.iter().any(|update| update.source == source) { + payment_preimage.0.copy_from_slice(&input.witness[3]); + self.pending_htlcs_updated.push(HTLCUpdate { + source, + payment_preimage: Some(payment_preimage), + payment_hash + }); + } } else if offered_preimage_claim { - payment_preimage.0.copy_from_slice(&input.witness[1]); - self.pending_htlcs_updated.push(HTLCUpdate { - source, - payment_preimage: Some(payment_preimage), - payment_hash - }); + if !self.pending_htlcs_updated.iter().any(|update| update.source == source) { + payment_preimage.0.copy_from_slice(&input.witness[1]); + self.pending_htlcs_updated.push(HTLCUpdate { + source, + payment_preimage: Some(payment_preimage), + payment_hash + }); + } } else { log_info!(self, "Failing HTLC with payment_hash {} timeout by a spend tx, waiting for confirmation (at height{})", log_bytes!(payment_hash.0), height + ANTI_REORG_DELAY - 1); match self.onchain_events_waiting_threshold_conf.entry(height + ANTI_REORG_DELAY - 1) {