Skip to content

Commit

Permalink
Make txid check first check in tx_signatures handling
Browse files Browse the repository at this point in the history
  • Loading branch information
dunxen committed Nov 21, 2024
1 parent 9363bcc commit 6790187
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions lightning/src/ln/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5701,6 +5701,14 @@ impl<SP: Deref> Channel<SP> where
}

if let Some(ref mut signing_session) = self.interactive_tx_signing_session {
if msg.tx_hash != signing_session.unsigned_tx.compute_txid() {
return Err(ChannelError::Close(
(
"The txid for the transaction does not match".to_string(),
ClosureReason::HolderForceClosed { broadcasted_latest_txn: Some(false) },
)));
}

if msg.witnesses.len() != signing_session.remote_inputs_count() {
return Err(ChannelError::Warn(
"Witness count did not match contributed input count".to_string()
Expand All @@ -5722,14 +5730,6 @@ impl<SP: Deref> Channel<SP> where
// for spending. Doesn't seem to be anything in rust-bitcoin.
}

if msg.tx_hash != signing_session.unsigned_tx.compute_txid() {
return Err(ChannelError::Close(
(
"The txid for the transaction does not match".to_string(),
ClosureReason::HolderForceClosed { broadcasted_latest_txn: Some(false) },
)));
}

let (tx_signatures_opt, funding_tx_opt) = signing_session.received_tx_signatures(msg.clone())
.map_err(|_| ChannelError::Warn("Witness count did not match contributed input count".to_string()))?;
if funding_tx_opt.is_some() {
Expand Down

0 comments on commit 6790187

Please sign in to comment.