@@ -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.
@@ -580,39 +582,39 @@ impl InMemorySigner {
580
582
}
581
583
582
584
/// Counterparty pubkeys.
583
- /// Will panic if ready_channel wasn't called.
585
+ /// Will panic if provide_channel_parameters wasn't called.
584
586
pub fn counterparty_pubkeys ( & self ) -> & ChannelPublicKeys { & self . get_channel_parameters ( ) . counterparty_parameters . as_ref ( ) . unwrap ( ) . pubkeys }
585
587
586
588
/// The contest_delay value specified by our counterparty and applied on holder-broadcastable
587
589
/// transactions, ie the amount of time that we have to wait to recover our funds if we
588
590
/// broadcast a transaction.
589
- /// Will panic if ready_channel wasn't called.
591
+ /// Will panic if provide_channel_parameters wasn't called.
590
592
pub fn counterparty_selected_contest_delay ( & self ) -> u16 { self . get_channel_parameters ( ) . counterparty_parameters . as_ref ( ) . unwrap ( ) . selected_contest_delay }
591
593
592
594
/// The contest_delay value specified by us and applied on transactions broadcastable
593
595
/// by our counterparty, ie the amount of time that they have to wait to recover their funds
594
596
/// if they broadcast a transaction.
595
- /// Will panic if ready_channel wasn't called.
597
+ /// Will panic if provide_channel_parameters wasn't called.
596
598
pub fn holder_selected_contest_delay ( & self ) -> u16 { self . get_channel_parameters ( ) . holder_selected_contest_delay }
597
599
598
600
/// Whether the holder is the initiator
599
- /// Will panic if ready_channel wasn't called.
601
+ /// Will panic if provide_channel_parameters wasn't called.
600
602
pub fn is_outbound ( & self ) -> bool { self . get_channel_parameters ( ) . is_outbound_from_holder }
601
603
602
604
/// Funding outpoint
603
- /// Will panic if ready_channel wasn't called.
605
+ /// Will panic if provide_channel_parameters wasn't called.
604
606
pub fn funding_outpoint ( & self ) -> & OutPoint { self . get_channel_parameters ( ) . funding_outpoint . as_ref ( ) . unwrap ( ) }
605
607
606
608
/// Obtain a ChannelTransactionParameters for this channel, to be used when verifying or
607
609
/// building transactions.
608
610
///
609
- /// Will panic if ready_channel wasn't called.
611
+ /// Will panic if provide_channel_parameters wasn't called.
610
612
pub fn get_channel_parameters ( & self ) -> & ChannelTransactionParameters {
611
613
self . channel_parameters . as_ref ( ) . unwrap ( )
612
614
}
613
615
614
616
/// Whether anchors should be used.
615
- /// Will panic if ready_channel wasn't called.
617
+ /// Will panic if provide_channel_parameters wasn't called.
616
618
pub fn opt_anchors ( & self ) -> bool {
617
619
self . get_channel_parameters ( ) . opt_anchors . is_some ( )
618
620
}
@@ -816,8 +818,10 @@ impl BaseSign for InMemorySigner {
816
818
Ok ( ( sign ( secp_ctx, & msghash, & self . node_secret ) , sign ( secp_ctx, & msghash, & self . funding_key ) ) )
817
819
}
818
820
819
- fn ready_channel ( & mut self , channel_parameters : & ChannelTransactionParameters ) {
820
- assert ! ( self . channel_parameters. is_none( ) , "Acceptance already noted" ) ;
821
+ fn provide_channel_parameters ( & mut self , channel_parameters : & ChannelTransactionParameters ) {
822
+ if self . channel_parameters . is_some ( ) {
823
+ return ;
824
+ }
821
825
assert ! ( channel_parameters. is_populated( ) , "Channel parameters must be fully populated" ) ;
822
826
self . channel_parameters = Some ( channel_parameters. clone ( ) ) ;
823
827
}
0 commit comments