Skip to content

Commit d3ccc28

Browse files
author
Antoine Riard
committed
Cleanup locally-selected-delay
1 parent aa18e57 commit d3ccc28

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

lightning/src/chain/keysinterface.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -319,13 +319,13 @@ pub trait ChannelKeys : Send+Clone {
319319
/// protocol.
320320
fn sign_channel_announcement<T: secp256k1::Signing>(&self, msg: &UnsignedChannelAnnouncement, secp_ctx: &Secp256k1<T>) -> Result<Signature, ()>;
321321

322-
/// Set the counterparty channel basepoints and counterparty_selected/locally_selected_contest_delay.
322+
/// Set the counterparty channel basepoints and counterparty_selected/holder_selected_contest_delay.
323323
/// This is done immediately on incoming channels and as soon as the channel is accepted on outgoing channels.
324324
///
325-
/// We bind locally_selected_contest_delay late here for API convenience.
325+
/// We bind holder_selected_contest_delay late here for API convenience.
326326
///
327327
/// Will be called before any signatures are applied.
328-
fn on_accept(&mut self, channel_points: &ChannelPublicKeys, counterparty_selected_contest_delay: u16, locally_selected_contest_delay: u16);
328+
fn on_accept(&mut self, channel_points: &ChannelPublicKeys, counterparty_selected_contest_delay: u16, holder_selected_contest_delay: u16);
329329
}
330330

