Skip to content

Commit 62ec2b0

Browse files
committed
fix Update pubkeys with tweak when splicing
1 parent 37c7f43 commit 62ec2b0

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

lightning/src/ln/channel.rs

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2432,7 +2432,7 @@ impl<SP: Deref> InitialRemoteCommitmentReceiver<SP> for FundedChannel<SP> where
24322432
}
24332433
}
24342434

2435-
/// A temporaty internal struct, used to return something from FundedChannel
2435+
/// A temporary internal struct, used to return something from FundedChannel
24362436
/// that implements [`FundingTxConstructorV2`], but only when it has the parts for it.
24372437
#[cfg(splicing)]
24382438
struct FundedChannelRefundingWrapper<'a, SP: Deref> where SP::Target: SignerProvider {
@@ -9088,8 +9088,23 @@ impl<SP: Deref> FundedChannel<SP> where
90889088
)?;
90899089

90909090
let post_value_to_self_msat = self.funding().value_to_self_msat.saturating_add(our_funding_satoshis);
9091+
90919092
let mut post_channel_transaction_parameters = self.funding().channel_transaction_parameters.clone();
90929093
post_channel_transaction_parameters.channel_value_satoshis = post_channel_value;
9094+
// Update the splicing 'tweak', this will rotate the keys in the signer
9095+
let prev_funding_txid = self.funding.funding_transaction.as_ref()
9096+
.map(|tx| tx.compute_txid());
9097+
post_channel_transaction_parameters.splice_parent_funding_txid = prev_funding_txid;
9098+
match &self.context.holder_signer {
9099+
ChannelSignerType::Ecdsa(ecdsa) => {
9100+
post_channel_transaction_parameters.holder_pubkeys =
9101+
ecdsa.pubkeys(prev_funding_txid, &self.context.secp_ctx);
9102+
}
9103+
// TODO (taproot|arik)
9104+
#[cfg(taproot)]
9105+
_ => todo!()
9106+
}
9107+
90939108
let pending_funding = FundingScope {
90949109
channel_transaction_parameters: post_channel_transaction_parameters,
90959110
value_to_self_msat: post_value_to_self_msat,
@@ -9198,8 +9213,23 @@ impl<SP: Deref> FundedChannel<SP> where
91989213
)?;
91999214

92009215
let post_value_to_self_msat = self.funding().value_to_self_msat.saturating_add(our_funding_satoshis);
9216+
92019217
let mut post_channel_transaction_parameters = self.funding().channel_transaction_parameters.clone();
92029218
post_channel_transaction_parameters.channel_value_satoshis = post_channel_value;
9219+
// Update the splicing 'tweak', this will rotate the keys in the signer
9220+
let prev_funding_txid = self.funding.funding_transaction.as_ref()
9221+
.map(|tx| tx.compute_txid());
9222+
post_channel_transaction_parameters.splice_parent_funding_txid = prev_funding_txid;
9223+
match &self.context.holder_signer {
9224+
ChannelSignerType::Ecdsa(ecdsa) => {
9225+
post_channel_transaction_parameters.holder_pubkeys =
9226+
ecdsa.pubkeys(prev_funding_txid, &self.context.secp_ctx);
9227+
}
9228+
// TODO (taproot|arik)
9229+
#[cfg(taproot)]
9230+
_ => todo!()
9231+
}
9232+
92039233
let pending_funding = FundingScope {
92049234
channel_transaction_parameters: post_channel_transaction_parameters,
92059235
value_to_self_msat: post_value_to_self_msat,

0 commit comments

Comments
 (0)