]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Rename their_to_self_delay as on_local_tx_csv
authorAntoine Riard <ariard@student.42.fr>
Thu, 30 Apr 2020 01:22:28 +0000 (21:22 -0400)
committerAntoine Riard <ariard@student.42.fr>
Tue, 12 May 2020 21:41:33 +0000 (17:41 -0400)
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
lightning/src/ln/onchaintx.rs

index 0a8c4bd46e23a0c2e3e230ac03a95e6e9cd24055..f547bcc2370895716823a3b9054fd5f17997dd3c 100644 (file)
@@ -743,7 +743,7 @@ pub struct ChannelMonitor<ChanSigner: ChannelKeys> {
        // first is the idx of the first of the two revocation points
        their_cur_revocation_points: Option<(u64, PublicKey, Option<PublicKey>)>,
 
-       their_to_self_delay: u16,
+       on_local_tx_csv: u16,
 
        commitment_secrets: CounterpartyCommitmentSecrets,
        remote_claimable_outpoints: HashMap<Txid, Vec<(HTLCOutputInCommitment, Option<Box<HTLCSource>>)>>,
@@ -832,7 +832,7 @@ impl<ChanSigner: ChannelKeys> PartialEq for ChannelMonitor<ChanSigner> {
                        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<ChanSigner: ChannelKeys + Writeable> ChannelMonitor<ChanSigner> {
                        },
                }
 
-               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<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
        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<Logger>) -> ChannelMonitor<ChanSigner> {
@@ -1073,7 +1073,7 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
 
                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<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
                        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<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
        /// 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<Signature>, Option<HTLCSource>)>) -> 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<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
                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<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
                                        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<ChanSigner: ChannelKeys + Readable> ReadableArgs<Arc<Logger>> 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<ChanSigner: ChannelKeys + Readable> ReadableArgs<Arc<Logger>> for (BlockHas
                        channel_value_satoshis,
                        their_cur_revocation_points,
 
-                       their_to_self_delay,
+                       on_local_tx_csv,
 
                        commitment_secrets,
                        remote_claimable_outpoints,
index bfd54d33fdd4a608f1786cf2f34a558c7ae56ac1..cb0be6576a8dccefda447f8b6350357bb336a4ef 100644 (file)
@@ -241,7 +241,7 @@ pub struct OnchainTxHandler<ChanSigner: ChannelKeys> {
        local_htlc_sigs: Option<Vec<Option<(usize, Signature)>>>,
        prev_local_commitment: Option<LocalCommitmentTransaction>,
        prev_local_htlc_sigs: Option<Vec<Option<(usize, Signature)>>>,
-       local_csv: u16,
+       on_local_tx_csv: u16,
 
        key_storage: ChanSigner,
 
@@ -286,7 +286,7 @@ impl<ChanSigner: ChannelKeys + Writeable> OnchainTxHandler<ChanSigner> {
                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<ChanSigner: ChannelKeys + Readable> ReadableArgs<Arc<Logger>> 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<ChanSigner: ChannelKeys + Readable> ReadableArgs<Arc<Logger>> 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<ChanSigner: ChannelKeys + Readable> ReadableArgs<Arc<Logger>> for OnchainTx
 }
 
 impl<ChanSigner: ChannelKeys> OnchainTxHandler<ChanSigner> {
-       pub(super) fn new(destination_script: Script, keys: ChanSigner, local_csv: u16, logger: Arc<Logger>) -> Self {
+       pub(super) fn new(destination_script: Script, keys: ChanSigner, on_local_tx_csv: u16, logger: Arc<Logger>) -> Self {
 
                let key_storage = keys;
 
@@ -409,7 +409,7 @@ impl<ChanSigner: ChannelKeys> OnchainTxHandler<ChanSigner> {
                        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<ChanSigner: ChannelKeys> OnchainTxHandler<ChanSigner> {
 
        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<ChanSigner: ChannelKeys> OnchainTxHandler<ChanSigner> {
        }
        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<ChanSigner: ChannelKeys> OnchainTxHandler<ChanSigner> {
                                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<ChanSigner: ChannelKeys> OnchainTxHandler<ChanSigner> {
                                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));
                                }
                        }
                }