@@ -4202,8 +4202,14 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
4202
4202
to_countersignatory_value,
4203
4203
) | {
4204
4204
let nondust_htlcs = vec ! [ ] ;
4205
+ // Since we're expected to only reach here during the initial persistence of a
4206
+ // monitor (i.e., via [`Persist::persist_new_channel`]), we expect to only have
4207
+ // one `FundingScope` present.
4208
+ debug_assert ! ( self . pending_funding. is_empty( ) ) ;
4209
+ let channel_parameters = & self . funding . channel_parameters ;
4205
4210
4206
4211
let commitment_tx = self . build_counterparty_commitment_tx (
4212
+ channel_parameters,
4207
4213
INITIAL_COMMITMENT_NUMBER ,
4208
4214
& their_per_commitment_point,
4209
4215
to_broadcaster_value,
@@ -4221,11 +4227,12 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
4221
4227
4222
4228
#[ rustfmt:: skip]
4223
4229
fn build_counterparty_commitment_tx (
4224
- & self , commitment_number : u64 , their_per_commitment_point : & PublicKey ,
4225
- to_broadcaster_value : u64 , to_countersignatory_value : u64 , feerate_per_kw : u32 ,
4230
+ & self , channel_parameters : & ChannelTransactionParameters , commitment_number : u64 ,
4231
+ their_per_commitment_point : & PublicKey , to_broadcaster_value : u64 ,
4232
+ to_countersignatory_value : u64 , feerate_per_kw : u32 ,
4226
4233
nondust_htlcs : Vec < HTLCOutputInCommitment >
4227
4234
) -> CommitmentTransaction {
4228
- let channel_parameters = & self . funding . channel_parameters . as_counterparty_broadcastable ( ) ;
4235
+ let channel_parameters = & channel_parameters. as_counterparty_broadcastable ( ) ;
4229
4236
CommitmentTransaction :: new ( commitment_number, their_per_commitment_point,
4230
4237
to_broadcaster_value, to_countersignatory_value, feerate_per_kw, nondust_htlcs, channel_parameters, & self . onchain_tx_handler . secp_ctx )
4231
4238
}
@@ -4247,9 +4254,20 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
4247
4254
htlc. transaction_output_index . map ( |_| htlc) . cloned ( )
4248
4255
} ) . collect :: < Vec < _ > > ( ) ;
4249
4256
4250
- let commitment_tx = self . build_counterparty_commitment_tx ( commitment_number,
4251
- & their_per_commitment_point, to_broadcaster_value,
4252
- to_countersignatory_value, feerate_per_kw, nondust_htlcs) ;
4257
+ // This monitor update variant is only applicable while there's a single
4258
+ // `FundingScope` active, otherwise we expect to see
4259
+ // `LatestCounterpartyCommitment` instead.
4260
+ debug_assert ! ( self . pending_funding. is_empty( ) ) ;
4261
+ let channel_parameters = & self . funding . channel_parameters ;
4262
+ let commitment_tx = self . build_counterparty_commitment_tx (
4263
+ channel_parameters,
4264
+ commitment_number,
4265
+ & their_per_commitment_point,
4266
+ to_broadcaster_value,
4267
+ to_countersignatory_value,
4268
+ feerate_per_kw,
4269
+ nondust_htlcs,
4270
+ ) ;
4253
4271
4254
4272
debug_assert_eq ! ( commitment_tx. trust( ) . txid( ) , commitment_txid) ;
4255
4273
0 commit comments