Skip to content

Commit 3c1e603

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 cbd0999 commit 3c1e603

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
@@ -5962,6 +5962,14 @@ impl<SP: Deref> FundedChannel<SP> where
59625962
}
59635963

59645964
if let Some(ref mut signing_session) = self.interactive_tx_signing_session {
5965+
if msg.tx_hash != signing_session.unsigned_tx.compute_txid() {
5966+
return Err(ChannelError::Close(
5967+
(
5968+
"The txid for the transaction does not match".to_string(),
5969+
ClosureReason::HolderForceClosed { broadcasted_latest_txn: Some(false) },
5970+
)));
5971+
}
5972+
59655973
if msg.witnesses.len() != signing_session.remote_inputs_count() {
59665974
return Err(ChannelError::Warn(
59675975
"Witness count did not match contributed input count".to_string()
@@ -5983,14 +5991,6 @@ impl<SP: Deref> FundedChannel<SP> where
59835991
// for spending. Doesn't seem to be anything in rust-bitcoin.
59845992
}
59855993

5986-
if msg.tx_hash != signing_session.unsigned_tx.compute_txid() {
5987-
return Err(ChannelError::Close(
5988-
(
5989-
"The txid for the transaction does not match".to_string(),
5990-
ClosureReason::HolderForceClosed { broadcasted_latest_txn: Some(false) },
5991-
)));
5992-
}
5993-
59945994
let (tx_signatures_opt, funding_tx_opt) = signing_session.received_tx_signatures(msg.clone())
59955995
.map_err(|_| ChannelError::Warn("Witness count did not match contributed input count".to_string()))?;
59965996
if funding_tx_opt.is_some() {

0 commit comments

Comments
 (0)