From 53884e3e55d0a205304c2e0e00a35185bd558a56 Mon Sep 17 00:00:00 2001 From: Antoine Riard Date: Wed, 29 Apr 2020 21:22:28 -0400 Subject: [PATCH] Rename their_to_self_delay as on_local_tx_csv on_remote_tx_csv is the CSV delay encumbering remote transactions revokable outputs as required by local. on_local_tx_csv is the CSV delay encumbering local transactions revokable outputs as required by remote. Local/remote is here defined from a code processing viewpoint, process running this code is "local". --- lightning/src/ln/channelmonitor.rs | 22 +++++++++++----------- lightning/src/ln/onchaintx.rs | 20 ++++++++++---------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/lightning/src/ln/channelmonitor.rs b/lightning/src/ln/channelmonitor.rs index 0a8c4bd46..f547bcc23 100644 --- a/lightning/src/ln/channelmonitor.rs +++ b/lightning/src/ln/channelmonitor.rs @@ -743,7 +743,7 @@ pub struct ChannelMonitor { // first is the idx of the first of the two revocation points their_cur_revocation_points: Option<(u64, PublicKey, Option)>, - their_to_self_delay: u16, + on_local_tx_csv: u16, commitment_secrets: CounterpartyCommitmentSecrets, remote_claimable_outpoints: HashMap>)>>, @@ -832,7 +832,7 @@ impl PartialEq for ChannelMonitor { self.funding_redeemscript != other.funding_redeemscript || self.channel_value_satoshis != other.channel_value_satoshis || self.their_cur_revocation_points != other.their_cur_revocation_points || - self.their_to_self_delay != other.their_to_self_delay || + self.on_local_tx_csv != other.on_local_tx_csv || self.commitment_secrets != other.commitment_secrets || self.remote_claimable_outpoints != other.remote_claimable_outpoints || self.remote_commitment_txn_on_chain != other.remote_commitment_txn_on_chain || @@ -927,7 +927,7 @@ impl ChannelMonitor { }, } - writer.write_all(&byte_utils::be16_to_array(self.their_to_self_delay))?; + writer.write_all(&byte_utils::be16_to_array(self.on_local_tx_csv))?; self.commitment_secrets.write(writer)?; @@ -1060,7 +1060,7 @@ impl ChannelMonitor { pub(super) fn new(keys: ChanSigner, shutdown_pubkey: &PublicKey, on_remote_tx_csv: u16, destination_script: &Script, funding_info: (OutPoint, Script), remote_htlc_base_key: &PublicKey, remote_delayed_payment_base_key: &PublicKey, - their_to_self_delay: u16, funding_redeemscript: Script, channel_value_satoshis: u64, + on_local_tx_csv: u16, funding_redeemscript: Script, channel_value_satoshis: u64, commitment_transaction_number_obscure_factor: u64, initial_local_commitment_tx: LocalCommitmentTransaction, logger: Arc) -> ChannelMonitor { @@ -1073,7 +1073,7 @@ impl ChannelMonitor { let remote_tx_cache = RemoteTxCache { remote_delayed_payment_base_key: *remote_delayed_payment_base_key, remote_htlc_base_key: *remote_htlc_base_key, on_remote_tx_csv, per_htlc: HashMap::new() }; - let mut onchain_tx_handler = OnchainTxHandler::new(destination_script.clone(), keys.clone(), their_to_self_delay, logger.clone()); + let mut onchain_tx_handler = OnchainTxHandler::new(destination_script.clone(), keys.clone(), on_local_tx_csv, logger.clone()); let local_tx_sequence = initial_local_commitment_tx.unsigned_tx.input[0].sequence as u64; let local_tx_locktime = initial_local_commitment_tx.unsigned_tx.lock_time as u64; @@ -1113,7 +1113,7 @@ impl ChannelMonitor { channel_value_satoshis: channel_value_satoshis, their_cur_revocation_points: None, - their_to_self_delay, + on_local_tx_csv, commitment_secrets: CounterpartyCommitmentSecrets::new(), remote_claimable_outpoints: HashMap::new(), @@ -1246,7 +1246,7 @@ impl ChannelMonitor { /// monitor watches for timeouts and may broadcast it if we approach such a timeout. Thus, it /// is important that any clones of this channel monitor (including remote clones) by kept /// up-to-date as our local commitment transaction is updated. - /// Panics if set_their_to_self_delay has never been called. + /// Panics if set_on_local_tx_csv has never been called. pub(super) fn provide_latest_local_commitment_tx_info(&mut self, commitment_tx: LocalCommitmentTransaction, htlc_outputs: Vec<(HTLCOutputInCommitment, Option, Option)>) -> Result<(), MonitorUpdateError> { if self.local_tx_signed { return Err(MonitorUpdateError("A local commitment tx has already been signed, no new local commitment txn can be sent to our counterparty")); @@ -1644,7 +1644,7 @@ impl ChannelMonitor { let mut claim_requests = Vec::with_capacity(local_tx.htlc_outputs.len()); let mut watch_outputs = Vec::with_capacity(local_tx.htlc_outputs.len()); - let redeemscript = chan_utils::get_revokeable_redeemscript(&local_tx.revocation_key, self.their_to_self_delay, &local_tx.delayed_payment_key); + let redeemscript = chan_utils::get_revokeable_redeemscript(&local_tx.revocation_key, self.on_local_tx_csv, &local_tx.delayed_payment_key); let broadcasted_local_revokable_script = Some((redeemscript.to_v0_p2wsh(), local_tx.per_commitment_point.clone(), local_tx.revocation_key.clone())); for &(ref htlc, _, _) in local_tx.htlc_outputs.iter() { @@ -2143,7 +2143,7 @@ impl ChannelMonitor { spendable_output = Some(SpendableOutputDescriptor::DynamicOutputP2WSH { outpoint: BitcoinOutPoint { txid: tx.txid(), vout: i as u32 }, per_commitment_point: broadcasted_local_revokable_script.1, - to_self_delay: self.their_to_self_delay, + to_self_delay: self.on_local_tx_csv, output: outp.clone(), key_derivation_params: self.keys.key_derivation_params(), remote_revocation_pubkey: broadcasted_local_revokable_script.2.clone(), @@ -2269,7 +2269,7 @@ impl ReadableArgs> for (BlockHas } }; - let their_to_self_delay: u16 = Readable::read(reader)?; + let on_local_tx_csv: u16 = Readable::read(reader)?; let commitment_secrets = Readable::read(reader)?; @@ -2463,7 +2463,7 @@ impl ReadableArgs> for (BlockHas channel_value_satoshis, their_cur_revocation_points, - their_to_self_delay, + on_local_tx_csv, commitment_secrets, remote_claimable_outpoints, diff --git a/lightning/src/ln/onchaintx.rs b/lightning/src/ln/onchaintx.rs index bfd54d33f..cb0be6576 100644 --- a/lightning/src/ln/onchaintx.rs +++ b/lightning/src/ln/onchaintx.rs @@ -241,7 +241,7 @@ pub struct OnchainTxHandler { local_htlc_sigs: Option>>, prev_local_commitment: Option, prev_local_htlc_sigs: Option>>, - local_csv: u16, + on_local_tx_csv: u16, key_storage: ChanSigner, @@ -286,7 +286,7 @@ impl OnchainTxHandler { self.prev_local_commitment.write(writer)?; self.prev_local_htlc_sigs.write(writer)?; - self.local_csv.write(writer)?; + self.on_local_tx_csv.write(writer)?; self.key_storage.write(writer)?; @@ -334,7 +334,7 @@ impl ReadableArgs> for OnchainTx let prev_local_commitment = Readable::read(reader)?; let prev_local_htlc_sigs = Readable::read(reader)?; - let local_csv = Readable::read(reader)?; + let on_local_tx_csv = Readable::read(reader)?; let key_storage = Readable::read(reader)?; @@ -387,7 +387,7 @@ impl ReadableArgs> for OnchainTx local_htlc_sigs, prev_local_commitment, prev_local_htlc_sigs, - local_csv, + on_local_tx_csv, key_storage, claimable_outpoints, pending_claim_requests, @@ -399,7 +399,7 @@ impl ReadableArgs> for OnchainTx } impl OnchainTxHandler { - pub(super) fn new(destination_script: Script, keys: ChanSigner, local_csv: u16, logger: Arc) -> Self { + pub(super) fn new(destination_script: Script, keys: ChanSigner, on_local_tx_csv: u16, logger: Arc) -> Self { let key_storage = keys; @@ -409,7 +409,7 @@ impl OnchainTxHandler { local_htlc_sigs: None, prev_local_commitment: None, prev_local_htlc_sigs: None, - local_csv, + on_local_tx_csv, key_storage, pending_claim_requests: HashMap::new(), claimable_outpoints: HashMap::new(), @@ -885,7 +885,7 @@ impl OnchainTxHandler { fn sign_latest_local_htlcs(&mut self) { if let Some(ref local_commitment) = self.local_commitment { - if let Ok(sigs) = self.key_storage.sign_local_commitment_htlc_transactions(local_commitment, self.local_csv, &self.secp_ctx) { + if let Ok(sigs) = self.key_storage.sign_local_commitment_htlc_transactions(local_commitment, self.on_local_tx_csv, &self.secp_ctx) { self.local_htlc_sigs = Some(Vec::new()); let ret = self.local_htlc_sigs.as_mut().unwrap(); for (htlc_idx, (local_sig, &(ref htlc, _))) in sigs.iter().zip(local_commitment.per_htlc.iter()).enumerate() { @@ -901,7 +901,7 @@ impl OnchainTxHandler { } fn sign_prev_local_htlcs(&mut self) { if let Some(ref local_commitment) = self.prev_local_commitment { - if let Ok(sigs) = self.key_storage.sign_local_commitment_htlc_transactions(local_commitment, self.local_csv, &self.secp_ctx) { + if let Ok(sigs) = self.key_storage.sign_local_commitment_htlc_transactions(local_commitment, self.on_local_tx_csv, &self.secp_ctx) { self.prev_local_htlc_sigs = Some(Vec::new()); let ret = self.prev_local_htlc_sigs.as_mut().unwrap(); for (htlc_idx, (local_sig, &(ref htlc, _))) in sigs.iter().zip(local_commitment.per_htlc.iter()).enumerate() { @@ -953,7 +953,7 @@ impl OnchainTxHandler { if let &Some(ref htlc_sigs) = &self.local_htlc_sigs { let &(ref htlc_idx, ref htlc_sig) = htlc_sigs[outp.vout as usize].as_ref().unwrap(); htlc_tx = Some(self.local_commitment.as_ref().unwrap() - .get_signed_htlc_tx(*htlc_idx, htlc_sig, preimage, self.local_csv)); + .get_signed_htlc_tx(*htlc_idx, htlc_sig, preimage, self.on_local_tx_csv)); } } } @@ -964,7 +964,7 @@ impl OnchainTxHandler { if let &Some(ref htlc_sigs) = &self.prev_local_htlc_sigs { let &(ref htlc_idx, ref htlc_sig) = htlc_sigs[outp.vout as usize].as_ref().unwrap(); htlc_tx = Some(self.prev_local_commitment.as_ref().unwrap() - .get_signed_htlc_tx(*htlc_idx, htlc_sig, preimage, self.local_csv)); + .get_signed_htlc_tx(*htlc_idx, htlc_sig, preimage, self.on_local_tx_csv)); } } } -- 2.39.5