@@ -10595,6 +10595,15 @@ where
10595
10595
our_funding_inputs: Vec<(TxIn, Transaction, Weight)>, change_script: Option<ScriptBuf>,
10596
10596
funding_feerate_per_kw: u32, locktime: u32,
10597
10597
) -> Result<msgs::SpliceInit, APIError> {
10598
+ if self.current_holder_commitment_point.is_none() {
10599
+ return Err(APIError::APIMisuseError {
10600
+ err: format!(
10601
+ "Channel {} cannot be spliced, commitment point needs to be advanced once",
10602
+ self.context.channel_id(),
10603
+ ),
10604
+ });
10605
+ }
10606
+
10598
10607
// Check if a splice has been initiated already.
10599
10608
// Note: only a single outstanding splice is supported (per spec)
10600
10609
if self.pending_splice.is_some() {
@@ -10696,6 +10705,13 @@ where
10696
10705
10697
10706
// TODO(splicing): Add check that we are the quiescence acceptor
10698
10707
10708
+ if self.current_holder_commitment_point.is_none() {
10709
+ return Err(ChannelError::Warn(format!(
10710
+ "Channel {} commitment point needs to be advanced once before spliced",
10711
+ self.context.channel_id(),
10712
+ )));
10713
+ }
10714
+
10699
10715
// Check if a splice has been initiated already.
10700
10716
if self.pending_splice.is_some() {
10701
10717
return Err(ChannelError::WarnAndDisconnect(format!(
@@ -13214,6 +13230,8 @@ where
13214
13230
let is_manual_broadcast = Some(self.context.is_manual_broadcast);
13215
13231
13216
13232
// `HolderCommitmentPoint::point` will become optional when async signing is implemented.
13233
+ let current_holder_commitment_point =
13234
+ self.current_holder_commitment_point.map(|p| p.point());
13217
13235
let next_holder_commitment_point = Some(self.next_holder_commitment_point.point());
13218
13236
let next_holder_commitment_point_next_advance =
13219
13237
self.next_holder_commitment_point.next_point();
@@ -13266,6 +13284,7 @@ where
13266
13284
(59, self.funding.minimum_depth_override, option), // Added in 0.2
13267
13285
(60, self.context.historical_scids, optional_vec), // Added in 0.2
13268
13286
(61, fulfill_attribution_data, optional_vec), // Added in 0.2
13287
+ (63, current_holder_commitment_point, option), // Added in 0.2
13269
13288
});
13270
13289
13271
13290
Ok(())
@@ -13615,6 +13634,7 @@ where
13615
13634
let mut malformed_htlcs: Option<Vec<(u64, u16, [u8; 32])>> = None;
13616
13635
let mut monitor_pending_update_adds: Option<Vec<msgs::UpdateAddHTLC>> = None;
13617
13636
13637
+ let mut current_holder_commitment_point_opt: Option<PublicKey> = None;
13618
13638
let mut next_holder_commitment_point_opt: Option<PublicKey> = None;
13619
13639
let mut next_holder_commitment_point_next_advance_opt: Option<PublicKey> = None;
13620
13640
let mut is_manual_broadcast = None;
@@ -13668,6 +13688,7 @@ where
13668
13688
(59, minimum_depth_override, option), // Added in 0.2
13669
13689
(60, historical_scids, optional_vec), // Added in 0.2
13670
13690
(61, fulfill_attribution_data, optional_vec), // Added in 0.2
13691
+ (63, current_holder_commitment_point_opt, option), // Added in 0.2
13671
13692
});
13672
13693
13673
13694
let holder_signer = signer_provider.derive_channel_signer(channel_keys_id);
@@ -13873,20 +13894,13 @@ where
13873
13894
},
13874
13895
};
13875
13896
13876
- let current_holder_commitment_point = {
13877
- let current_holder_commitment_transaction_number =
13878
- next_holder_commitment_point.transaction_number() + 1;
13879
- let point = holder_signer
13880
- .get_per_commitment_point(current_holder_commitment_transaction_number, &secp_ctx)
13881
- .expect(
13882
- "Must be able to derive the current commitment point upon channel restoration",
13883
- );
13884
- Some(HolderCommitmentPoint {
13885
- transaction_number: current_holder_commitment_transaction_number,
13897
+ let current_holder_commitment_point =
13898
+ current_holder_commitment_point_opt.map(|point| HolderCommitmentPoint {
13899
+ transaction_number: next_holder_commitment_point.transaction_number() + 1,
13886
13900
point,
13887
- next_point: Some(next_holder_commitment_point.point()),
13888
- })
13889
- } ;
13901
+ // Not needed since current_holder_commitment_point is never advanced
13902
+ next_point: None,
13903
+ }) ;
13890
13904
13891
13905
Ok(FundedChannel {
13892
13906
funding: FundingScope {
0 commit comments