Skip to content

Commit 92ff728

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 9755914 commit 92ff728

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
@@ -6002,6 +6002,14 @@ impl<SP: Deref> FundedChannel<SP> where
60026002
}
60036003

60046004
if let Some(ref mut signing_session) = self.interactive_tx_signing_session {
6005+
if msg.tx_hash != signing_session.unsigned_tx.compute_txid() {
6006+
return Err(ChannelError::Close(
6007+
(
6008+
"The txid for the transaction does not match".to_string(),
6009+
ClosureReason::HolderForceClosed { broadcasted_latest_txn: Some(false) },
6010+
)));
6011+
}
6012+
60056013
if msg.witnesses.len() != signing_session.remote_inputs_count() {
60066014
return Err(ChannelError::Warn(
60076015
"Witness count did not match contributed input count".to_string()
@@ -6023,14 +6031,6 @@ impl<SP: Deref> FundedChannel<SP> where
60236031
// for spending. Doesn't seem to be anything in rust-bitcoin.
60246032
}
60256033

6026-
if msg.tx_hash != signing_session.unsigned_tx.compute_txid() {
6027-
return Err(ChannelError::Close(
6028-
(
6029-
"The txid for the transaction does not match".to_string(),
6030-
ClosureReason::HolderForceClosed { broadcasted_latest_txn: Some(false) },
6031-
)));
6032-
}
6033-
60346034
let (tx_signatures_opt, funding_tx_opt) = signing_session.received_tx_signatures(msg.clone())
60356035
.map_err(|_| ChannelError::Warn("Witness count did not match contributed input count".to_string()))?;
60366036
if funding_tx_opt.is_some() {

0 commit comments

Comments
 (0)