From 343901b7161ba57b46d8bba3f868d61a96b29a7c Mon Sep 17 00:00:00 2001 From: Lucas Soriano del Pino Date: Thu, 2 Nov 2023 00:56:25 +1100 Subject: [PATCH] Use original funding TXO to get channel monitors --- lightning/src/ln/channelmanager.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lightning/src/ln/channelmanager.rs b/lightning/src/ln/channelmanager.rs index 2e344eb12d3..bab76a40a2d 100644 --- a/lightning/src/ln/channelmanager.rs +++ b/lightning/src/ln/channelmanager.rs @@ -2622,12 +2622,6 @@ where return Err(APIError::ChannelUnavailable { err: "Channel is not useable.".to_string() }); } - if let Some(commit_tx_number) = commit_tx_number { - if commit_tx_number != chan.get_cur_holder_commitment_transaction_number() - 1 { - return Err(APIError::ExternalError { err: format!("Invalid commitment transaction number, expected {} but got {}", chan.get_cur_holder_commitment_transaction_number(), commit_tx_number) }); - } - } - let channel_value = chan.context().get_value_satoshis(); let own_balance = chan.context().get_available_balances(&self.fee_estimator).balance_msat; let funding_outpoint = chan.context().channel_transaction_parameters.funding_outpoint.unwrap(); @@ -2638,6 +2632,12 @@ where ChannelPhase::Funded(channel) => Ok(channel) }?; + if let Some(commit_tx_number) = commit_tx_number { + if commit_tx_number != channel.get_cur_holder_commitment_transaction_number() - 1 { + return Err(APIError::ExternalError { err: format!("Invalid commitment transaction number, expected {} but got {}", channel.get_cur_holder_commitment_transaction_number(), commit_tx_number) }); + } + } + let mut lock = ChannelLock { channel }; let res = callback(&mut lock); @@ -9818,7 +9818,7 @@ where if let ChannelPhase::Funded(chan) = phase { // Channels that were persisted have to be funded, otherwise they should have been // discarded. - let funding_txo = chan.context.get_funding_txo().ok_or(DecodeError::InvalidValue)?; + let funding_txo = chan.context.get_original_funding_txo().ok_or(DecodeError::InvalidValue)?; let monitor = args.channel_monitors.get(&funding_txo) .expect("We already checked for monitor presence when loading channels"); let mut max_in_flight_update_id = monitor.get_latest_update_id();