Skip to content

Commit 910cdc8

Browse files
committed
Move txid check to start of tx_signatures handling
By moving the txid check to the start of `tx_signatures` handling, we can avoid spurious witness count mismatch errors. Also, it just makes more sense to check the txid earlier.
1 parent 99f5126 commit 910cdc8

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

lightning/src/ln/channel.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6140,6 +6140,14 @@ impl<SP: Deref> FundedChannel<SP> where
61406140
}
61416141

61426142
if let Some(ref mut signing_session) = self.interactive_tx_signing_session {
6143+
if msg.tx_hash != signing_session.unsigned_tx.compute_txid() {
6144+
return Err(ChannelError::Close(
6145+
(
6146+
"The txid for the transaction does not match".to_string(),
6147+
ClosureReason::HolderForceClosed { broadcasted_latest_txn: Some(false) },
6148+
)));
6149+
}
6150+
61436151
if msg.witnesses.len() != signing_session.remote_inputs_count() {
61446152
return Err(ChannelError::Warn(
61456153
"Witness count did not match contributed input count".to_string()
@@ -6161,14 +6169,6 @@ impl<SP: Deref> FundedChannel<SP> where
61616169
// for spending. Doesn't seem to be anything in rust-bitcoin.
61626170
}
61636171

6164-
if msg.tx_hash != signing_session.unsigned_tx.compute_txid() {
6165-
return Err(ChannelError::Close(
6166-
(
6167-
"The txid for the transaction does not match".to_string(),
6168-
ClosureReason::HolderForceClosed { broadcasted_latest_txn: Some(false) },
6169-
)));
6170-
}
6171-
61726172
let (tx_signatures_opt, funding_tx_opt) = signing_session.received_tx_signatures(msg.clone())
61736173
.map_err(|_| ChannelError::Warn("Witness count did not match contributed input count".to_string()))?;
61746174
if funding_tx_opt.is_some() {

0 commit comments

Comments
 (0)