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 commitment transaction signing a part of ChannelKeys.
This adds a new fn to ChannelKeys which is called when we generte
a new remote commitment transaction for signing. While it may be
theoretically possible to unwind state updates by disconnecting and
reconnecting as well as making appropriate state machine changes,
the effort required to get it correct likely outweighs the UX cost
of "preflighting" the requests to hardwre wallets.
let commitment_sighash = hash_to_message!(&bip143::SighashComponents::new(&commitment_tx).sighash_all(&commitment_tx.input[0],&channel_funding_script, channel_value_satoshis)[..]);
157
+
let commitment_sig = secp_ctx.sign(&commitment_sighash,&self.funding_key);
log_trace!(self,"Building commitment transaction number {} for {}, generated by {} with fee {}...", commitment_number,if local {"us"} else {"remote"},if generated_by_local {"us"} else {"remote"}, feerate_per_kw);
836
+
log_trace!(self,"Building commitment transaction number {} (really {} xor {}) for {}, generated by {} with fee {}...", commitment_number,(INITIAL_COMMITMENT_NUMBER - commitment_number),self.get_commitment_transaction_number_obscure_factor(),if local {"us"} else {"remote"},if generated_by_local {"us"} else {"remote"}, feerate_per_kw);
let remote_keys = self.build_remote_transaction_keys()?;
1520
1520
let remote_initial_commitment_tx = self.build_commitment_transaction(self.cur_remote_commitment_transaction_number,&remote_keys,false,false,self.feerate_per_kw).0;
1521
-
let remote_sighash = hash_to_message!(&bip143::SighashComponents::new(&remote_initial_commitment_tx).sighash_all(&remote_initial_commitment_tx.input[0],&funding_script,self.channel_value_satoshis)[..]);
1521
+
let remote_signature = self.local_keys.sign_remote_commitment(self.channel_value_satoshis,&self.get_funding_redeemscript(),self.feerate_per_kw,&remote_initial_commitment_tx,&remote_keys,&Vec::new(),self.our_to_self_delay,&self.secp_ctx)
1522
+
.map_err(|_| ChannelError::Close("Failed to get signatures for new commitment_signed"))?.0;
1522
1523
1523
1524
// We sign the "remote" commitment transaction, allowing them to broadcast the tx if they wish.
let funding_script = self.get_funding_redeemscript();
3226
-
3227
3226
let remote_keys = self.build_remote_transaction_keys()?;
3228
3227
let remote_initial_commitment_tx = self.build_commitment_transaction(self.cur_remote_commitment_transaction_number,&remote_keys,false,false,self.feerate_per_kw).0;
3229
-
let remote_sighash = hash_to_message!(&bip143::SighashComponents::new(&remote_initial_commitment_tx).sighash_all(&remote_initial_commitment_tx.input[0],&funding_script,self.channel_value_satoshis)[..]);
3230
-
3231
-
// We sign the "remote" commitment transaction, allowing them to broadcast the tx if they wish.
let remote_keys = self.build_remote_transaction_keys()?;
3532
3527
let remote_commitment_tx = self.build_commitment_transaction(self.cur_remote_commitment_transaction_number,&remote_keys,false,true, feerate_per_kw);
3533
-
let remote_commitment_txid = remote_commitment_tx.0.txid();
3534
-
let remote_sighash = hash_to_message!(&bip143::SighashComponents::new(&remote_commitment_tx.0).sighash_all(&remote_commitment_tx.0.input[0],&funding_script,self.channel_value_satoshis)[..]);
3535
-
let our_sig = self.secp_ctx.sign(&remote_sighash,self.local_keys.funding_key());
3536
-
log_trace!(self,"Signing remote commitment tx {} with redeemscript {} with pubkey {} -> {}", encode::serialize_hex(&remote_commitment_tx.0), encode::serialize_hex(&funding_script), log_bytes!(PublicKey::from_secret_key(&self.secp_ctx,self.local_keys.funding_key()).serialize()), log_bytes!(our_sig.serialize_compact()[..]));
let res = self.local_keys.sign_remote_commitment(self.channel_value_satoshis,&self.get_funding_redeemscript(), feerate_per_kw,&remote_commitment_tx.0,&remote_keys,&htlcs,self.our_to_self_delay,&self.secp_ctx)
3537
+
.map_err(|_| ChannelError::Close("Failed to get signatures for new commitment_signed"))?;
3538
+
signature = res.0;
3539
+
htlc_signatures = res.1;
3540
+
3541
+
log_trace!(self,"Signed remote commitment tx {} with redeemscript {} -> {}",
0 commit comments