331331
/// A trait to describe an object which can get user secrets and key material.
@@ -356,15 +356,15 @@ pub trait KeysInterface: Send + Sync {
356356
struct AcceptedChannelData {
357357
/// Counterparty public keys and base points
358358
counterparty_channel_pubkeys: ChannelPublicKeys,
359-
/// The contest_delay value specified by our counterparty and applied on locally-broadcastable
359+
/// The contest_delay value specified by our counterparty and applied on holder-broadcastable
360360
/// transactions, ie the amount of time that we have to wait to recover our funds if we
361361
/// broadcast a transaction. You'll likely want to pass this to the
362362
/// ln::chan_utils::build*_transaction functions when signing holder's transactions.
363363
counterparty_selected_contest_delay: u16,
364364
/// The contest_delay value specified by us and applied on transactions broadcastable
365365
/// by our counterparty, ie the amount of time that they have to wait to recover their funds
366366
/// if they broadcast a transaction.
367-
locally_selected_contest_delay: u16,
367+
holder_selected_contest_delay: u16,
368368
}
369369

370370
#[derive(Clone)]
@@ -384,7 +384,7 @@ pub struct InMemoryChannelKeys {
384384
pub commitment_seed: [u8; 32],
385385
/// Holder public keys and basepoints
386386
pub(crate) holder_channel_pubkeys: ChannelPublicKeys,
387-
/// Counterparty public keys and counterparty/locally selected_contest_delay, populated on channel acceptance
387+
/// Counterparty public keys and counterparty/holder selected_contest_delay, populated on channel acceptance
388388
accepted_channel_data: Option<AcceptedChannelData>,
389389
/// The total value of this channel
390390
channel_value_satoshis: u64,
@@ -442,7 +442,7 @@ impl InMemoryChannelKeys {
442442
/// Will panic if on_accept wasn't called.
443443
pub fn counterparty_pubkeys(&self) -> &ChannelPublicKeys { &self.accepted_channel_data.as_ref().unwrap().counterparty_channel_pubkeys }
444444

445-
/// The contest_delay value specified by our counterparty and applied on locally-broadcastable
445+
/// The contest_delay value specified by our counterparty and applied on holder-broadcastable
446446
/// transactions, ie the amount of time that we have to wait to recover our funds if we
447447
/// broadcast a transaction. You'll likely want to pass this to the
448448
/// ln::chan_utils::build*_transaction functions when signing holder's transactions.
@@ -453,7 +453,7 @@ impl InMemoryChannelKeys {
453453
/// by our counterparty, ie the amount of time that they have to wait to recover their funds
454454
/// if they broadcast a transaction.
455455
/// Will panic if on_accept wasn't called.
456-
pub fn locally_selected_contest_delay(&self) -> u16 { self.accepted_channel_data.as_ref().unwrap().locally_selected_contest_delay }
456+
pub fn holder_selected_contest_delay(&self) -> u16 { self.accepted_channel_data.as_ref().unwrap().holder_selected_contest_delay }
457457
}
458458

459459
impl ChannelKeys for InMemoryChannelKeys {
@@ -485,7 +485,7 @@ impl ChannelKeys for InMemoryChannelKeys {
485485
let mut htlc_sigs = Vec::with_capacity(htlcs.len());
486486
for ref htlc in htlcs {
487487
if let Some(_) = htlc.transaction_output_index {
488-
let htlc_tx = chan_utils::build_htlc_transaction(&commitment_txid, feerate_per_kw, accepted_data.locally_selected_contest_delay, htlc, &keys.broadcaster_delayed_payment_key, &keys.revocation_key);
488+
let htlc_tx = chan_utils::build_htlc_transaction(&commitment_txid, feerate_per_kw, accepted_data.holder_selected_contest_delay, htlc, &keys.broadcaster_delayed_payment_key, &keys.revocation_key);
489489
let htlc_redeemscript = chan_utils::get_htlc_redeemscript(&htlc, &keys);
490490
let htlc_sighash = hash_to_message!(&bip143::SigHashCache::new(&htlc_tx).signature_hash(0, &htlc_redeemscript, htlc.amount_msat / 1000, SigHashType::All)[..]);
491491
let our_htlc_key = match chan_utils::derive_private_key(&secp_ctx, &keys.per_commitment_point, &self.htlc_base_key) {
@@ -546,7 +546,7 @@ impl ChannelKeys for InMemoryChannelKeys {
546546
Ok(counterparty_delayedpubkey) => counterparty_delayedpubkey,
547547
Err(_) => return Err(())
548548
};
549-
chan_utils::get_revokeable_redeemscript(&revocation_pubkey, self.locally_selected_contest_delay(), &counterparty_delayedpubkey)
549+
chan_utils::get_revokeable_redeemscript(&revocation_pubkey, self.holder_selected_contest_delay(), &counterparty_delayedpubkey)
550550
};
551551
let mut sighash_parts = bip143::SigHashCache::new(justice_tx);
552552
let sighash = hash_to_message!(&sighash_parts.signature_hash(input, &witness_script, amount, SigHashType::All)[..]);
@@ -588,18 +588,18 @@ impl ChannelKeys for InMemoryChannelKeys {
588588
Ok(secp_ctx.sign(&msghash, &self.funding_key))
589589
}
590590

591-
fn on_accept(&mut self, channel_pubkeys: &ChannelPublicKeys, counterparty_selected_contest_delay: u16, locally_selected_contest_delay: u16) {
591+
fn on_accept(&mut self, channel_pubkeys: &ChannelPublicKeys, counterparty_selected_contest_delay: u16, holder_selected_contest_delay: u16) {
592592
assert!(self.accepted_channel_data.is_none(), "Already accepted");
593593
self.accepted_channel_data = Some(AcceptedChannelData {
594594
counterparty_channel_pubkeys: channel_pubkeys.clone(),
595595
counterparty_selected_contest_delay,
596-
locally_selected_contest_delay,
596+
holder_selected_contest_delay,
597597
});
598598
}
599599
}
600600

601601
impl_writeable!(AcceptedChannelData, 0,
602-
{ counterparty_channel_pubkeys, counterparty_selected_contest_delay, locally_selected_contest_delay });
602+
{ counterparty_channel_pubkeys, counterparty_selected_contest_delay, holder_selected_contest_delay });
603603

604604
impl Writeable for InMemoryChannelKeys {
605605
fn write<W: Writer>(&self, writer: &mut W) -> Result<(), Error> {

lightning/src/util/enforcing_trait_impls.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@ impl ChannelKeys for EnforcingChannelKeys {
132132
self.inner.sign_channel_announcement(msg, secp_ctx)
133133
}
134134

135-
fn on_accept(&mut self, channel_pubkeys: &ChannelPublicKeys, remote_locally_selected_delay: u16, locally_selected_delay: u16) {
136-
self.inner.on_accept(channel_pubkeys, remote_locally_selected_delay, locally_selected_delay)
135+
fn on_accept(&mut self, channel_pubkeys: &ChannelPublicKeys, counterparty_selected_delay: u16, holder_selected_delay: u16) {
136+
self.inner.on_accept(channel_pubkeys, counterparty_selected_delay, holder_selected_delay)
137137
}
138138
}
139139

0 commit comments

Comments
 (0)