Skip to content

Commit b636731

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 01760ab commit b636731

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
@@ -5709,6 +5709,14 @@ impl<SP: Deref> Channel<SP> where
57095709
}
57105710

57115711
if let Some(ref mut signing_session) = self.interactive_tx_signing_session {
5712+
if msg.tx_hash != signing_session.unsigned_tx.compute_txid() {
5713+
return Err(ChannelError::Close(
5714+
(
5715+
"The txid for the transaction does not match".to_string(),
5716+
ClosureReason::HolderForceClosed { broadcasted_latest_txn: Some(false) },
5717+
)));
5718+
}
5719+
57125720
if msg.witnesses.len() != signing_session.remote_inputs_count() {
57135721
return Err(ChannelError::Warn(
57145722
"Witness count did not match contributed input count".to_string()
@@ -5730,14 +5738,6 @@ impl<SP: Deref> Channel<SP> where
57305738
// for spending. Doesn't seem to be anything in rust-bitcoin.
57315739
}
57325740

5733-
if msg.tx_hash != signing_session.unsigned_tx.compute_txid() {
5734-
return Err(ChannelError::Close(
5735-
(
5736-
"The txid for the transaction does not match".to_string(),
5737-
ClosureReason::HolderForceClosed { broadcasted_latest_txn: Some(false) },
5738-
)));
5739-
}
5740-
57415741
let (tx_signatures_opt, funding_tx_opt) = signing_session.received_tx_signatures(msg.clone())
57425742
.map_err(|_| ChannelError::Warn("Witness count did not match contributed input count".to_string()))?;
57435743
if funding_tx_opt.is_some() {

0 commit comments

Comments
 (0)