Skip to content

Commit 9fdb6ff

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 4061675 commit 9fdb6ff

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
@@ -5711,6 +5711,14 @@ impl<SP: Deref> Channel<SP> where
57115711
}
57125712

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

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

0 commit comments

Comments
 (0)