@@ -4195,8 +4195,14 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
41954195 to_countersignatory_value,
41964196 ) | {
41974197 let nondust_htlcs = vec ! [ ] ;
4198+ // Since we're expected to only reach here during the initial persistence of a
4199+ // monitor (i.e., via [`Persist::persist_new_channel`]), we expect to only have
4200+ // one `FundingScope` present.
4201+ debug_assert ! ( self . pending_funding. is_empty( ) ) ;
4202+ let channel_parameters = & self . funding . channel_parameters ;
41984203
41994204 let commitment_tx = self . build_counterparty_commitment_tx (
4205+ channel_parameters,
42004206 INITIAL_COMMITMENT_NUMBER ,
42014207 & their_per_commitment_point,
42024208 to_broadcaster_value,
@@ -4214,11 +4220,12 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
42144220
42154221 #[ rustfmt:: skip]
42164222 fn build_counterparty_commitment_tx (
4217- & self , commitment_number : u64 , their_per_commitment_point : & PublicKey ,
4218- to_broadcaster_value : u64 , to_countersignatory_value : u64 , feerate_per_kw : u32 ,
4223+ & self , channel_parameters : & ChannelTransactionParameters , commitment_number : u64 ,
4224+ their_per_commitment_point : & PublicKey , to_broadcaster_value : u64 ,
4225+ to_countersignatory_value : u64 , feerate_per_kw : u32 ,
42194226 nondust_htlcs : Vec < HTLCOutputInCommitment >
42204227 ) -> CommitmentTransaction {
4221- let channel_parameters = & self . funding . channel_parameters . as_counterparty_broadcastable ( ) ;
4228+ let channel_parameters = & channel_parameters. as_counterparty_broadcastable ( ) ;
42224229 CommitmentTransaction :: new ( commitment_number, their_per_commitment_point,
42234230 to_broadcaster_value, to_countersignatory_value, feerate_per_kw, nondust_htlcs, channel_parameters, & self . onchain_tx_handler . secp_ctx )
42244231 }
@@ -4240,9 +4247,20 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
42404247 htlc. transaction_output_index . map ( |_| htlc) . cloned ( )
42414248 } ) . collect :: < Vec < _ > > ( ) ;
42424249
4243- let commitment_tx = self . build_counterparty_commitment_tx ( commitment_number,
4244- & their_per_commitment_point, to_broadcaster_value,
4245- to_countersignatory_value, feerate_per_kw, nondust_htlcs) ;
4250+ // This monitor update variant is only applicable while there's a single
4251+ // `FundingScope` active, otherwise we expect to see
4252+ // `LatestCounterpartyCommitment` instead.
4253+ debug_assert ! ( self . pending_funding. is_empty( ) ) ;
4254+ let channel_parameters = & self . funding . channel_parameters ;
4255+ let commitment_tx = self . build_counterparty_commitment_tx (
4256+ channel_parameters,
4257+ commitment_number,
4258+ & their_per_commitment_point,
4259+ to_broadcaster_value,
4260+ to_countersignatory_value,
4261+ feerate_per_kw,
4262+ nondust_htlcs,
4263+ ) ;
42464264
42474265 debug_assert_eq ! ( commitment_tx. trust( ) . txid( ) , commitment_txid) ;
42484266
0 commit comments