Skip to content

Commit

Permalink
Use original funding TXO to get channel monitors
Browse files Browse the repository at this point in the history
  • Loading branch information
luckysori authored and holzeis committed Nov 20, 2023
1 parent 6b045f0 commit 343901b
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lightning/src/ln/channelmanager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit 343901b

Please sign in to comment.