Skip to content

Commit 08892b5

Browse files
committed
Make channel_parameters explicit to build_counterparty_commitment_tx
It's best to let the caller decide what the appropriate `ChannelTransactionParameters` are as it has the most context.
1 parent 1d8b3db commit 08892b5

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed

lightning/src/chain/channelmonitor.rs

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4187,8 +4187,14 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
41874187
to_countersignatory_value,
41884188
)| {
41894189
let nondust_htlcs = vec![];
4190+
// Since we're expected to only reach here during the initial persistence of a
4191+
// monitor (i.e., via [`Persist::persist_new_channel`]), we expect to only have
4192+
// one `FundingScope` present.
4193+
debug_assert!(self.pending_funding.is_empty());
4194+
let channel_parameters = &self.funding.channel_parameters;
41904195

41914196
let commitment_tx = self.build_counterparty_commitment_tx(
4197+
channel_parameters,
41924198
INITIAL_COMMITMENT_NUMBER,
41934199
&their_per_commitment_point,
41944200
to_broadcaster_value,
@@ -4206,11 +4212,12 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
42064212

42074213
#[rustfmt::skip]
42084214
fn build_counterparty_commitment_tx(
4209-
&self, commitment_number: u64, their_per_commitment_point: &PublicKey,
4210-
to_broadcaster_value: u64, to_countersignatory_value: u64, feerate_per_kw: u32,
4215+
&self, channel_parameters: &ChannelTransactionParameters, commitment_number: u64,
4216+
their_per_commitment_point: &PublicKey, to_broadcaster_value: u64,
4217+
to_countersignatory_value: u64, feerate_per_kw: u32,
42114218
nondust_htlcs: Vec<HTLCOutputInCommitment>
42124219
) -> CommitmentTransaction {
4213-
let channel_parameters = &self.funding.channel_parameters.as_counterparty_broadcastable();
4220+
let channel_parameters = &channel_parameters.as_counterparty_broadcastable();
42144221
CommitmentTransaction::new(commitment_number, their_per_commitment_point,
42154222
to_broadcaster_value, to_countersignatory_value, feerate_per_kw, nondust_htlcs, channel_parameters, &self.onchain_tx_handler.secp_ctx)
42164223
}
@@ -4232,9 +4239,20 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
42324239
htlc.transaction_output_index.map(|_| htlc).cloned()
42334240
}).collect::<Vec<_>>();
42344241

4235-
let commitment_tx = self.build_counterparty_commitment_tx(commitment_number,
4236-
&their_per_commitment_point, to_broadcaster_value,
4237-
to_countersignatory_value, feerate_per_kw, nondust_htlcs);
4242+
// This monitor update variant is only applicable while there's a single
4243+
// `FundingScope` active, otherwise we expect to see
4244+
// `LatestCounterpartyCommitment` instead.
4245+
debug_assert!(self.pending_funding.is_empty());
4246+
let channel_parameters = &self.funding.channel_parameters;
4247+
let commitment_tx = self.build_counterparty_commitment_tx(
4248+
channel_parameters,
4249+
commitment_number,
4250+
&their_per_commitment_point,
4251+
to_broadcaster_value,
4252+
to_countersignatory_value,
4253+
feerate_per_kw,
4254+
nondust_htlcs,
4255+
);
42384256

42394257
debug_assert_eq!(commitment_tx.trust().txid(), commitment_txid);
42404258

0 commit comments

Comments
 (0)