@@ -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,12 @@ 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. 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.
374374 ///
375375 /// 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 ) ;
381377}
382378
383379/// A cloneable signer.
@@ -583,39 +579,39 @@ impl InMemorySigner {
583579 }
584580
585581 /// Counterparty pubkeys.
586- /// Will panic if ready_channel wasn't called.
582+ /// Will panic if provide_channel_parameters wasn't called.
587583 pub fn counterparty_pubkeys ( & self ) -> & ChannelPublicKeys { & self . get_channel_parameters ( ) . counterparty_parameters . as_ref ( ) . unwrap ( ) . pubkeys }
588584
589585 /// The contest_delay value specified by our counterparty and applied on holder-broadcastable
590586 /// transactions, ie the amount of time that we have to wait to recover our funds if we
591587 /// broadcast a transaction.
592- /// Will panic if ready_channel wasn't called.
588+ /// Will panic if provide_channel_parameters wasn't called.
593589 pub fn counterparty_selected_contest_delay ( & self ) -> u16 { self . get_channel_parameters ( ) . counterparty_parameters . as_ref ( ) . unwrap ( ) . selected_contest_delay }
594590
595591 /// The contest_delay value specified by us and applied on transactions broadcastable
596592 /// by our counterparty, ie the amount of time that they have to wait to recover their funds
597593 /// if they broadcast a transaction.
598- /// Will panic if ready_channel wasn't called.
594+ /// Will panic if provide_channel_parameters wasn't called.
599595 pub fn holder_selected_contest_delay ( & self ) -> u16 { self . get_channel_parameters ( ) . holder_selected_contest_delay }
600596
601597 /// 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.
603599 pub fn is_outbound ( & self ) -> bool { self . get_channel_parameters ( ) . is_outbound_from_holder }
604600
605601 /// Funding outpoint
606- /// Will panic if ready_channel wasn't called.
602+ /// Will panic if provide_channel_parameters wasn't called.
607603 pub fn funding_outpoint ( & self ) -> & OutPoint { self . get_channel_parameters ( ) . funding_outpoint . as_ref ( ) . unwrap ( ) }
608604
609605 /// Obtain a ChannelTransactionParameters for this channel, to be used when verifying or
610606 /// building transactions.
611607 ///
612- /// Will panic if ready_channel wasn't called.
608+ /// Will panic if provide_channel_parameters wasn't called.
613609 pub fn get_channel_parameters ( & self ) -> & ChannelTransactionParameters {
614610 self . channel_parameters . as_ref ( ) . unwrap ( )
615611 }
616612
617613 /// Whether anchors should be used.
618- /// Will panic if ready_channel wasn't called.
614+ /// Will panic if provide_channel_parameters wasn't called.
619615 pub fn opt_anchors ( & self ) -> bool {
620616 self . get_channel_parameters ( ) . opt_anchors . is_some ( )
621617 }
@@ -819,8 +815,12 @@ impl BaseSign for InMemorySigner {
819815 Ok ( ( sign ( secp_ctx, & msghash, & self . node_secret ) , sign ( secp_ctx, & msghash, & self . funding_key ) ) )
820816 }
821817
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+ }
824824 assert ! ( channel_parameters. is_populated( ) , "Channel parameters must be fully populated" ) ;
825825 self . channel_parameters = Some ( channel_parameters. clone ( ) ) ;
826826 }
0 commit comments