]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Merge pull request #2605 from wpaulino/anchors-monitor-track-to-remote-script
authorMatt Corallo <649246+TheBlueMatt@users.noreply.github.com>
Fri, 29 Sep 2023 22:06:58 +0000 (22:06 +0000)
committerGitHub <noreply@github.com>
Fri, 29 Sep 2023 22:06:58 +0000 (22:06 +0000)
Use correct to_remote script in counterparty commitments

1  2 
lightning/src/chain/channelmonitor.rs
lightning/src/ln/monitor_tests.rs

index 5d3e0ac28bbf45058068761db4cad78f1283558c,53ac85c29328bb74a45d0745e66802720b708ccb..25bfa14d5420ac266b6254acfaba55b1c2e413ce
@@@ -1691,17 -1690,22 +1691,27 @@@ impl<Signer: WriteableEcdsaChannelSigne
        pub fn get_spendable_outputs(&self, tx: &Transaction, confirmation_height: u32) -> Vec<SpendableOutputDescriptor> {
                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<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
Simple merge