@@ -962,8 +962,12 @@ impl HolderCommitmentPoint {
962
962
{
963
963
HolderCommitmentPoint::Available {
964
964
transaction_number: INITIAL_COMMITMENT_NUMBER,
965
- current: signer.as_ref().get_per_commitment_point(INITIAL_COMMITMENT_NUMBER, secp_ctx),
966
- next: signer.as_ref().get_per_commitment_point(INITIAL_COMMITMENT_NUMBER - 1, secp_ctx),
965
+ // TODO(async_signing): remove this expect with the Uninitialized variant
966
+ current: signer.as_ref().get_per_commitment_point(INITIAL_COMMITMENT_NUMBER, secp_ctx)
967
+ .expect("Signer must be able to provide initial commitment point"),
968
+ // TODO(async_signing): remove this expect with the Uninitialized variant
969
+ next: signer.as_ref().get_per_commitment_point(INITIAL_COMMITMENT_NUMBER - 1, secp_ctx)
970
+ .expect("Signer must be able to provide second commitment point"),
967
971
}
968
972
}
969
973
@@ -1001,9 +1005,12 @@ impl HolderCommitmentPoint {
1001
1005
where SP::Target: SignerProvider, L::Target: Logger
1002
1006
{
1003
1007
if let HolderCommitmentPoint::PendingNext { transaction_number, current } = self {
1004
- let next = signer.as_ref().get_per_commitment_point(*transaction_number - 1, secp_ctx);
1005
- log_trace!(logger, "Retrieved next per-commitment point {}", *transaction_number - 1);
1006
- *self = HolderCommitmentPoint::Available { transaction_number: *transaction_number, current: *current, next };
1008
+ if let Ok(next) = signer.as_ref().get_per_commitment_point(*transaction_number - 1, secp_ctx) {
1009
+ log_trace!(logger, "Retrieved next per-commitment point {}", *transaction_number - 1);
1010
+ *self = HolderCommitmentPoint::Available { transaction_number: *transaction_number, current: *current, next };
1011
+ } else {
1012
+ log_trace!(logger, "Next per-commitment point {} is pending", transaction_number);
1013
+ }
1007
1014
}
1008
1015
}
1009
1016
@@ -5622,7 +5629,9 @@ impl<SP: Deref> Channel<SP> where
5622
5629
5623
5630
let our_commitment_transaction = INITIAL_COMMITMENT_NUMBER - self.context.holder_commitment_point.transaction_number() - 1;
5624
5631
if msg.next_remote_commitment_number > 0 {
5625
- let expected_point = self.context.holder_signer.as_ref().get_per_commitment_point(INITIAL_COMMITMENT_NUMBER - msg.next_remote_commitment_number + 1, &self.context.secp_ctx);
5632
+ let expected_point = self.context.holder_signer.as_ref()
5633
+ .get_per_commitment_point(INITIAL_COMMITMENT_NUMBER - msg.next_remote_commitment_number + 1, &self.context.secp_ctx)
5634
+ .expect("TODO: async signing is not yet supported for per commitment points upon channel reestablishment");
5626
5635
let given_secret = SecretKey::from_slice(&msg.your_last_per_commitment_secret)
5627
5636
.map_err(|_| ChannelError::close("Peer sent a garbage channel_reestablish with unparseable secret key".to_owned()))?;
5628
5637
if expected_point != PublicKey::from_secret_key(&self.context.secp_ctx, &given_secret) {
@@ -8230,10 +8239,12 @@ impl<SP: Deref> OutboundV2Channel<SP> where SP::Target: SignerProvider {
8230
8239
8231
8240
let first_per_commitment_point = self.context.holder_signer.as_ref()
8232
8241
.get_per_commitment_point(self.context.holder_commitment_point.transaction_number(),
8233
- &self.context.secp_ctx);
8242
+ &self.context.secp_ctx)
8243
+ .expect("TODO: async signing is not yet supported for commitment points in v2 channel establishment");
8234
8244
let second_per_commitment_point = self.context.holder_signer.as_ref()
8235
8245
.get_per_commitment_point(self.context.holder_commitment_point.transaction_number() - 1,
8236
- &self.context.secp_ctx);
8246
+ &self.context.secp_ctx)
8247
+ .expect("TODO: async signing is not yet supported for commitment points in v2 channel establishment");
8237
8248
let keys = self.context.get_holder_pubkeys();
8238
8249
8239
8250
msgs::OpenChannelV2 {
@@ -8380,9 +8391,11 @@ impl<SP: Deref> InboundV2Channel<SP> where SP::Target: SignerProvider {
8380
8391
/// [`msgs::AcceptChannelV2`]: crate::ln::msgs::AcceptChannelV2
8381
8392
fn generate_accept_channel_v2_message(&self) -> msgs::AcceptChannelV2 {
8382
8393
let first_per_commitment_point = self.context.holder_signer.as_ref().get_per_commitment_point(
8383
- self.context.holder_commitment_point.transaction_number(), &self.context.secp_ctx);
8394
+ self.context.holder_commitment_point.transaction_number(), &self.context.secp_ctx)
8395
+ .expect("TODO: async signing is not yet supported for commitment points in v2 channel establishment");
8384
8396
let second_per_commitment_point = self.context.holder_signer.as_ref().get_per_commitment_point(
8385
- self.context.holder_commitment_point.transaction_number() - 1, &self.context.secp_ctx);
8397
+ self.context.holder_commitment_point.transaction_number() - 1, &self.context.secp_ctx)
8398
+ .expect("TODO: async signing is not yet supported for commitment points in v2 channel establishment");
8386
8399
let keys = self.context.get_holder_pubkeys();
8387
8400
8388
8401
msgs::AcceptChannelV2 {
@@ -9334,14 +9347,16 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
9334
9347
(Some(current), Some(next)) => HolderCommitmentPoint::Available {
9335
9348
transaction_number: cur_holder_commitment_transaction_number, current, next
9336
9349
},
9337
- (Some(current), _) => HolderCommitmentPoint::Available {
9350
+ (Some(current), _) => HolderCommitmentPoint::PendingNext {
9338
9351
transaction_number: cur_holder_commitment_transaction_number, current,
9339
- next: holder_signer.get_per_commitment_point(cur_holder_commitment_transaction_number - 1, &secp_ctx),
9340
9352
},
9341
- (_, _) => HolderCommitmentPoint::Available {
9342
- transaction_number: cur_holder_commitment_transaction_number,
9343
- current: holder_signer.get_per_commitment_point(cur_holder_commitment_transaction_number, &secp_ctx),
9344
- next: holder_signer.get_per_commitment_point(cur_holder_commitment_transaction_number - 1, &secp_ctx),
9353
+ (_, _) => {
9354
+ // TODO(async_signing): remove this expect with the Uninitialized variant
9355
+ let current = holder_signer.get_per_commitment_point(cur_holder_commitment_transaction_number, &secp_ctx)
9356
+ .expect("Must be able to derive the current commitment point upon channel restoration");
9357
+ HolderCommitmentPoint::PendingNext {
9358
+ transaction_number: cur_holder_commitment_transaction_number, current,
9359
+ }
9345
9360
},
9346
9361
};
9347
9362
0 commit comments