Skip to content

Commit d1d52cb

Browse files
author
Antoine Riard
committed
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".
1 parent 42db6d7 commit d1d52cb

File tree

2 files changed

+21
-21
lines changed

2 files changed

+21
-21
lines changed

lightning/src/ln/channelmonitor.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -757,7 +757,7 @@ pub struct ChannelMonitor<ChanSigner: ChannelKeys> {
757757
// first is the idx of the first of the two revocation points
758758
their_cur_revocation_points: Option<(u64, PublicKey, Option<PublicKey>)>,
759759

760-
their_to_self_delay: u16,
760+
on_local_tx_csv: u16,
761761

762762
commitment_secrets: CounterpartyCommitmentSecrets,
763763
remote_claimable_outpoints: HashMap<Txid, Vec<(HTLCOutputInCommitment, Option<Box<HTLCSource>>)>>,
@@ -846,7 +846,7 @@ impl<ChanSigner: ChannelKeys> PartialEq for ChannelMonitor<ChanSigner> {
846846
self.funding_redeemscript != other.funding_redeemscript ||
847847
self.channel_value_satoshis != other.channel_value_satoshis ||
848848
self.their_cur_revocation_points != other.their_cur_revocation_points ||
849-
self.their_to_self_delay != other.their_to_self_delay ||
849+
self.on_local_tx_csv != other.on_local_tx_csv ||
850850
self.commitment_secrets != other.commitment_secrets ||
851851
self.remote_claimable_outpoints != other.remote_claimable_outpoints ||
852852
self.remote_commitment_txn_on_chain != other.remote_commitment_txn_on_chain ||
@@ -947,7 +947,7 @@ impl<ChanSigner: ChannelKeys + Writeable> ChannelMonitor<ChanSigner> {
947947
},
948948
}
949949

950-
writer.write_all(&byte_utils::be16_to_array(self.their_to_self_delay))?;
950+
writer.write_all(&byte_utils::be16_to_array(self.on_local_tx_csv))?;
951951

952952
self.commitment_secrets.write(writer)?;
953953

@@ -1080,7 +1080,7 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
10801080
pub(super) fn new(keys: ChanSigner, shutdown_pubkey: &PublicKey,
10811081
on_remote_tx_csv: u16, destination_script: &Script, funding_info: (OutPoint, Script),
10821082
remote_htlc_base_key: &PublicKey, remote_delayed_payment_base_key: &PublicKey,
1083-
their_to_self_delay: u16, funding_redeemscript: Script, channel_value_satoshis: u64,
1083+
on_local_tx_csv: u16, funding_redeemscript: Script, channel_value_satoshis: u64,
10841084
commitment_transaction_number_obscure_factor: u64,
10851085
initial_local_commitment_tx: LocalCommitmentTransaction,
10861086
logger: Arc<Logger>) -> ChannelMonitor<ChanSigner> {
@@ -1091,7 +1091,7 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
10911091

10921092
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() };
10931093

1094-
let mut onchain_tx_handler = OnchainTxHandler::new(destination_script.clone(), keys.clone(), their_to_self_delay, logger.clone());
1094+
let mut onchain_tx_handler = OnchainTxHandler::new(destination_script.clone(), keys.clone(), on_local_tx_csv, logger.clone());
10951095

10961096
let local_tx_sequence = initial_local_commitment_tx.unsigned_tx.input[0].sequence as u64;
10971097
let local_tx_locktime = initial_local_commitment_tx.unsigned_tx.lock_time as u64;
@@ -1131,7 +1131,7 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
11311131
channel_value_satoshis: channel_value_satoshis,
11321132
their_cur_revocation_points: None,
11331133

1134-
their_to_self_delay,
1134+
on_local_tx_csv,
11351135

11361136
commitment_secrets: CounterpartyCommitmentSecrets::new(),
11371137
remote_claimable_outpoints: HashMap::new(),
@@ -1273,7 +1273,7 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
12731273
/// monitor watches for timeouts and may broadcast it if we approach such a timeout. Thus, it
12741274
/// is important that any clones of this channel monitor (including remote clones) by kept
12751275
/// up-to-date as our local commitment transaction is updated.
1276-
/// Panics if set_their_to_self_delay has never been called.
1276+
/// Panics if set_on_local_tx_csv has never been called.
12771277
pub(super) fn provide_latest_local_commitment_tx_info(&mut self, commitment_tx: LocalCommitmentTransaction, htlc_outputs: Vec<(HTLCOutputInCommitment, Option<Signature>, Option<HTLCSource>)>) -> Result<(), MonitorUpdateError> {
12781278
if self.local_tx_signed {
12791279
return Err(MonitorUpdateError("A local commitment tx has already been signed, no new local commitment txn can be sent to our counterparty"));
@@ -1683,7 +1683,7 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
16831683
let mut claim_requests = Vec::with_capacity(local_tx.htlc_outputs.len());
16841684
let mut watch_outputs = Vec::with_capacity(local_tx.htlc_outputs.len());
16851685

1686-
let redeemscript = chan_utils::get_revokeable_redeemscript(&local_tx.revocation_key, self.their_to_self_delay, &local_tx.delayed_payment_key);
1686+
let redeemscript = chan_utils::get_revokeable_redeemscript(&local_tx.revocation_key, self.on_local_tx_csv, &local_tx.delayed_payment_key);
16871687
let broadcasted_local_revokable_script = Some((redeemscript.to_v0_p2wsh(), local_tx.per_commitment_point.clone(), redeemscript));
16881688

16891689
for &(ref htlc, _, _) in local_tx.htlc_outputs.iter() {
@@ -2190,7 +2190,7 @@ impl<ChanSigner: ChannelKeys> ChannelMonitor<ChanSigner> {
21902190
outpoint: BitcoinOutPoint { txid: tx.txid(), vout: i as u32 },
21912191
per_commitment_point: broadcasted_local_revokable_script.1,
21922192
witness_script: broadcasted_local_revokable_script.2.clone(),
2193-
to_self_delay: self.their_to_self_delay,
2193+
to_self_delay: self.on_local_tx_csv,
21942194
output: outp.clone(),
21952195
});
21962196
break;
@@ -2324,7 +2324,7 @@ impl<ChanSigner: ChannelKeys + Readable> ReadableArgs<Arc<Logger>> for (BlockHas
23242324
}
23252325
};
23262326

2327-
let their_to_self_delay: u16 = Readable::read(reader)?;
2327+
let on_local_tx_csv: u16 = Readable::read(reader)?;
23282328

23292329
let commitment_secrets = Readable::read(reader)?;
23302330

@@ -2518,7 +2518,7 @@ impl<ChanSigner: ChannelKeys + Readable> ReadableArgs<Arc<Logger>> for (BlockHas
25182518
channel_value_satoshis,
25192519
their_cur_revocation_points,
25202520

2521-
their_to_self_delay,
2521+
on_local_tx_csv,
25222522

25232523
commitment_secrets,
25242524
remote_claimable_outpoints,

lightning/src/ln/onchaintx.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ pub struct OnchainTxHandler<ChanSigner: ChannelKeys> {
241241
local_htlc_sigs: Option<Vec<Option<(usize, Signature)>>>,
242242
prev_local_commitment: Option<LocalCommitmentTransaction>,
243243
prev_local_htlc_sigs: Option<Vec<Option<(usize, Signature)>>>,
244-
local_csv: u16,
244+
on_local_tx_csv: u16,
245245

246246
key_storage: ChanSigner,
247247

@@ -286,7 +286,7 @@ impl<ChanSigner: ChannelKeys + Writeable> OnchainTxHandler<ChanSigner> {
286286
self.prev_local_commitment.write(writer)?;
287287
self.prev_local_htlc_sigs.write(writer)?;
288288

289-
self.local_csv.write(writer)?;
289+
self.on_local_tx_csv.write(writer)?;
290290

291291
self.key_storage.write(writer)?;
292292

@@ -334,7 +334,7 @@ impl<ChanSigner: ChannelKeys + Readable> ReadableArgs<Arc<Logger>> for OnchainTx
334334
let prev_local_commitment = Readable::read(reader)?;
335335
let prev_local_htlc_sigs = Readable::read(reader)?;
336336

337-
let local_csv = Readable::read(reader)?;
337+
let on_local_tx_csv = Readable::read(reader)?;
338338

339339
let key_storage = Readable::read(reader)?;
340340

@@ -387,7 +387,7 @@ impl<ChanSigner: ChannelKeys + Readable> ReadableArgs<Arc<Logger>> for OnchainTx
387387
local_htlc_sigs,
388388
prev_local_commitment,
389389
prev_local_htlc_sigs,
390-
local_csv,
390+
on_local_tx_csv,
391391
key_storage,
392392
claimable_outpoints,
393393
pending_claim_requests,
@@ -399,7 +399,7 @@ impl<ChanSigner: ChannelKeys + Readable> ReadableArgs<Arc<Logger>> for OnchainTx
399399
}
400400

401401
impl<ChanSigner: ChannelKeys> OnchainTxHandler<ChanSigner> {
402-
pub(super) fn new(destination_script: Script, keys: ChanSigner, local_csv: u16, logger: Arc<Logger>) -> Self {
402+
pub(super) fn new(destination_script: Script, keys: ChanSigner, on_local_tx_csv: u16, logger: Arc<Logger>) -> Self {
403403

404404
let key_storage = keys;
405405

@@ -409,7 +409,7 @@ impl<ChanSigner: ChannelKeys> OnchainTxHandler<ChanSigner> {
409409
local_htlc_sigs: None,
410410
prev_local_commitment: None,
411411
prev_local_htlc_sigs: None,
412-
local_csv,
412+
on_local_tx_csv,
413413
key_storage,
414414
pending_claim_requests: HashMap::new(),
415415
claimable_outpoints: HashMap::new(),
@@ -865,7 +865,7 @@ impl<ChanSigner: ChannelKeys> OnchainTxHandler<ChanSigner> {
865865

866866
fn sign_latest_local_htlcs(&mut self) {
867867
if let Some(ref local_commitment) = self.local_commitment {
868-
if let Ok(sigs) = self.key_storage.sign_local_commitment_htlc_transactions(local_commitment, self.local_csv, &self.secp_ctx) {
868+
if let Ok(sigs) = self.key_storage.sign_local_commitment_htlc_transactions(local_commitment, self.on_local_tx_csv, &self.secp_ctx) {
869869
self.local_htlc_sigs = Some(Vec::new());
870870
let ret = self.local_htlc_sigs.as_mut().unwrap();
871871
for (htlc_idx, (local_sig, &(ref htlc, _))) in sigs.iter().zip(local_commitment.per_htlc.iter()).enumerate() {
@@ -881,7 +881,7 @@ impl<ChanSigner: ChannelKeys> OnchainTxHandler<ChanSigner> {
881881
}
882882
fn sign_prev_local_htlcs(&mut self) {
883883
if let Some(ref local_commitment) = self.prev_local_commitment {
884-
if let Ok(sigs) = self.key_storage.sign_local_commitment_htlc_transactions(local_commitment, self.local_csv, &self.secp_ctx) {
884+
if let Ok(sigs) = self.key_storage.sign_local_commitment_htlc_transactions(local_commitment, self.on_local_tx_csv, &self.secp_ctx) {
885885
self.prev_local_htlc_sigs = Some(Vec::new());
886886
let ret = self.prev_local_htlc_sigs.as_mut().unwrap();
887887
for (htlc_idx, (local_sig, &(ref htlc, _))) in sigs.iter().zip(local_commitment.per_htlc.iter()).enumerate() {
@@ -933,7 +933,7 @@ impl<ChanSigner: ChannelKeys> OnchainTxHandler<ChanSigner> {
933933
if let &Some(ref htlc_sigs) = &self.local_htlc_sigs {
934934
let &(ref htlc_idx, ref htlc_sig) = htlc_sigs[outp.vout as usize].as_ref().unwrap();
935935
htlc_tx = Some(self.local_commitment.as_ref().unwrap()
936-
.get_signed_htlc_tx(*htlc_idx, htlc_sig, preimage, self.local_csv));
936+
.get_signed_htlc_tx(*htlc_idx, htlc_sig, preimage, self.on_local_tx_csv));
937937
}
938938
}
939939
}
@@ -944,7 +944,7 @@ impl<ChanSigner: ChannelKeys> OnchainTxHandler<ChanSigner> {
944944
if let &Some(ref htlc_sigs) = &self.prev_local_htlc_sigs {
945945
let &(ref htlc_idx, ref htlc_sig) = htlc_sigs[outp.vout as usize].as_ref().unwrap();
946946
htlc_tx = Some(self.prev_local_commitment.as_ref().unwrap()
947-
.get_signed_htlc_tx(*htlc_idx, htlc_sig, preimage, self.local_csv));
947+
.get_signed_htlc_tx(*htlc_idx, htlc_sig, preimage, self.on_local_tx_csv));
948948
}
949949
}
950950
}

0 commit comments

Comments
 (0)