Skip to content

Commit 9850c58

Browse files
committed
Remove unnecessary signing call in ChannelMonitor
1 parent cd16cdd commit 9850c58

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

lightning/src/chain/channelmonitor.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3491,7 +3491,9 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
34913491
let commitment_package = PackageTemplate::build_package(self.funding_info.0.txid.clone(), self.funding_info.0.index as u32, PackageSolvingData::HolderFundingOutput(funding_outp), self.best_block.height(), self.best_block.height());
34923492
claimable_outpoints.push(commitment_package);
34933493
self.pending_monitor_events.push(MonitorEvent::CommitmentTxConfirmed(self.funding_info.0));
3494-
let commitment_tx = self.onchain_tx_handler.get_fully_signed_holder_tx(&self.funding_redeemscript);
3494+
// Although we aren't signing the transaction directly here, the transaction will be signed
3495+
// in the claim that is queued to OnchainTxHandler. We set holder_tx_signed here to reject
3496+
// new channel updates.
34953497
self.holder_tx_signed = true;
34963498
// We can't broadcast our HTLC transactions while the commitment transaction is
34973499
// unconfirmed. We'll delay doing so until we detect the confirmed commitment in
@@ -3501,7 +3503,8 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
35013503
// assuming it gets confirmed in the next block. Sadly, we have code which considers
35023504
// "not yet confirmed" things as discardable, so we cannot do that here.
35033505
let (mut new_outpoints, _) = self.get_broadcasted_holder_claims(&self.current_holder_commitment_tx, self.best_block.height());
3504-
let new_outputs = self.get_broadcasted_holder_watch_outputs(&self.current_holder_commitment_tx, &commitment_tx);
3506+
let unsigned_commitment_tx = self.onchain_tx_handler.get_unsigned_holder_commitment_tx();
3507+
let new_outputs = self.get_broadcasted_holder_watch_outputs(&self.current_holder_commitment_tx, &unsigned_commitment_tx);
35053508
if !new_outputs.is_empty() {
35063509
watch_outputs.push((self.current_holder_commitment_tx.txid.clone(), new_outputs));
35073510
}

lightning/src/chain/onchaintx.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1123,6 +1123,10 @@ impl<ChannelSigner: WriteableEcdsaChannelSigner> OnchainTxHandler<ChannelSigner>
11231123
ret
11241124
}
11251125

1126+
pub(crate) fn get_unsigned_holder_commitment_tx(&self) -> Transaction {
1127+
self.holder_commitment.trust().built_transaction().transaction.clone()
1128+
}
1129+
11261130
//TODO: getting lastest holder transactions should be infallible and result in us "force-closing the channel", but we may
11271131
// have empty holder commitment transaction if a ChannelMonitor is asked to force-close just after OutboundV1Channel::get_funding_created,
11281132
// before providing a initial commitment transaction. For outbound channel, init ChannelMonitor at Channel::funding_signed, there is nothing

0 commit comments

Comments
 (0)