@@ -161,7 +161,7 @@ pub enum SpendableOutputDescriptor {
161
161
///
162
162
/// To derive the revocation_pubkey provided here (which is used in the witness
163
163
/// 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
165
165
/// to chan_utils::derive_public_revocation_key.
166
166
///
167
167
/// The witness script which is hashed and included in the output script_pubkey may be
@@ -368,16 +368,18 @@ pub trait BaseSign {
368
368
-> Result < ( Signature , Signature ) , ( ) > ;
369
369
370
370
/// 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 usually
372
+ /// done immediately upon signer derivation, unless the channel has yet to be funded, in which
373
+ /// case it is done as soon as the funding outpoint is known. Since these are static channel
374
+ /// data, they MUST NOT be allowed to change to different values once set. If the channel
375
+ /// parameters are already known, any further calls should act as a no-op.
374
376
///
375
377
/// channel_parameters.is_populated() MUST be true.
376
378
///
377
379
/// We bind holder_selected_contest_delay late here for API convenience.
378
380
///
379
381
/// Will be called before any signatures are applied.
380
- fn ready_channel ( & mut self , channel_parameters : & ChannelTransactionParameters ) ;
382
+ fn provide_channel_parameters ( & mut self , channel_parameters : & ChannelTransactionParameters ) ;
381
383
}
382
384
383
385
/// A cloneable signer.
@@ -583,39 +585,39 @@ impl InMemorySigner {
583
585
}
584
586
585
587
/// Counterparty pubkeys.
586
- /// Will panic if ready_channel wasn't called.
588
+ /// Will panic if provide_channel_parameters wasn't called.
587
589
pub fn counterparty_pubkeys ( & self ) -> & ChannelPublicKeys { & self . get_channel_parameters ( ) . counterparty_parameters . as_ref ( ) . unwrap ( ) . pubkeys }
588
590
589
591
/// The contest_delay value specified by our counterparty and applied on holder-broadcastable
590
592
/// transactions, ie the amount of time that we have to wait to recover our funds if we
591
593
/// broadcast a transaction.
592
- /// Will panic if ready_channel wasn't called.
594
+ /// Will panic if provide_channel_parameters wasn't called.
593
595
pub fn counterparty_selected_contest_delay ( & self ) -> u16 { self . get_channel_parameters ( ) . counterparty_parameters . as_ref ( ) . unwrap ( ) . selected_contest_delay }
594
596
595
597
/// The contest_delay value specified by us and applied on transactions broadcastable
596
598
/// by our counterparty, ie the amount of time that they have to wait to recover their funds
597
599
/// if they broadcast a transaction.
598
- /// Will panic if ready_channel wasn't called.
600
+ /// Will panic if provide_channel_parameters wasn't called.
599
601
pub fn holder_selected_contest_delay ( & self ) -> u16 { self . get_channel_parameters ( ) . holder_selected_contest_delay }
600
602
601
603
/// Whether the holder is the initiator
602
- /// Will panic if ready_channel wasn't called.
604
+ /// Will panic if provide_channel_parameters wasn't called.
603
605
pub fn is_outbound ( & self ) -> bool { self . get_channel_parameters ( ) . is_outbound_from_holder }
604
606
605
607
/// Funding outpoint
606
- /// Will panic if ready_channel wasn't called.
608
+ /// Will panic if provide_channel_parameters wasn't called.
607
609
pub fn funding_outpoint ( & self ) -> & OutPoint { self . get_channel_parameters ( ) . funding_outpoint . as_ref ( ) . unwrap ( ) }
608
610
609
611
/// Obtain a ChannelTransactionParameters for this channel, to be used when verifying or
610
612
/// building transactions.
611
613
///
612
- /// Will panic if ready_channel wasn't called.
614
+ /// Will panic if provide_channel_parameters wasn't called.
613
615
pub fn get_channel_parameters ( & self ) -> & ChannelTransactionParameters {
614
616
self . channel_parameters . as_ref ( ) . unwrap ( )
615
617
}
616
618
617
619
/// Whether anchors should be used.
618
- /// Will panic if ready_channel wasn't called.
620
+ /// Will panic if provide_channel_parameters wasn't called.
619
621
pub fn opt_anchors ( & self ) -> bool {
620
622
self . get_channel_parameters ( ) . opt_anchors . is_some ( )
621
623
}
@@ -819,8 +821,10 @@ impl BaseSign for InMemorySigner {
819
821
Ok ( ( sign ( secp_ctx, & msghash, & self . node_secret ) , sign ( secp_ctx, & msghash, & self . funding_key ) ) )
820
822
}
821
823
822
- fn ready_channel ( & mut self , channel_parameters : & ChannelTransactionParameters ) {
823
- assert ! ( self . channel_parameters. is_none( ) , "Acceptance already noted" ) ;
824
+ fn provide_channel_parameters ( & mut self , channel_parameters : & ChannelTransactionParameters ) {
825
+ if self . channel_parameters . is_some ( ) {
826
+ return ;
827
+ }
824
828
assert ! ( channel_parameters. is_populated( ) , "Channel parameters must be fully populated" ) ;
825
829
self . channel_parameters = Some ( channel_parameters. clone ( ) ) ;
826
830
}
0 commit comments