@@ -7008,10 +7008,12 @@ where
7008
7008
.and_then(|funding_negotiation| funding_negotiation.as_funding())
7009
7009
.expect("Funding must exist for negotiated pending splice");
7010
7010
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
+ })?;
7015
7017
let (holder_commitment_tx, _) = self.context.validate_commitment_signed(
7016
7018
pending_splice_funding,
7017
7019
transaction_number,
@@ -10602,7 +10604,7 @@ where
10602
10604
if self.holder_commitment_point.current_point().is_none() {
10603
10605
return Err(APIError::APIMisuseError {
10604
10606
err: format!(
10605
- "Channel {} cannot be spliced, commitment point needs to be advanced once ",
10607
+ "Channel {} cannot be spliced until a payment is routed ",
10606
10608
self.context.channel_id(),
10607
10609
),
10608
10610
});
@@ -10710,7 +10712,7 @@ where
10710
10712
// TODO(splicing): Add check that we are the quiescence acceptor
10711
10713
10712
10714
if self.holder_commitment_point.current_point().is_none() {
10713
- return Err(ChannelError::Warn (format!(
10715
+ return Err(ChannelError::WarnAndDisconnect (format!(
10714
10716
"Channel {} commitment point needs to be advanced once before spliced",
10715
10717
self.context.channel_id(),
10716
10718
)));
@@ -13874,13 +13876,28 @@ where
13874
13876
}
13875
13877
13876
13878
// 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
13878
13880
// 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
+
13880
13897
match (holder_commitment_point_next_opt, holder_commitment_point_pending_next_opt) {
13881
13898
(Some(next_point), pending_next_point) => HolderCommitmentPoint {
13882
13899
next_transaction_number: holder_commitment_next_transaction_number,
13883
- current_point: None ,
13900
+ current_point,
13884
13901
next_point,
13885
13902
pending_next_point,
13886
13903
},
@@ -13900,12 +13917,13 @@ where
13900
13917
);
13901
13918
HolderCommitmentPoint {
13902
13919
next_transaction_number: holder_commitment_next_transaction_number,
13903
- current_point: holder_commitment_point_current_opt ,
13920
+ current_point,
13904
13921
next_point,
13905
13922
pending_next_point: Some(pending_next_point),
13906
13923
}
13907
13924
},
13908
- };
13925
+ }
13926
+ };
13909
13927
13910
13928
Ok(FundedChannel {
13911
13929
funding: FundingScope {
0 commit comments