From: Matt Corallo <649246+TheBlueMatt@users.noreply.github.com> Date: Fri, 29 Sep 2023 22:06:58 +0000 (+0000) Subject: Merge pull request #2605 from wpaulino/anchors-monitor-track-to-remote-script X-Git-Tag: v0.0.117-rc1~4 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=620244dc2ec3153a61e009b80a8c59cf41514482;p=rust-lightning Merge pull request #2605 from wpaulino/anchors-monitor-track-to-remote-script Use correct to_remote script in counterparty commitments --- 620244dc2ec3153a61e009b80a8c59cf41514482 diff --cc lightning/src/chain/channelmonitor.rs index 5d3e0ac28,53ac85c29..25bfa14d5 --- a/lightning/src/chain/channelmonitor.rs +++ b/lightning/src/chain/channelmonitor.rs @@@ -1691,17 -1690,22 +1691,27 @@@ impl Vec { let inner = self.inner.lock().unwrap(); let current_height = inner.best_block.height; - if current_height.saturating_sub(ANTI_REORG_DELAY) + 1 >= confirmation_height { - inner.get_spendable_outputs(tx) - } else { - Vec::new() - } + let mut spendable_outputs = inner.get_spendable_outputs(tx); + spendable_outputs.retain(|descriptor| { + let mut conf_threshold = current_height.saturating_sub(ANTI_REORG_DELAY) + 1; + if let SpendableOutputDescriptor::DelayedPaymentOutput(descriptor) = descriptor { + conf_threshold = cmp::min(conf_threshold, + current_height.saturating_sub(descriptor.to_self_delay as u32) + 1); + } + conf_threshold >= confirmation_height + }); + spendable_outputs } + + #[cfg(test)] + pub fn get_counterparty_payment_script(&self) -> Script{ + self.inner.lock().unwrap().counterparty_payment_script.clone() + } + + #[cfg(test)] + pub fn set_counterparty_payment_script(&self, script: Script) { + self.inner.lock().unwrap().counterparty_payment_script = script; + } } impl ChannelMonitorImpl {