Skip to content

Commit e1e69e0

Browse files
committed
f DRY secret key
1 parent 0c7474d commit e1e69e0

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lightning/src/ln/channel.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2742,8 +2742,10 @@ impl<Signer: Sign> Channel<Signer> {
27422742
return Err(ChannelError::Close("Peer sent revoke_and_ack after we'd started exchanging closing_signeds".to_owned()));
27432743
}
27442744

2745+
let secret = secp_check!(SecretKey::from_slice(&msg.per_commitment_secret), "Peer provided an invalid per_commitment_secret".to_owned());
2746+
27452747
if let Some(counterparty_prev_commitment_point) = self.counterparty_prev_commitment_point {
2746-
if PublicKey::from_secret_key(&self.secp_ctx, &secp_check!(SecretKey::from_slice(&msg.per_commitment_secret), "Peer provided an invalid per_commitment_secret".to_owned())) != counterparty_prev_commitment_point {
2748+
if PublicKey::from_secret_key(&self.secp_ctx, &secret) != counterparty_prev_commitment_point {
27472749
return Err(ChannelError::Close("Got a revoke commitment secret which didn't correspond to their current pubkey".to_owned()));
27482750
}
27492751
}
@@ -2765,8 +2767,6 @@ impl<Signer: Sign> Channel<Signer> {
27652767
*self.next_remote_commitment_tx_fee_info_cached.lock().unwrap() = None;
27662768
}
27672769

2768-
let secret = SecretKey::from_slice(&msg.per_commitment_secret)
2769-
.map_err(|_| ChannelError::Close("Malformed commitment secret".to_owned()))?;
27702770
self.holder_signer.validate_counterparty_revocation(
27712771
self.cur_counterparty_commitment_transaction_number + 1,
27722772
&secret

0 commit comments

Comments
 (0)