You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Make ChannelSigner solely responsible for validating commitment sigs
As part of the custom transactions project, we want to make channel
generic over any funding, htlc, and revokeable scripts used on-chain.
Hence, this commit removes the validation of holder commitment
signatures from channel, as it requires building the funding, htlc, and
revokeable scripts to create the expected sighash.
This signature validation is now the sole responsibility of
`ChannelSigner::validate_holder_commitment`.
This commit updates `InMemorySigner` to honor this new API contract.
if let Err(_) = self.secp_ctx.verify_ecdsa(&sighash, &msg.signature, &funding.counterparty_funding_pubkey()) {
4225
-
return Err(ChannelError::close("Invalid commitment tx signature from peer".to_owned()));
4226
-
}
4227
-
bitcoin_tx.txid
4228
-
};
4187
+
4188
+
if msg.htlc_signatures.len() != commitment_data.tx.nondust_htlcs().len() {
4189
+
return Err(ChannelError::close(format!("Got wrong number of HTLC signatures ({}) from remote. It must be {}", msg.htlc_signatures.len(), commitment_data.tx.nondust_htlcs().len())));
4190
+
}
4191
+
4192
+
let holder_commitment_tx = HolderCommitmentTransaction::new(
4193
+
commitment_data.tx,
4194
+
msg.signature,
4195
+
msg.htlc_signatures.clone(),
4196
+
&funding.get_holder_pubkeys().funding_pubkey,
4197
+
funding.counterparty_funding_pubkey()
4198
+
);
4199
+
4200
+
log_trace!(logger, "Validating commitment_signed commitment in channel {}", self.channel_id());
.map_err(|_| ChannelError::close("Failed to validate our commitment".to_owned()))?;
4229
4208
4230
4209
// If our counterparty updated the channel fee in this commitment transaction, check that
4231
4210
// they can actually afford the new fee now.
@@ -4257,28 +4236,10 @@ where
4257
4236
}
4258
4237
}
4259
4238
4260
-
if msg.htlc_signatures.len() != commitment_data.tx.nondust_htlcs().len() {
4261
-
return Err(ChannelError::close(format!("Got wrong number of HTLC signatures ({}) from remote. It must be {}", msg.htlc_signatures.len(), commitment_data.tx.nondust_htlcs().len())));
4262
-
}
4263
-
4264
-
let holder_keys = commitment_data.tx.trust().keys();
4265
-
let mut nondust_htlc_sources = Vec::with_capacity(commitment_data.tx.nondust_htlcs().len());
4266
-
let mut dust_htlcs = Vec::with_capacity(commitment_data.htlcs_included.len() - commitment_data.tx.nondust_htlcs().len());
4267
-
for (idx, (htlc, mut source_opt)) in commitment_data.htlcs_included.into_iter().enumerate() {
4239
+
let mut nondust_htlc_sources = Vec::with_capacity(holder_commitment_tx.nondust_htlcs().len());
4240
+
let mut dust_htlcs = Vec::with_capacity(commitment_data.htlcs_included.len() - holder_commitment_tx.nondust_htlcs().len());
4241
+
for (htlc, mut source_opt) in commitment_data.htlcs_included.into_iter() {
4268
4242
if let Some(_) = htlc.transaction_output_index {
4269
-
let htlc_tx = chan_utils::build_htlc_transaction(&commitment_txid, commitment_data.tx.feerate_per_kw(),
0 commit comments