Skip to content

Commit 830a027

Browse files
authored
Merge pull request #3365 from TheBlueMatt/2024-10-commitment-point-init
Set `holder_commitment_point` to `Available` on upgrade
2 parents 6f5f249 + 1486b1b commit 830a027

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

lightning/src/ln/channel.rs

+10-2
Original file line numberDiff line numberDiff line change
@@ -7788,6 +7788,12 @@ impl<SP: Deref> Channel<SP> where
77887788
pub fn get_channel_reestablish<L: Deref>(&mut self, logger: &L) -> msgs::ChannelReestablish where L::Target: Logger {
77897789
assert!(self.context.channel_state.is_peer_disconnected());
77907790
assert_ne!(self.context.cur_counterparty_commitment_transaction_number, INITIAL_COMMITMENT_NUMBER);
7791+
// This is generally the first function which gets called on any given channel once we're
7792+
// up and running normally. Thus, we take this opportunity to attempt to resolve the
7793+
// `holder_commitment_point` to get any keys which we are currently missing.
7794+
self.context.holder_commitment_point.try_resolve_pending(
7795+
&self.context.holder_signer, &self.context.secp_ctx, logger,
7796+
);
77917797
// Prior to static_remotekey, my_current_per_commitment_point was critical to claiming
77927798
// current to_remote balances. However, it no longer has any use, and thus is now simply
77937799
// set to a dummy (but valid, as required by the spec) public key.
@@ -10004,8 +10010,10 @@ impl<'a, 'b, 'c, ES: Deref, SP: Deref> ReadableArgs<(&'a ES, &'b SP, u32, &'c Ch
1000410010
// TODO(async_signing): remove this expect with the Uninitialized variant
1000510011
let current = holder_signer.get_per_commitment_point(cur_holder_commitment_transaction_number, &secp_ctx)
1000610012
.expect("Must be able to derive the current commitment point upon channel restoration");
10007-
HolderCommitmentPoint::PendingNext {
10008-
transaction_number: cur_holder_commitment_transaction_number, current,
10013+
let next = holder_signer.get_per_commitment_point(cur_holder_commitment_transaction_number - 1, &secp_ctx)
10014+
.expect("Must be able to derive the next commitment point upon channel restoration");
10015+
HolderCommitmentPoint::Available {
10016+
transaction_number: cur_holder_commitment_transaction_number, current, next,
1000910017
}
1001010018
},
1001110019
};

0 commit comments

Comments
 (0)