From 9f3bb7d7a54ca24e42d358a9f0f78cf8944d3f98 Mon Sep 17 00:00:00 2001 From: Wilmer Paulino Date: Thu, 28 Sep 2023 12:12:19 -0700 Subject: [PATCH] Fix incorrect anchors `counterparty_payment_script` upon deserialization --- lightning/src/chain/channelmonitor.rs | 23 ++++++- lightning/src/ln/monitor_tests.rs | 87 +++++++++++++++++++++++++++ lightning/src/util/test_utils.rs | 11 +++- 3 files changed, 119 insertions(+), 2 deletions(-) diff --git a/lightning/src/chain/channelmonitor.rs b/lightning/src/chain/channelmonitor.rs index 95f68ba22..53ac85c29 100644 --- a/lightning/src/chain/channelmonitor.rs +++ b/lightning/src/chain/channelmonitor.rs @@ -1696,6 +1696,16 @@ impl ChannelMonitor { Vec::new() } } + + #[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 { @@ -4146,7 +4156,7 @@ impl<'a, 'b, ES: EntropySource, SP: SignerProvider> ReadableArgs<(&'a ES, &'b SP 1 => { None }, _ => return Err(DecodeError::InvalidValue), }; - let counterparty_payment_script = Readable::read(reader)?; + let mut counterparty_payment_script: Script = Readable::read(reader)?; let shutdown_script = { let script =