@@ -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,12 @@ 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. Since these are
372
+ /// static channel data, they MUST NOT be allowed to change to different values once set, as LDK
373
+ /// may call this method more than once.
374
374
///
375
375
/// channel_parameters.is_populated() MUST be true.
376
- ///
377
- /// We bind holder_selected_contest_delay late here for API convenience.
378
- ///
379
- /// Will be called before any signatures are applied.
380
- fn ready_channel ( & mut self , channel_parameters : & ChannelTransactionParameters ) ;
376
+ fn provide_channel_parameters ( & mut self , channel_parameters : & ChannelTransactionParameters ) ;
381
377
}
382
378
383
379
/// A cloneable signer.
@@ -583,39 +579,39 @@ impl InMemorySigner {
583
579
}
584
580
585
581
/// Counterparty pubkeys.
586
- /// Will panic if ready_channel wasn't called.
582
+ /// Will panic if provide_channel_parameters wasn't called.
587
583
pub fn counterparty_pubkeys ( & self ) -> & ChannelPublicKeys { & self . get_channel_parameters ( ) . counterparty_parameters . as_ref ( ) . unwrap ( ) . pubkeys }
588
584
589
585
/// The contest_delay value specified by our counterparty and applied on holder-broadcastable
590
586
/// transactions, ie the amount of time that we have to wait to recover our funds if we
591
587
/// broadcast a transaction.
592
- /// Will panic if ready_channel wasn't called.
588
+ /// Will panic if provide_channel_parameters wasn't called.
593
589
pub fn counterparty_selected_contest_delay ( & self ) -> u16 { self . get_channel_parameters ( ) . counterparty_parameters . as_ref ( ) . unwrap ( ) . selected_contest_delay }
594
590
595
591
/// The contest_delay value specified by us and applied on transactions broadcastable
596
592
/// by our counterparty, ie the amount of time that they have to wait to recover their funds
597
593
/// if they broadcast a transaction.
598
- /// Will panic if ready_channel wasn't called.
594
+ /// Will panic if provide_channel_parameters wasn't called.
599
595
pub fn holder_selected_contest_delay ( & self ) -> u16 { self . get_channel_parameters ( ) . holder_selected_contest_delay }
600
596
601
597
/// Whether the holder is the initiator
602
- /// Will panic if ready_channel wasn't called.
598
+ /// Will panic if provide_channel_parameters wasn't called.
603
599
pub fn is_outbound ( & self ) -> bool { self . get_channel_parameters ( ) . is_outbound_from_holder }
604
600
605
601
/// Funding outpoint
606
- /// Will panic if ready_channel wasn't called.
602
+ /// Will panic if provide_channel_parameters wasn't called.
607
603
pub fn funding_outpoint ( & self ) -> & OutPoint { self . get_channel_parameters ( ) . funding_outpoint . as_ref ( ) . unwrap ( ) }
608
604
609
605
/// Obtain a ChannelTransactionParameters for this channel, to be used when verifying or
610
606
/// building transactions.
611
607
///
612
- /// Will panic if ready_channel wasn't called.
608
+ /// Will panic if provide_channel_parameters wasn't called.
613
609
pub fn get_channel_parameters ( & self ) -> & ChannelTransactionParameters {
614
610
self . channel_parameters . as_ref ( ) . unwrap ( )
615
611
}
616
612
617
613
/// Whether anchors should be used.
618
- /// Will panic if ready_channel wasn't called.
614
+ /// Will panic if provide_channel_parameters wasn't called.
619
615
pub fn opt_anchors ( & self ) -> bool {
620
616
self . get_channel_parameters ( ) . opt_anchors . is_some ( )
621
617
}
@@ -819,8 +815,12 @@ impl BaseSign for InMemorySigner {
819
815
Ok ( ( sign ( secp_ctx, & msghash, & self . node_secret ) , sign ( secp_ctx, & msghash, & self . funding_key ) ) )
820
816
}
821
817
822
- fn ready_channel ( & mut self , channel_parameters : & ChannelTransactionParameters ) {
823
- assert ! ( self . channel_parameters. is_none( ) , "Acceptance already noted" ) ;
818
+ fn provide_channel_parameters ( & mut self , channel_parameters : & ChannelTransactionParameters ) {
819
+ assert ! ( self . channel_parameters. is_none( ) || self . channel_parameters. as_ref( ) . unwrap( ) == channel_parameters) ;
820
+ if self . channel_parameters . is_some ( ) {
821
+ // The channel parameters were already set and they match, return early.
822
+ return ;
823
+ }
824
824
assert ! ( channel_parameters. is_populated( ) , "Channel parameters must be fully populated" ) ;
825
825
self . channel_parameters = Some ( channel_parameters. clone ( ) ) ;
826
826
}
0 commit comments