Skip to content

Commit 6ac5f01

Browse files
committed
Drop creating new funding pubkey, new signer (from review)
1 parent 705cd6f commit 6ac5f01

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed

lightning/src/ln/channel.rs

+5-17
Original file line numberDiff line numberDiff line change
@@ -3846,25 +3846,13 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
38463846

38473847
/// Get the splice message that can be sent during splice initiation.
38483848
#[cfg(splicing)]
3849-
pub fn get_splice_init(&self, our_funding_contribution_satoshis: i64, signer_provider: &SP,
3849+
pub fn get_splice_init(&self, our_funding_contribution_satoshis: i64,
38503850
funding_feerate_perkw: u32, locktime: u32,
38513851
) -> msgs::SpliceInit {
3852-
// At this point we are not committed to the new channel value yet, but the funding pubkey
3853-
// depends on the channel value, so we create here a new funding pubkey with the new
3854-
// channel value.
3852+
// Reuse the existing funding pubkey, in spite of the channel value changing
3853+
// (though at this point we don't know the new value yet, due tue the optional counterparty contribution)
38553854
// Note that channel_keys_id is supposed NOT to change
3856-
let funding_pubkey = {
3857-
// TODO: Funding pubkey generation requires the post channel value, but that is not known yet,
3858-
// the acceptor contribution is missing. There is a need for a way to generate a new funding pubkey,
3859-
// not based on the channel value
3860-
let pre_channel_value = self.channel_value_satoshis;
3861-
let placeholder_counterparty_contribution = 0;
3862-
let incomplete_post_splice_channel_value = PendingSpliceInfoPre::compute_post_value(pre_channel_value,
3863-
our_funding_contribution_satoshis, placeholder_counterparty_contribution);
3864-
let holder_signer = signer_provider.derive_channel_signer(incomplete_post_splice_channel_value, self.channel_keys_id);
3865-
holder_signer.pubkeys().funding_pubkey
3866-
};
3867-
3855+
let funding_pubkey = self.get_holder_pubkeys().funding_pubkey.clone();
38683856
msgs::SpliceInit {
38693857
channel_id: self.channel_id,
38703858
funding_contribution_satoshis: our_funding_contribution_satoshis,
@@ -3880,7 +3868,7 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
38803868
pub fn get_splice_ack(&mut self, our_funding_contribution_satoshis: i64) -> Result<msgs::SpliceAck, ChannelError> {
38813869
// TODO(splicing): checks
38823870

3883-
// Note: at this point keys are already updated
3871+
// Reuse the existing funding pubkey, in spite of the channel value changing
38843872
let funding_pubkey = self.get_holder_pubkeys().funding_pubkey;
38853873
Ok(msgs::SpliceAck {
38863874
channel_id: self.channel_id,

lightning/src/ln/channelmanager.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4056,7 +4056,7 @@ where
40564056
our_funding_contribution: our_funding_contribution_satoshis,
40574057
});
40584058

4059-
let msg = chan.context.get_splice_init(our_funding_contribution_satoshis, &self.signer_provider, funding_feerate_perkw, locktime);
4059+
let msg = chan.context.get_splice_init(our_funding_contribution_satoshis, funding_feerate_perkw, locktime);
40604060

40614061
peer_state.pending_msg_events.push(events::MessageSendEvent::SendSpliceInit {
40624062
node_id: *counterparty_node_id,

lightning/src/ln/functional_tests_splice.rs

+14-2
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ fn test_v1_splice_in() {
6363
MessageSendEvent::SendOpenChannel,
6464
acceptor_node.node.get_our_node_id()
6565
);
66+
let expected_initiator_funding_key = "03c21e841cbc0b48197d060c71e116c185fa0ac281b7d0aa5924f535154437ca3b";
67+
assert_eq!(open_channel_message.common_fields.funding_pubkey.to_string(), expected_initiator_funding_key);
6668

6769
let _res = acceptor_node
6870
.node
@@ -73,6 +75,9 @@ fn test_v1_splice_in() {
7375
MessageSendEvent::SendAcceptChannel,
7476
initiator_node.node.get_our_node_id()
7577
);
78+
let expected_acceptor_funding_key = "039481c28b904cbe12681e79937373fc76245c1b29871028ae60ba3152162c319b";
79+
assert_eq!(accept_channel_message.common_fields.funding_pubkey.to_string(), expected_acceptor_funding_key);
80+
7681
let _res = initiator_node.node.handle_accept_channel(
7782
acceptor_node.node.get_our_node_id(),
7883
&accept_channel_message.clone(),
@@ -229,20 +234,27 @@ fn test_v1_splice_in() {
229234
)
230235
.unwrap();
231236
// Extract the splice message from node0 to node1
232-
let splice_msg = get_event_msg!(
237+
let splice_init_msg = get_event_msg!(
233238
initiator_node,
234239
MessageSendEvent::SendSpliceInit,
235240
acceptor_node.node.get_our_node_id()
236241
);
242+
assert_eq!(splice_init_msg.funding_contribution_satoshis, splice_in_sats as i64);
243+
assert_eq!(splice_init_msg.funding_feerate_perkw, funding_feerate_perkw);
244+
assert_eq!(splice_init_msg.funding_pubkey.to_string(), expected_initiator_funding_key);
245+
assert!(splice_init_msg.require_confirmed_inputs.is_none());
237246

238247
let _res =
239-
acceptor_node.node.handle_splice_init(initiator_node.node.get_our_node_id(), &splice_msg);
248+
acceptor_node.node.handle_splice_init(initiator_node.node.get_our_node_id(), &splice_init_msg);
240249
// Extract the splice_ack message from node1 to node0
241250
let splice_ack_msg = get_event_msg!(
242251
acceptor_node,
243252
MessageSendEvent::SendSpliceAck,
244253
initiator_node.node.get_our_node_id()
245254
);
255+
assert_eq!(splice_ack_msg.funding_contribution_satoshis, 0);
256+
assert_eq!(splice_ack_msg.funding_pubkey.to_string(), expected_acceptor_funding_key);
257+
assert!(splice_ack_msg.require_confirmed_inputs.is_none());
246258

247259
// still pre-splice channel: capacity not updated, channel usable, and funding tx set
248260
assert_eq!(acceptor_node.node.list_channels().len(), 1);

0 commit comments

Comments
 (0)