Skip to content

Commit 9ee6c17

Browse files
committed
Rename KeysInterface ready_channel to provide_channel_parameters
Now that ready_channel is also called on startup upon deserializing channels, we opt to rename it to a more indicative name.
1 parent ef53b60 commit 9ee6c17

File tree

3 files changed

+19
-18
lines changed

3 files changed

+19
-18
lines changed

lightning/src/chain/keysinterface.rs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ pub enum SpendableOutputDescriptor {
161161
///
162162
/// To derive the revocation_pubkey provided here (which is used in the witness
163163
/// script generation), you must pass the counterparty revocation_basepoint (which appears in the
164-
/// call to Sign::ready_channel) and the provided per_commitment point
164+
/// call to Sign::provide_channel_parameters) and the provided per_commitment point
165165
/// to chan_utils::derive_public_revocation_key.
166166
///
167167
/// The witness script which is hashed and included in the output script_pubkey may be
@@ -368,16 +368,17 @@ pub trait BaseSign {
368368
-> Result<(Signature, Signature), ()>;
369369

370370
/// Set the counterparty static channel data, including basepoints,
371-
/// counterparty_selected/holder_selected_contest_delay and funding outpoint.
372-
/// This is done as soon as the funding outpoint is known. Since these are static channel data,
373-
/// they MUST NOT be allowed to change to different values once set.
371+
/// counterparty_selected/holder_selected_contest_delay and funding outpoint. This is only
372+
/// called once either immediately upon signer derivation, or if the channel has yet to be
373+
/// funded, as soon as the funding outpoint is known. Since these are static channel data, they
374+
/// MUST NOT be allowed to change to different values once set.
374375
///
375376
/// channel_parameters.is_populated() MUST be true.
376377
///
377378
/// We bind holder_selected_contest_delay late here for API convenience.
378379
///
379380
/// Will be called before any signatures are applied.
380-
fn ready_channel(&mut self, channel_parameters: &ChannelTransactionParameters);
381+
fn provide_channel_parameters(&mut self, channel_parameters: &ChannelTransactionParameters);
381382
}
382383

383384
/// A cloneable signer.
@@ -583,39 +584,39 @@ impl InMemorySigner {
583584
}
584585

585586
/// Counterparty pubkeys.
586-
/// Will panic if ready_channel wasn't called.
587+
/// Will panic if provide_channel_parameters wasn't called.
587588
pub fn counterparty_pubkeys(&self) -> &ChannelPublicKeys { &self.get_channel_parameters().counterparty_parameters.as_ref().unwrap().pubkeys }
588589

589590
/// The contest_delay value specified by our counterparty and applied on holder-broadcastable
590591
/// transactions, ie the amount of time that we have to wait to recover our funds if we
591592
/// broadcast a transaction.
592-
/// Will panic if ready_channel wasn't called.
593+
/// Will panic if provide_channel_parameters wasn't called.
593594
pub fn counterparty_selected_contest_delay(&self) -> u16 { self.get_channel_parameters().counterparty_parameters.as_ref().unwrap().selected_contest_delay }
594595

595596
/// The contest_delay value specified by us and applied on transactions broadcastable
596597
/// by our counterparty, ie the amount of time that they have to wait to recover their funds
597598
/// if they broadcast a transaction.
598-
/// Will panic if ready_channel wasn't called.
599+
/// Will panic if provide_channel_parameters wasn't called.
599600
pub fn holder_selected_contest_delay(&self) -> u16 { self.get_channel_parameters().holder_selected_contest_delay }
600601

601602
/// Whether the holder is the initiator
602-
/// Will panic if ready_channel wasn't called.
603+
/// Will panic if provide_channel_parameters wasn't called.
603604
pub fn is_outbound(&self) -> bool { self.get_channel_parameters().is_outbound_from_holder }
604605

605606
/// Funding outpoint
606-
/// Will panic if ready_channel wasn't called.
607+
/// Will panic if provide_channel_parameters wasn't called.
607608
pub fn funding_outpoint(&self) -> &OutPoint { self.get_channel_parameters().funding_outpoint.as_ref().unwrap() }
608609

609610
/// Obtain a ChannelTransactionParameters for this channel, to be used when verifying or
610611
/// building transactions.
611612
///
612-
/// Will panic if ready_channel wasn't called.
613+
/// Will panic if provide_channel_parameters wasn't called.
613614
pub fn get_channel_parameters(&self) -> &ChannelTransactionParameters {
614615
self.channel_parameters.as_ref().unwrap()
615616
}
616617

617618
/// Whether anchors should be used.
618-
/// Will panic if ready_channel wasn't called.
619+
/// Will panic if provide_channel_parameters wasn't called.
619620
pub fn opt_anchors(&self) -> bool {
620621
self.get_channel_parameters().opt_anchors.is_some()
621622
}
@@ -819,7 +820,7 @@ impl BaseSign for InMemorySigner {
819820
Ok((sign(secp_ctx, &msghash, &self.node_secret), sign(secp_ctx, &msghash, &self.funding_key)))
820821
}
821822

822-
fn ready_channel(&mut self, channel_parameters: &ChannelTransactionParameters) {
823+
fn provide_channel_parameters(&mut self, channel_parameters: &ChannelTransactionParameters) {
823824
assert!(self.channel_parameters.is_none(), "Acceptance already noted");
824825
assert!(channel_parameters.is_populated(), "Channel parameters must be fully populated");
825826
self.channel_parameters = Some(channel_parameters.clone());

lightning/src/ln/channel.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2215,7 +2215,7 @@ impl<Signer: Sign> Channel<Signer> {
22152215
self.channel_transaction_parameters.funding_outpoint = Some(funding_txo);
22162216
// This is an externally observable change before we finish all our checks. In particular
22172217
// funding_created_signature may fail.
2218-
self.holder_signer.ready_channel(&self.channel_transaction_parameters);
2218+
self.holder_signer.provide_channel_parameters(&self.channel_transaction_parameters);
22192219

22202220
let (counterparty_initial_commitment_txid, initial_commitment_tx, signature) = match self.funding_created_signature(&msg.signature, logger) {
22212221
Ok(res) => res,
@@ -5250,7 +5250,7 @@ impl<Signer: Sign> Channel<Signer> {
52505250
}
52515251

52525252
self.channel_transaction_parameters.funding_outpoint = Some(funding_txo);
5253-
self.holder_signer.ready_channel(&self.channel_transaction_parameters);
5253+
self.holder_signer.provide_channel_parameters(&self.channel_transaction_parameters);
52545254

52555255
let signature = match self.get_outbound_funding_created_signature(logger) {
52565256
Ok(res) => res,
@@ -7296,7 +7296,7 @@ mod tests {
72967296
selected_contest_delay: 144
72977297
});
72987298
chan.channel_transaction_parameters.funding_outpoint = Some(funding_info);
7299-
signer.ready_channel(&chan.channel_transaction_parameters);
7299+
signer.provide_channel_parameters(&chan.channel_transaction_parameters);
73007300

73017301
assert_eq!(counterparty_pubkeys.payment_point.serialize()[..],
73027302
hex::decode("032c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991").unwrap()[..]);

lightning/src/util/enforcing_trait_impls.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,8 @@ impl BaseSign for EnforcingSigner {
215215
self.inner.sign_channel_announcement(msg, secp_ctx)
216216
}
217217

218-
fn ready_channel(&mut self, channel_parameters: &ChannelTransactionParameters) {
219-
self.inner.ready_channel(channel_parameters)
218+
fn provide_channel_parameters(&mut self, channel_parameters: &ChannelTransactionParameters) {
219+
self.inner.provide_channel_parameters(channel_parameters)
220220
}
221221
}
222222

0 commit comments

Comments
 (0)