Skip to content

Commit 0affb0f

Browse files
authored
Merge pull request lightningdevkit#7 from lightsparkdev/waterson/fallible-per-commitment-point
Only invoke get_per_commitment_point in places where it's allowed to fail
2 parents 18516e7 + 6a3ee56 commit 0affb0f

File tree

5 files changed

+75
-35
lines changed

5 files changed

+75
-35
lines changed

lightning/src/chain/channelmonitor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2639,7 +2639,7 @@ impl<Signer: WriteableEcdsaChannelSigner> ChannelMonitorImpl<Signer> {
26392639
per_commitment_number: htlc.per_commitment_number,
26402640
per_commitment_point: self.onchain_tx_handler.signer.get_per_commitment_point(
26412641
htlc.per_commitment_number, &self.onchain_tx_handler.secp_ctx,
2642-
),
2642+
).unwrap(),
26432643
htlc: htlc.htlc,
26442644
preimage: htlc.preimage,
26452645
counterparty_sig: htlc.counterparty_sig,

lightning/src/ln/channel.rs

Lines changed: 67 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,13 @@ pub(super) struct ChannelContext<Signer: ChannelSigner> {
668668
// cost of others, but should really just be changed.
669669

670670
cur_holder_commitment_transaction_number: u64,
671+
672+
// The commitment point corresponding to `cur_holder_commitment_transaction_number`, which is the
673+
// *next* state. We recompute it each time the state changes because the state changes in places
674+
// that might be fallible: in particular, if the commitment point must be fetched from a remote
675+
// source, we want to ensure it happens at a point where we can actually fail somewhat gracefully;
676+
// i.e., force-closing a channel is better than a panic!
677+
next_per_commitment_point: PublicKey,
671678
cur_counterparty_commitment_transaction_number: u64,
672679
value_to_self_msat: u64, // Excluding all pending_htlcs, excluding fees
673680
pending_inbound_htlcs: Vec<InboundHTLCOutput>,
@@ -1455,13 +1462,14 @@ impl<Signer: ChannelSigner> ChannelContext<Signer> {
14551462
/// our counterparty!)
14561463
/// The result is a transaction which we can revoke broadcastership of (ie a "local" transaction)
14571464
/// TODO Some magic rust shit to compile-time check this?
1458-
fn build_holder_transaction_keys(&self, commitment_number: u64) -> TxCreationKeys {
1459-
let per_commitment_point = self.holder_signer.get_per_commitment_point(commitment_number, &self.secp_ctx);
1465+
fn build_holder_transaction_keys(&self) -> TxCreationKeys {
14601466
let delayed_payment_base = &self.get_holder_pubkeys().delayed_payment_basepoint;
14611467
let htlc_basepoint = &self.get_holder_pubkeys().htlc_basepoint;
14621468
let counterparty_pubkeys = self.get_counterparty_pubkeys();
14631469

1464-
TxCreationKeys::derive_new(&self.secp_ctx, &per_commitment_point, delayed_payment_base, htlc_basepoint, &counterparty_pubkeys.revocation_basepoint, &counterparty_pubkeys.htlc_basepoint)
1470+
TxCreationKeys::derive_new(
1471+
&self.secp_ctx, &self.next_per_commitment_point, delayed_payment_base, htlc_basepoint,
1472+
&counterparty_pubkeys.revocation_basepoint, &counterparty_pubkeys.htlc_basepoint)
14651473
}
14661474

14671475
#[inline]
@@ -2515,7 +2523,12 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
25152523
log_trace!(logger, "Initial counterparty tx for channel {} is: txid {} tx {}",
25162524
log_bytes!(self.context.channel_id()), counterparty_initial_bitcoin_tx.txid, encode::serialize_hex(&counterparty_initial_bitcoin_tx.transaction));
25172525

2518-
let holder_signer = self.context.build_holder_transaction_keys(self.context.cur_holder_commitment_transaction_number);
2526+
self.context.next_per_commitment_point =
2527+
self.context.holder_signer.get_per_commitment_point(
2528+
self.context.cur_holder_commitment_transaction_number, &self.context.secp_ctx
2529+
).map_err(|_| ChannelError::Close("Unable to generate commitment point".to_owned()))?;
2530+
2531+
let holder_signer = self.context.build_holder_transaction_keys();
25192532
let initial_commitment_tx = self.context.build_commitment_transaction(self.context.cur_holder_commitment_transaction_number, &holder_signer, true, false, logger).tx;
25202533
{
25212534
let trusted_tx = initial_commitment_tx.trust();
@@ -2559,6 +2572,11 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
25592572
assert_eq!(self.context.channel_state & (ChannelState::MonitorUpdateInProgress as u32), 0); // We have no had any monitor(s) yet to fail update!
25602573
self.context.channel_state = ChannelState::FundingSent as u32;
25612574
self.context.cur_holder_commitment_transaction_number -= 1;
2575+
self.context.next_per_commitment_point =
2576+
self.context.holder_signer.get_per_commitment_point(
2577+
self.context.cur_holder_commitment_transaction_number, &self.context.secp_ctx
2578+
).map_err(|_| ChannelError::Close("Unable to generate commitment point".to_owned()))?;
2579+
25622580
self.context.cur_counterparty_commitment_transaction_number -= 1;
25632581

25642582
log_info!(logger, "Received funding_signed from peer for channel {}", log_bytes!(self.context.channel_id()));
@@ -2880,7 +2898,7 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
28802898

28812899
let funding_script = self.context.get_funding_redeemscript();
28822900

2883-
let keys = self.context.build_holder_transaction_keys(self.context.cur_holder_commitment_transaction_number);
2901+
let keys = self.context.build_holder_transaction_keys();
28842902

28852903
let commitment_stats = self.context.build_commitment_transaction(self.context.cur_holder_commitment_transaction_number, &keys, true, false, logger);
28862904
let commitment_txid = {
@@ -3044,6 +3062,11 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
30443062
};
30453063

30463064
self.context.cur_holder_commitment_transaction_number -= 1;
3065+
self.context.next_per_commitment_point =
3066+
self.context.holder_signer.get_per_commitment_point(
3067+
self.context.cur_holder_commitment_transaction_number, &self.context.secp_ctx
3068+
).map_err(|_| ChannelError::Close("Unable to generate commitment point".to_owned()))?;
3069+
30473070
// Note that if we need_commitment & !AwaitingRemoteRevoke we'll call
30483071
// build_commitment_no_status_check() next which will reset this to RAAFirst.
30493072
self.context.resend_order = RAACommitmentOrder::CommitmentFirst;
@@ -3494,7 +3517,7 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
34943517
// Before proposing a feerate update, check that we can actually afford the new fee.
34953518
let inbound_stats = self.context.get_inbound_pending_htlc_stats(Some(feerate_per_kw));
34963519
let outbound_stats = self.context.get_outbound_pending_htlc_stats(Some(feerate_per_kw));
3497-
let keys = self.context.build_holder_transaction_keys(self.context.cur_holder_commitment_transaction_number);
3520+
let keys = self.context.build_holder_transaction_keys();
34983521
let commitment_stats = self.context.build_commitment_transaction(self.context.cur_holder_commitment_transaction_number, &keys, true, true, logger);
34993522
let buffer_fee_msat = commit_tx_fee_sat(feerate_per_kw, commitment_stats.num_nondust_htlcs + outbound_stats.on_holder_tx_holding_cell_htlcs_count as usize + CONCURRENT_INBOUND_HTLC_FEE_BUFFER as usize, self.context.get_channel_type()) * 1000;
35003523
let holder_balance_msat = commitment_stats.local_balance_msat - outbound_stats.holding_cell_msat;
@@ -3675,10 +3698,9 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
36753698
assert!(!self.context.is_outbound() || self.context.minimum_depth == Some(0),
36763699
"Funding transaction broadcast by the local client before it should have - LDK didn't do it!");
36773700
self.context.monitor_pending_channel_ready = false;
3678-
let next_per_commitment_point = self.context.holder_signer.get_per_commitment_point(self.context.cur_holder_commitment_transaction_number, &self.context.secp_ctx);
36793701
Some(msgs::ChannelReady {
36803702
channel_id: self.context.channel_id(),
3681-
next_per_commitment_point,
3703+
next_per_commitment_point: self.context.next_per_commitment_point,
36823704
short_channel_id_alias: Some(self.context.outbound_scid_alias),
36833705
})
36843706
} else { None };
@@ -3757,12 +3779,11 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
37573779
}
37583780

37593781
fn get_last_revoke_and_ack(&self) -> msgs::RevokeAndACK {
3760-
let next_per_commitment_point = self.context.holder_signer.get_per_commitment_point(self.context.cur_holder_commitment_transaction_number, &self.context.secp_ctx);
37613782
let per_commitment_secret = self.context.holder_signer.release_commitment_secret(self.context.cur_holder_commitment_transaction_number + 2);
37623783
msgs::RevokeAndACK {
37633784
channel_id: self.context.channel_id,
37643785
per_commitment_secret,
3765-
next_per_commitment_point,
3786+
next_per_commitment_point: self.context.next_per_commitment_point,
37663787
#[cfg(taproot)]
37673788
next_local_nonce: None,
37683789
}
@@ -3861,7 +3882,9 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
38613882
}
38623883

38633884
if msg.next_remote_commitment_number > 0 {
3864-
let expected_point = self.context.holder_signer.get_per_commitment_point(INITIAL_COMMITMENT_NUMBER - msg.next_remote_commitment_number + 1, &self.context.secp_ctx);
3885+
let state_index = INITIAL_COMMITMENT_NUMBER - msg.next_remote_commitment_number + 1;
3886+
let expected_point = self.context.holder_signer.get_per_commitment_point(state_index, &self.context.secp_ctx)
3887+
.map_err(|_| ChannelError::Close(format!("Unable to retrieve per-commitment point for state {state_index}")))?;
38653888
let given_secret = SecretKey::from_slice(&msg.your_last_per_commitment_secret)
38663889
.map_err(|_| ChannelError::Close("Peer sent a garbage channel_reestablish with unparseable secret key".to_owned()))?;
38673890
if expected_point != PublicKey::from_secret_key(&self.context.secp_ctx, &given_secret) {
@@ -3926,11 +3949,10 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
39263949
}
39273950

39283951
// We have OurChannelReady set!
3929-
let next_per_commitment_point = self.context.holder_signer.get_per_commitment_point(self.context.cur_holder_commitment_transaction_number, &self.context.secp_ctx);
39303952
return Ok(ReestablishResponses {
39313953
channel_ready: Some(msgs::ChannelReady {
39323954
channel_id: self.context.channel_id(),
3933-
next_per_commitment_point,
3955+
next_per_commitment_point: self.context.next_per_commitment_point,
39343956
short_channel_id_alias: Some(self.context.outbound_scid_alias),
39353957
}),
39363958
raa: None, commitment_update: None,
@@ -3966,10 +3988,9 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
39663988

39673989
let channel_ready = if msg.next_local_commitment_number == 1 && INITIAL_COMMITMENT_NUMBER - self.context.cur_holder_commitment_transaction_number == 1 {
39683990
// We should never have to worry about MonitorUpdateInProgress resending ChannelReady
3969-
let next_per_commitment_point = self.context.holder_signer.get_per_commitment_point(self.context.cur_holder_commitment_transaction_number, &self.context.secp_ctx);
39703991
Some(msgs::ChannelReady {
39713992
channel_id: self.context.channel_id(),
3972-
next_per_commitment_point,
3993+
next_per_commitment_point: self.context.next_per_commitment_point,
39733994
short_channel_id_alias: Some(self.context.outbound_scid_alias),
39743995
})
39753996
} else { None };
@@ -4655,13 +4676,13 @@ impl<Signer: WriteableEcdsaChannelSigner> Channel<Signer> {
46554676
if need_commitment_update {
46564677
if self.context.channel_state & (ChannelState::MonitorUpdateInProgress as u32) == 0 {
46574678
if self.context.channel_state & (ChannelState::PeerDisconnected as u32) == 0 {
4658-
let next_per_commitment_point =
4659-
self.context.holder_signer.get_per_commitment_point(INITIAL_COMMITMENT_NUMBER - 1, &self.context.secp_ctx);
4660-
return Some(msgs::ChannelReady {
4661-
channel_id: self.context.channel_id,
4662-
next_per_commitment_point,
4663-
short_channel_id_alias: Some(self.context.outbound_scid_alias),
4664-
});
4679+
if let Ok(next_per_commitment_point) = self.context.holder_signer.get_per_commitment_point(INITIAL_COMMITMENT_NUMBER - 1, &self.context.secp_ctx) {
4680+
return Some(msgs::ChannelReady {
4681+
channel_id: self.context.channel_id,
4682+
next_per_commitment_point,
4683+
short_channel_id_alias: Some(self.context.outbound_scid_alias),
4684+
});
4685+
}
46654686
}
46664687
} else {
46674688
self.context.monitor_pending_channel_ready = true;
@@ -5588,6 +5609,9 @@ impl<Signer: WriteableEcdsaChannelSigner> OutboundV1Channel<Signer> {
55885609

55895610
let temporary_channel_id = entropy_source.get_secure_random_bytes();
55905611

5612+
let next_per_commitment_point = holder_signer.get_per_commitment_point(INITIAL_COMMITMENT_NUMBER, &secp_ctx)
5613+
.map_err(|_| APIError::ChannelUnavailable { err: "Unable to generate initial commitment point".to_owned()})?;
5614+
55915615
Ok(Self {
55925616
context: ChannelContext {
55935617
user_id,
@@ -5616,6 +5640,7 @@ impl<Signer: WriteableEcdsaChannelSigner> OutboundV1Channel<Signer> {
56165640
destination_script,
56175641

56185642
cur_holder_commitment_transaction_number: INITIAL_COMMITMENT_NUMBER,
5643+
next_per_commitment_point,
56195644
cur_counterparty_commitment_transaction_number: INITIAL_COMMITMENT_NUMBER,
56205645
value_to_self_msat,
56215646

@@ -5854,7 +5879,6 @@ impl<Signer: WriteableEcdsaChannelSigner> OutboundV1Channel<Signer> {
58545879
panic!("Tried to send an open_channel for a channel that has already advanced");
58555880
}
58565881

5857-
let first_per_commitment_point = self.context.holder_signer.get_per_commitment_point(self.context.cur_holder_commitment_transaction_number, &self.context.secp_ctx);
58585882
let keys = self.context.get_holder_pubkeys();
58595883

58605884
msgs::OpenChannel {
@@ -5874,7 +5898,7 @@ impl<Signer: WriteableEcdsaChannelSigner> OutboundV1Channel<Signer> {
58745898
payment_point: keys.payment_point,
58755899
delayed_payment_basepoint: keys.delayed_payment_basepoint,
58765900
htlc_basepoint: keys.htlc_basepoint,
5877-
first_per_commitment_point,
5901+
first_per_commitment_point: self.context.next_per_commitment_point,
58785902
channel_flags: if self.context.config.announced_channel {1} else {0},
58795903
shutdown_scriptpubkey: Some(match &self.context.shutdown_scriptpubkey {
58805904
Some(script) => script.clone().into_inner(),
@@ -6233,6 +6257,9 @@ impl<Signer: WriteableEcdsaChannelSigner> InboundV1Channel<Signer> {
62336257
let mut secp_ctx = Secp256k1::new();
62346258
secp_ctx.seeded_randomize(&entropy_source.get_secure_random_bytes());
62356259

6260+
let next_per_commitment_point = holder_signer.get_per_commitment_point(INITIAL_COMMITMENT_NUMBER, &secp_ctx)
6261+
.map_err(|_| ChannelError::Close("Unable to generate initial commitment point".to_owned()))?;
6262+
62366263
let chan = Self {
62376264
context: ChannelContext {
62386265
user_id,
@@ -6260,6 +6287,7 @@ impl<Signer: WriteableEcdsaChannelSigner> InboundV1Channel<Signer> {
62606287
destination_script,
62616288

62626289
cur_holder_commitment_transaction_number: INITIAL_COMMITMENT_NUMBER,
6290+
next_per_commitment_point,
62636291
cur_counterparty_commitment_transaction_number: INITIAL_COMMITMENT_NUMBER,
62646292
value_to_self_msat: msg.push_msat,
62656293

@@ -6408,7 +6436,6 @@ impl<Signer: WriteableEcdsaChannelSigner> InboundV1Channel<Signer> {
64086436
///
64096437
/// [`msgs::AcceptChannel`]: crate::ln::msgs::AcceptChannel
64106438
fn generate_accept_channel_message(&self) -> msgs::AcceptChannel {
6411-
let first_per_commitment_point = self.context.holder_signer.get_per_commitment_point(self.context.cur_holder_commitment_transaction_number, &self.context.secp_ctx);
64126439
let keys = self.context.get_holder_pubkeys();
64136440

64146441
msgs::AcceptChannel {
@@ -6425,7 +6452,7 @@ impl<Signer: WriteableEcdsaChannelSigner> InboundV1Channel<Signer> {
64256452
payment_point: keys.payment_point,
64266453
delayed_payment_basepoint: keys.delayed_payment_basepoint,
64276454
htlc_basepoint: keys.htlc_basepoint,
6428-
first_per_commitment_point,
6455+
first_per_commitment_point: self.context.next_per_commitment_point,
64296456
shutdown_scriptpubkey: Some(match &self.context.shutdown_scriptpubkey {
64306457
Some(script) => script.clone().into_inner(),
64316458
None => Builder::new().into_script(),
@@ -6448,7 +6475,7 @@ impl<Signer: WriteableEcdsaChannelSigner> InboundV1Channel<Signer> {
64486475
fn funding_created_signature<L: Deref>(&mut self, sig: &Signature, logger: &L) -> Result<(Txid, CommitmentTransaction, Signature), ChannelError> where L::Target: Logger {
64496476
let funding_script = self.context.get_funding_redeemscript();
64506477

6451-
let keys = self.context.build_holder_transaction_keys(self.context.cur_holder_commitment_transaction_number);
6478+
let keys = self.context.build_holder_transaction_keys();
64526479
let initial_commitment_tx = self.context.build_commitment_transaction(self.context.cur_holder_commitment_transaction_number, &keys, true, false, logger).tx;
64536480
{
64546481
let trusted_tx = initial_commitment_tx.trust();
@@ -6556,6 +6583,13 @@ impl<Signer: WriteableEcdsaChannelSigner> InboundV1Channel<Signer> {
65566583
self.context.cur_counterparty_commitment_transaction_number -= 1;
65576584
self.context.cur_holder_commitment_transaction_number -= 1;
65586585

6586+
let next_per_commitment_point_result = self.context.holder_signer.get_per_commitment_point(
6587+
self.context.cur_holder_commitment_transaction_number, &self.context.secp_ctx);
6588+
if next_per_commitment_point_result.is_err() {
6589+
return Err((self, ChannelError::Close("Unable to generate commitment point".to_owned())));
6590+
}
6591+
self.context.next_per_commitment_point = next_per_commitment_point_result.unwrap();
6592+
65596593
log_info!(logger, "Generated funding_signed for peer for channel {}", log_bytes!(self.context.channel_id()));
65606594

65616595
// Promote the channel to a full-fledged one now that we have updated the state and have a
@@ -7309,6 +7343,11 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
73097343
let mut secp_ctx = Secp256k1::new();
73107344
secp_ctx.seeded_randomize(&entropy_source.get_secure_random_bytes());
73117345

7346+
// If we weren't able to load the next_per_commitment_point, ask the signer for it now.
7347+
let next_per_commitment_point = holder_signer.get_per_commitment_point(
7348+
cur_holder_commitment_transaction_number, &secp_ctx
7349+
).map_err(|_| DecodeError::Io(io::ErrorKind::Other))?;
7350+
73127351
// `user_id` used to be a single u64 value. In order to remain backwards
73137352
// compatible with versions prior to 0.0.113, the u128 is serialized as two
73147353
// separate u64 values.
@@ -7361,6 +7400,7 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
73617400
destination_script,
73627401

73637402
cur_holder_commitment_transaction_number,
7403+
next_per_commitment_point,
73647404
cur_counterparty_commitment_transaction_number,
73657405
value_to_self_msat,
73667406

lightning/src/ln/functional_tests.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,7 @@ fn test_update_fee_that_funder_cannot_afford() {
714714
let chan_signer = remote_chan.get_signer();
715715
let pubkeys = chan_signer.pubkeys();
716716
(pubkeys.delayed_payment_basepoint, pubkeys.htlc_basepoint,
717-
chan_signer.get_per_commitment_point(INITIAL_COMMITMENT_NUMBER - 1, &secp_ctx),
717+
chan_signer.get_per_commitment_point(INITIAL_COMMITMENT_NUMBER - 1, &secp_ctx).unwrap(),
718718
pubkeys.funding_pubkey)
719719
};
720720

@@ -1421,7 +1421,7 @@ fn test_fee_spike_violation_fails_htlc() {
14211421
let pubkeys = chan_signer.pubkeys();
14221422
(pubkeys.revocation_basepoint, pubkeys.htlc_basepoint,
14231423
chan_signer.release_commitment_secret(INITIAL_COMMITMENT_NUMBER),
1424-
chan_signer.get_per_commitment_point(INITIAL_COMMITMENT_NUMBER - 2, &secp_ctx),
1424+
chan_signer.get_per_commitment_point(INITIAL_COMMITMENT_NUMBER - 2, &secp_ctx).unwrap(),
14251425
chan_signer.pubkeys().funding_pubkey)
14261426
};
14271427
let (remote_delayed_payment_basepoint, remote_htlc_basepoint, remote_point, remote_funding) = {
@@ -1431,7 +1431,7 @@ fn test_fee_spike_violation_fails_htlc() {
14311431
let chan_signer = remote_chan.get_signer();
14321432
let pubkeys = chan_signer.pubkeys();
14331433
(pubkeys.delayed_payment_basepoint, pubkeys.htlc_basepoint,
1434-
chan_signer.get_per_commitment_point(INITIAL_COMMITMENT_NUMBER - 1, &secp_ctx),
1434+
chan_signer.get_per_commitment_point(INITIAL_COMMITMENT_NUMBER - 1, &secp_ctx).unwrap(),
14351435
chan_signer.pubkeys().funding_pubkey)
14361436
};
14371437

lightning/src/sign/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ pub trait ChannelSigner {
345345
/// Gets the per-commitment point for a specific commitment number
346346
///
347347
/// Note that the commitment number starts at `(1 << 48) - 1` and counts backwards.
348-
fn get_per_commitment_point(&self, idx: u64, secp_ctx: &Secp256k1<secp256k1::All>) -> PublicKey;
348+
fn get_per_commitment_point(&self, idx: u64, secp_ctx: &Secp256k1<secp256k1::All>) -> Result<PublicKey, ()>;
349349

350350
/// Gets the commitment secret for a specific commitment number as part of the revocation process
351351
///
@@ -920,9 +920,9 @@ impl EntropySource for InMemorySigner {
920920
}
921921

922922
impl ChannelSigner for InMemorySigner {
923-
fn get_per_commitment_point(&self, idx: u64, secp_ctx: &Secp256k1<secp256k1::All>) -> PublicKey {
923+
fn get_per_commitment_point(&self, idx: u64, secp_ctx: &Secp256k1<secp256k1::All>) -> Result<PublicKey, ()> {
924924
let commitment_secret = SecretKey::from_slice(&chan_utils::build_commitment_secret(&self.commitment_seed, idx)).unwrap();
925-
PublicKey::from_secret_key(secp_ctx, &commitment_secret)
925+
Ok(PublicKey::from_secret_key(secp_ctx, &commitment_secret))
926926
}
927927

928928
fn release_commitment_secret(&self, idx: u64) -> [u8; 32] {

lightning/src/util/enforcing_trait_impls.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ impl EnforcingSigner {
9797
}
9898

9999
impl ChannelSigner for EnforcingSigner {
100-
fn get_per_commitment_point(&self, idx: u64, secp_ctx: &Secp256k1<secp256k1::All>) -> PublicKey {
100+
fn get_per_commitment_point(&self, idx: u64, secp_ctx: &Secp256k1<secp256k1::All>) -> Result<PublicKey, ()> {
101101
self.inner.get_per_commitment_point(idx, secp_ctx)
102102
}
103103

0 commit comments

Comments
 (0)