Skip to content

Commit bf675b6

Browse files
committed
fixup! fixup! fixup! Enable spliting lightning channel
I think we might need to update the `ChannelTransactionParameters` in the `OnchainTxHandler` when we split the channel. It seems necessary in general and it has become mandatory now that we have a `debug_assert_eq` checking the commitment TXIDs when handling a `ChannelMonitorUpdate` in the `ChannelMonitor`.
1 parent 2c10619 commit bf675b6

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

lightning/src/chain/channelmonitor.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -1292,12 +1292,20 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitor<Signer> {
12921292
if let Some(original) = inner.original_funding_info.as_ref() {
12931293
if fund_outpoint == original.0 {
12941294
inner.original_funding_info = None;
1295+
inner.onchain_tx_handler.channel_transaction_parameters.original_funding_outpoint = None;
12951296
}
12961297
} else {
1297-
inner.original_funding_info = Some((inner.funding_info.0.clone(), inner.funding_info.1.clone()));
1298+
let original_funding_txo = inner.funding_info.0;
1299+
let original_funding_script_pubkey = &inner.funding_info.1;
1300+
1301+
inner.original_funding_info = Some((original_funding_txo, original_funding_script_pubkey.clone()));
1302+
inner.onchain_tx_handler.channel_transaction_parameters.original_funding_outpoint = Some(original_funding_txo);
12981303
}
12991304
inner.outputs_to_watch.insert(fund_outpoint.txid, vec![(fund_outpoint.index as u32, script.clone())]);
1305+
13001306
inner.funding_info = (fund_outpoint, script.clone());
1307+
inner.onchain_tx_handler.channel_transaction_parameters.funding_outpoint = Some(fund_outpoint);
1308+
13011309
inner.channel_value_satoshis = channel_value_satoshis;
13021310
inner.onchain_tx_handler.signer.set_channel_value_satoshis(channel_value_satoshis);
13031311
script

lightning/src/ln/channel.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1076,8 +1076,7 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
10761076
self.channel_transaction_parameters.original_funding_outpoint.or(self.get_funding_txo())
10771077
}
10781078

1079-
/// Set the funding output and value of the channel, returning a `ChannelMonitorUpdate`
1080-
/// containing a commitment for the new funding output if requested.
1079+
/// Set the funding output and value of the channel.
10811080
fn set_funding_outpoint(&mut self, funding_outpoint: &OutPoint, channel_value_satoshis: u64, own_balance: u64)
10821081
{
10831082
self.channel_value_satoshis = channel_value_satoshis;

lightning/src/ln/channelmanager.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -2720,6 +2720,10 @@ where
27202720
let chan = channel_lock.get_channel();
27212721

27222722
let original_funding_txo = chan.context.get_original_funding_txo().unwrap();
2723+
if ChannelMonitorUpdateStatus::Completed != self.chain_monitor.update_channel_funding_txo(chan.context.get_original_funding_txo().unwrap(), *funding_outpoint, channel_value_satoshis) {
2724+
return Err(APIError::APIMisuseError { err: "Could not update channel funding transaction.".to_string() });
2725+
}
2726+
27232727
let monitor_update = chan.set_funding_outpoint(funding_outpoint, channel_value_satoshis, own_balance, true, &self.logger);
27242728
if let Some(monitor_update) = &monitor_update {
27252729
let update_res = self.chain_monitor.update_channel(original_funding_txo, monitor_update);
@@ -2728,10 +2732,6 @@ where
27282732
}
27292733
}
27302734

2731-
if ChannelMonitorUpdateStatus::Completed != self.chain_monitor.update_channel_funding_txo(chan.context.get_original_funding_txo().unwrap(), *funding_outpoint, channel_value_satoshis) {
2732-
return Err(APIError::APIMisuseError { err: "Could not update channel funding transaction.".to_string() });
2733-
}
2734-
27352735
let res = chan.monitor_updating_restored(&self.logger, &self.node_signer, self.genesis_hash, &self.default_configuration, self.best_block.read().unwrap().height());
27362736

27372737
let commit_tx_number = chan.get_cur_counterparty_commitment_transaction_number();

0 commit comments

Comments
 (0)