Skip to content

Commit c8af714

Browse files
committed
Check correct commitment number/point in initial commitment_signed
When splicing a channel, the initial commitment_signed received should use the same commitment number and point previously received prior to splicing the channel. Account for this by checking the commitment_signed against that one instead, which is now stored separately in FundedChannel.
1 parent a7ba4dd commit c8af714

File tree

1 file changed

+24
-7
lines changed

1 file changed

+24
-7
lines changed

lightning/src/ln/channel.rs

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4195,17 +4195,17 @@ where
41954195

41964196
#[rustfmt::skip]
41974197
fn validate_commitment_signed<L: Deref>(
4198-
&self, funding: &FundingScope, holder_commitment_point: &HolderCommitmentPoint,
4198+
&self, funding: &FundingScope, transaction_number: u64, commitment_point: PublicKey,
41994199
msg: &msgs::CommitmentSigned, logger: &L,
42004200
) -> Result<(HolderCommitmentTransaction, Vec<(HTLCOutputInCommitment, Option<&HTLCSource>)>), ChannelError>
42014201
where
42024202
L::Target: Logger,
42034203
{
42044204
let funding_script = funding.get_funding_redeemscript();
42054205

4206-
let commitment_data = self.build_commitment_transaction(funding,
4207-
holder_commitment_point.next_transaction_number(), &holder_commitment_point.next_point(),
4208-
true, false, logger);
4206+
let commitment_data = self.build_commitment_transaction(
4207+
funding, transaction_number, &commitment_point, true, false, logger,
4208+
);
42094209
let commitment_txid = {
42104210
let trusted_tx = commitment_data.tx.trust();
42114211
let bitcoin_tx = trusted_tx.built_transaction();
@@ -7003,9 +7003,15 @@ where
70037003
})
70047004
.and_then(|funding_negotiation| funding_negotiation.as_funding())
70057005
.expect("Funding must exist for negotiated pending splice");
7006+
let transaction_number = self.holder_commitment_point.current_transaction_number();
7007+
let commitment_point = self
7008+
.holder_commitment_point
7009+
.current_point()
7010+
.expect("current should be set after receiving the initial commitment_signed");
70067011
let (holder_commitment_tx, _) = self.context.validate_commitment_signed(
70077012
pending_splice_funding,
7008-
&self.holder_commitment_point,
7013+
transaction_number,
7014+
commitment_point,
70097015
msg,
70107016
logger,
70117017
)?;
@@ -7089,9 +7095,17 @@ where
70897095
));
70907096
}
70917097

7098+
let transaction_number = self.holder_commitment_point.next_transaction_number();
7099+
let commitment_point = self.holder_commitment_point.next_point();
70927100
let update = self
70937101
.context
7094-
.validate_commitment_signed(&self.funding, &self.holder_commitment_point, msg, logger)
7102+
.validate_commitment_signed(
7103+
&self.funding,
7104+
transaction_number,
7105+
commitment_point,
7106+
msg,
7107+
logger,
7108+
)
70957109
.map(|(commitment_tx, htlcs_included)| {
70967110
let (nondust_htlc_sources, dust_htlcs) =
70977111
Self::get_commitment_htlc_data(&htlcs_included);
@@ -7153,9 +7167,12 @@ where
71537167
funding_txid
71547168
))
71557169
})?;
7170+
let transaction_number = self.holder_commitment_point.next_transaction_number();
7171+
let commitment_point = self.holder_commitment_point.next_point();
71567172
let (commitment_tx, htlcs_included) = self.context.validate_commitment_signed(
71577173
funding,
7158-
&self.holder_commitment_point,
7174+
transaction_number,
7175+
commitment_point,
71597176
msg,
71607177
logger,
71617178
)?;

0 commit comments

Comments
 (0)