Skip to content

Commit eb18913

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 ac060f9 commit eb18913

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
@@ -6133,6 +6133,14 @@ impl<SP: Deref> FundedChannel<SP> where
61336133
}
61346134

61356135
if let Some(ref mut signing_session) = self.interactive_tx_signing_session {
6136+
if msg.tx_hash != signing_session.unsigned_tx.compute_txid() {
6137+
return Err(ChannelError::Close(
6138+
(
6139+
"The txid for the transaction does not match".to_string(),
6140+
ClosureReason::HolderForceClosed { broadcasted_latest_txn: Some(false) },
6141+
)));
6142+
}
6143+
61366144
if msg.witnesses.len() != signing_session.remote_inputs_count() {
61376145
return Err(ChannelError::Warn(
61386146
"Witness count did not match contributed input count".to_string()
@@ -6154,14 +6162,6 @@ impl<SP: Deref> FundedChannel<SP> where
61546162
// for spending. Doesn't seem to be anything in rust-bitcoin.
61556163
}
61566164

6157-
if msg.tx_hash != signing_session.unsigned_tx.compute_txid() {
6158-
return Err(ChannelError::Close(
6159-
(
6160-
"The txid for the transaction does not match".to_string(),
6161-
ClosureReason::HolderForceClosed { broadcasted_latest_txn: Some(false) },
6162-
)));
6163-
}
6164-
61656165
let (tx_signatures_opt, funding_tx_opt) = signing_session.received_tx_signatures(msg.clone())
61666166
.map_err(|_| ChannelError::Warn("Witness count did not match contributed input count".to_string()))?;
61676167
if funding_tx_opt.is_some() {

0 commit comments

Comments
 (0)