@@ -7008,10 +7008,12 @@ where
70087008 .and_then(|funding_negotiation| funding_negotiation.as_funding())
70097009 .expect("Funding must exist for negotiated pending splice");
70107010 let transaction_number = self.holder_commitment_point.current_transaction_number();
7011- let commitment_point = self
7012- .holder_commitment_point
7013- .current_point()
7014- .expect("current should be set after receiving the initial commitment_signed");
7011+ let commitment_point = self.holder_commitment_point.current_point().ok_or_else(|| {
7012+ debug_assert!(false);
7013+ ChannelError::close(
7014+ "current_point should be set for channels initiating splicing".to_owned(),
7015+ )
7016+ })?;
70157017 let (holder_commitment_tx, _) = self.context.validate_commitment_signed(
70167018 pending_splice_funding,
70177019 transaction_number,
@@ -10602,7 +10604,7 @@ where
1060210604 if self.holder_commitment_point.current_point().is_none() {
1060310605 return Err(APIError::APIMisuseError {
1060410606 err: format!(
10605- "Channel {} cannot be spliced, commitment point needs to be advanced once ",
10607+ "Channel {} cannot be spliced until a payment is routed ",
1060610608 self.context.channel_id(),
1060710609 ),
1060810610 });
@@ -10710,7 +10712,7 @@ where
1071010712 // TODO(splicing): Add check that we are the quiescence acceptor
1071110713
1071210714 if self.holder_commitment_point.current_point().is_none() {
10713- return Err(ChannelError::Warn (format!(
10715+ return Err(ChannelError::WarnAndDisconnect (format!(
1071410716 "Channel {} commitment point needs to be advanced once before spliced",
1071510717 self.context.channel_id(),
1071610718 )));
@@ -13874,13 +13876,28 @@ where
1387413876 }
1387513877
1387613878 // If we're restoring this channel for the first time after an upgrade, then we require that the
13877- // signer be available so that we can immediately populate the current commitment point. Channel
13879+ // signer be available so that we can immediately populate the next commitment point. Channel
1387813880 // restoration will fail if this is not possible.
13879- let holder_commitment_point =
13881+ let holder_commitment_point = {
13882+ let current_point = holder_commitment_point_current_opt.or_else(|| {
13883+ if holder_commitment_next_transaction_number == INITIAL_COMMITMENT_NUMBER {
13884+ None
13885+ } else {
13886+ // If the current point is not available then splicing can't be initiated
13887+ // until the next point is advanced and becomes the current point.
13888+ holder_signer
13889+ .get_per_commitment_point(
13890+ holder_commitment_next_transaction_number + 1,
13891+ &secp_ctx,
13892+ )
13893+ .ok()
13894+ }
13895+ });
13896+
1388013897 match (holder_commitment_point_next_opt, holder_commitment_point_pending_next_opt) {
1388113898 (Some(next_point), pending_next_point) => HolderCommitmentPoint {
1388213899 next_transaction_number: holder_commitment_next_transaction_number,
13883- current_point: None ,
13900+ current_point,
1388413901 next_point,
1388513902 pending_next_point,
1388613903 },
@@ -13900,12 +13917,13 @@ where
1390013917 );
1390113918 HolderCommitmentPoint {
1390213919 next_transaction_number: holder_commitment_next_transaction_number,
13903- current_point: holder_commitment_point_current_opt ,
13920+ current_point,
1390413921 next_point,
1390513922 pending_next_point: Some(pending_next_point),
1390613923 }
1390713924 },
13908- };
13925+ }
13926+ };
1390913927
1391013928 Ok(FundedChannel {
1391113929 funding: FundingScope {
0 commit comments