Skip to content

Commit 9d291e0

Browse files
committed
Convert ChannelSigner::pubkeys to only fetch *new* pubkeys
The `remote_key` derived by default in `KeysManager` depends on the chanel's `channel_keys_id`, which generally has sufficient entropy that without it the `remote_key` cannot be re-derived. In disaster case where there is no remaining state except the `KeysManager`'s `seed`, this results in lost funds, even if the counterparty force-closes the channel. Luckily, because of the `static_remote_key` feature, there's no need for this. If the `remote_key` we derive is one of a countable set, we can simply scan the chain for outputs to our `remote_key`s. In the next commit, we'll start using different `remote_key`s based on a config knob the user sets, but with the current `ChannelSigner::pubkeys` API this would be invalid - we can't return a different set of keys for a re-derived `ChannelSigner`. Luckily, this isn't actually how LDK uses `ChannelSigner::pubkeys`, it actually only calls it when it wants a new set of pubkeys, either for a new channel or a splice. Thus, here, we rename `ChannelSigner::pubkeys` to `ChannelSigner::new_pubkeys` and update documentation to match.
1 parent 7ff74d5 commit 9d291e0

File tree

9 files changed

+56
-89
lines changed

9 files changed

+56
-89
lines changed

fuzz/src/chanmon_consistency.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -382,11 +382,9 @@ impl SignerProvider for KeyProvider {
382382
}
383383

384384
fn derive_channel_signer(&self, channel_keys_id: [u8; 32]) -> Self::EcdsaSigner {
385-
let secp_ctx = Secp256k1::signing_only();
386385
let id = channel_keys_id[0];
387386
#[rustfmt::skip]
388387
let keys = InMemorySigner::new(
389-
&secp_ctx,
390388
SecretKey::from_slice(&[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, self.node_secret[31]]).unwrap(),
391389
SecretKey::from_slice(&[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, self.node_secret[31]]).unwrap(),
392390
// We leave both the v1 and v2 derivation to_remote keys the same as there's not any

fuzz/src/full_stack.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,6 @@ impl SignerProvider for KeyProvider {
458458
}
459459

460460
fn derive_channel_signer(&self, keys_id: [u8; 32]) -> Self::EcdsaSigner {
461-
let secp_ctx = Secp256k1::signing_only();
462461
let ctr = keys_id[0];
463462
let (inbound, state) = self.signer_state.borrow().get(&ctr).unwrap().clone();
464463

@@ -479,7 +478,7 @@ impl SignerProvider for KeyProvider {
479478
f = key;
480479
// We leave both the v1 and v2 derivation to_remote keys the same as there's not any real
481480
// reason to fuzz differences here, and it keeps us consistent with past behavior.
482-
let signer = InMemorySigner::new(&secp_ctx, a, b, c, c, d, e, f, keys_id, keys_id);
481+
let signer = InMemorySigner::new(a, b, c, c, d, e, f, keys_id, keys_id);
483482

484483
TestChannelSigner::new_with_revoked(DynSigner::new(signer), state, false, false)
485484
}

lightning/src/chain/channelmonitor.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6699,7 +6699,7 @@ mod tests {
66996699
use crate::ln::functional_test_utils::*;
67006700
use crate::ln::script::ShutdownScript;
67016701
use crate::ln::types::ChannelId;
6702-
use crate::sign::InMemorySigner;
6702+
use crate::sign::{ChannelSigner, InMemorySigner};
67036703
use crate::sync::Arc;
67046704
use crate::types::features::ChannelTypeFeatures;
67056705
use crate::types::payment::{PaymentHash, PaymentPreimage};
@@ -6872,7 +6872,6 @@ mod tests {
68726872
}
68736873

68746874
let keys = InMemorySigner::new(
6875-
&secp_ctx,
68766875
SecretKey::from_slice(&[41; 32]).unwrap(),
68776876
SecretKey::from_slice(&[41; 32]).unwrap(),
68786877
SecretKey::from_slice(&[41; 32]).unwrap(),
@@ -6894,7 +6893,7 @@ mod tests {
68946893
let funding_outpoint = OutPoint { txid: Txid::all_zeros(), index: u16::MAX };
68956894
let channel_id = ChannelId::v1_from_funding_outpoint(funding_outpoint);
68966895
let channel_parameters = ChannelTransactionParameters {
6897-
holder_pubkeys: keys.holder_channel_pubkeys.clone(),
6896+
holder_pubkeys: keys.new_pubkeys(None, &secp_ctx),
68986897
holder_selected_contest_delay: 66,
68996898
is_outbound_from_holder: true,
69006899
counterparty_parameters: Some(CounterpartyChannelTransactionParameters {
@@ -7135,7 +7134,6 @@ mod tests {
71357134
let dummy_key = PublicKey::from_secret_key(&secp_ctx, &SecretKey::from_slice(&[42; 32]).unwrap());
71367135

71377136
let keys = InMemorySigner::new(
7138-
&secp_ctx,
71397137
SecretKey::from_slice(&[41; 32]).unwrap(),
71407138
SecretKey::from_slice(&[41; 32]).unwrap(),
71417139
SecretKey::from_slice(&[41; 32]).unwrap(),
@@ -7157,7 +7155,7 @@ mod tests {
71577155
let funding_outpoint = OutPoint { txid: Txid::all_zeros(), index: u16::MAX };
71587156
let channel_id = ChannelId::v1_from_funding_outpoint(funding_outpoint);
71597157
let channel_parameters = ChannelTransactionParameters {
7160-
holder_pubkeys: keys.holder_channel_pubkeys.clone(),
7158+
holder_pubkeys: keys.new_pubkeys(None, &secp_ctx),
71617159
holder_selected_contest_delay: 66,
71627160
is_outbound_from_holder: true,
71637161
counterparty_parameters: Some(CounterpartyChannelTransactionParameters {

lightning/src/chain/onchaintx.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1287,7 +1287,7 @@ mod tests {
12871287
};
12881288
use crate::ln::channel_keys::{DelayedPaymentBasepoint, HtlcBasepoint, RevocationBasepoint};
12891289
use crate::ln::functional_test_utils::create_dummy_block;
1290-
use crate::sign::{ChannelDerivationParameters, HTLCDescriptor, InMemorySigner};
1290+
use crate::sign::{ChannelDerivationParameters, ChannelSigner, HTLCDescriptor, InMemorySigner};
12911291
use crate::types::payment::{PaymentHash, PaymentPreimage};
12921292
use crate::util::test_utils::{TestBroadcaster, TestFeeEstimator, TestLogger};
12931293

@@ -1301,7 +1301,6 @@ mod tests {
13011301
fn test_broadcast_height() {
13021302
let secp_ctx = Secp256k1::new();
13031303
let signer = InMemorySigner::new(
1304-
&secp_ctx,
13051304
SecretKey::from_slice(&[41; 32]).unwrap(),
13061305
SecretKey::from_slice(&[41; 32]).unwrap(),
13071306
SecretKey::from_slice(&[41; 32]).unwrap(),
@@ -1339,7 +1338,7 @@ mod tests {
13391338
// Use non-anchor channels so that HTLC-Timeouts are broadcast immediately instead of sent
13401339
// to the user for external funding.
13411340
let chan_params = ChannelTransactionParameters {
1342-
holder_pubkeys: signer.holder_channel_pubkeys.clone(),
1341+
holder_pubkeys: signer.new_pubkeys(None, &secp_ctx),
13431342
holder_selected_contest_delay: 66,
13441343
is_outbound_from_holder: true,
13451344
counterparty_parameters: Some(CounterpartyChannelTransactionParameters {

lightning/src/ln/chan_utils.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,11 +1014,11 @@ pub struct ChannelTransactionParameters {
10141014
/// If a channel was funded with transaction A, and later spliced with transaction B, this field
10151015
/// tracks the txid of transaction A.
10161016
///
1017-
/// See [`compute_funding_key_tweak`] and [`ChannelSigner::pubkeys`] for more context on how
1017+
/// See [`compute_funding_key_tweak`] and [`ChannelSigner::new_pubkeys`] for more context on how
10181018
/// this may be used.
10191019
///
10201020
/// [`compute_funding_key_tweak`]: crate::sign::compute_funding_key_tweak
1021-
/// [`ChannelSigner::pubkeys`]: crate::sign::ChannelSigner::pubkeys
1021+
/// [`ChannelSigner::new_pubkeys`]: crate::sign::ChannelSigner::new_pubkeys
10221022
pub splice_parent_funding_txid: Option<Txid>,
10231023
/// This channel's type, as negotiated during channel open. For old objects where this field
10241024
/// wasn't serialized, it will default to static_remote_key at deserialization.
@@ -2240,8 +2240,8 @@ mod tests {
22402240
let counterparty_signer = keys_provider.derive_channel_signer(keys_provider.generate_channel_keys_id(true, 1));
22412241
let per_commitment_secret = SecretKey::from_slice(&<Vec<u8>>::from_hex("1f1e1d1c1b1a191817161514131211100f0e0d0c0b0a09080706050403020100").unwrap()[..]).unwrap();
22422242
let per_commitment_point = PublicKey::from_secret_key(&secp_ctx, &per_commitment_secret);
2243-
let holder_pubkeys = signer.pubkeys(None, &secp_ctx);
2244-
let counterparty_pubkeys = counterparty_signer.pubkeys(None, &secp_ctx).clone();
2243+
let holder_pubkeys = signer.new_pubkeys(None, &secp_ctx);
2244+
let counterparty_pubkeys = counterparty_signer.new_pubkeys(None, &secp_ctx).clone();
22452245
let channel_parameters = ChannelTransactionParameters {
22462246
holder_pubkeys: holder_pubkeys.clone(),
22472247
holder_selected_contest_delay: 0,

lightning/src/ln/channel.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2380,7 +2380,7 @@ impl FundingScope {
23802380

23812381
// Rotate the pubkeys using the prev_funding_txid as a tweak
23822382
let prev_funding_txid = prev_funding.get_funding_txid();
2383-
let holder_pubkeys = context.holder_pubkeys(prev_funding_txid);
2383+
let holder_pubkeys = context.new_holder_pubkeys(prev_funding_txid);
23842384

23852385
let channel_parameters = &prev_funding.channel_transaction_parameters;
23862386
let mut post_channel_transaction_parameters = ChannelTransactionParameters {
@@ -3365,7 +3365,7 @@ where
33653365

33663366
// TODO(dual_funding): Checks for `funding_feerate_sat_per_1000_weight`?
33673367

3368-
let pubkeys = holder_signer.pubkeys(None, &secp_ctx);
3368+
let pubkeys = holder_signer.new_pubkeys(None, &secp_ctx);
33693369

33703370
let funding = FundingScope {
33713371
value_to_self_msat,
@@ -3603,7 +3603,7 @@ where
36033603
Err(_) => return Err(APIError::ChannelUnavailable { err: "Failed to get destination script".to_owned()}),
36043604
};
36053605

3606-
let pubkeys = holder_signer.pubkeys(None, &secp_ctx);
3606+
let pubkeys = holder_signer.new_pubkeys(None, &secp_ctx);
36073607
let temporary_channel_id = temporary_channel_id_fn.map(|f| f(&pubkeys))
36083608
.unwrap_or_else(|| ChannelId::temporary_from_entropy_source(entropy_source));
36093609

@@ -3967,9 +3967,9 @@ where
39673967
}
39683968

39693969
/// Returns holder pubkeys to use for the channel.
3970-
fn holder_pubkeys(&self, prev_funding_txid: Option<Txid>) -> ChannelPublicKeys {
3970+
fn new_holder_pubkeys(&self, prev_funding_txid: Option<Txid>) -> ChannelPublicKeys {
39713971
match &self.holder_signer {
3972-
ChannelSignerType::Ecdsa(ecdsa) => ecdsa.pubkeys(prev_funding_txid, &self.secp_ctx),
3972+
ChannelSignerType::Ecdsa(ecdsa) => ecdsa.new_pubkeys(prev_funding_txid, &self.secp_ctx),
39733973
// TODO (taproot|arik)
39743974
#[cfg(taproot)]
39753975
_ => todo!(),
@@ -11553,7 +11553,7 @@ where
1155311553

1155411554
// Rotate the pubkeys using the prev_funding_txid as a tweak
1155511555
let prev_funding_txid = self.funding.get_funding_txid();
11556-
let funding_pubkey = self.context.holder_pubkeys(prev_funding_txid).funding_pubkey;
11556+
let funding_pubkey = self.context.new_holder_pubkeys(prev_funding_txid).funding_pubkey;
1155711557

1155811558
Ok(msgs::SpliceInit {
1155911559
channel_id: self.context.channel_id,
@@ -15983,7 +15983,6 @@ mod tests {
1598315983
let secp_ctx = Secp256k1::new();
1598415984

1598515985
let signer = InMemorySigner::new(
15986-
&secp_ctx,
1598715986
SecretKey::from_slice(&<Vec<u8>>::from_hex("30ff4956bbdd3222d44cc5e8a1261dab1e07957bdac5ae88fe3261ef321f3749").unwrap()[..]).unwrap(),
1598815987
SecretKey::from_slice(&<Vec<u8>>::from_hex("0fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff").unwrap()[..]).unwrap(),
1598915988
SecretKey::from_slice(&<Vec<u8>>::from_hex("1111111111111111111111111111111111111111111111111111111111111111").unwrap()[..]).unwrap(),
@@ -15997,7 +15996,7 @@ mod tests {
1599715996
[0; 32],
1599815997
);
1599915998

16000-
let holder_pubkeys = signer.pubkeys(None, &secp_ctx);
15999+
let holder_pubkeys = signer.new_pubkeys(None, &secp_ctx);
1600116000
assert_eq!(holder_pubkeys.funding_pubkey.serialize()[..],
1600216001
<Vec<u8>>::from_hex("023da092f6980e58d2c037173180e9a465476026ee50f96695963e8efe436f54eb").unwrap()[..]);
1600316002
let keys_provider = Keys { signer: signer.clone() };

lightning/src/sign/mod.rs

Lines changed: 36 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -270,11 +270,14 @@ pub enum SpendableOutputDescriptor {
270270
/// it is an output from an old state which we broadcast (which should never happen).
271271
///
272272
/// To derive the delayed payment key which is used to sign this input, you must pass the
273-
/// holder [`InMemorySigner::delayed_payment_base_key`] (i.e., the private key which corresponds to the
274-
/// [`ChannelPublicKeys::delayed_payment_basepoint`] in [`ChannelSigner::pubkeys`]) and the provided
275-
/// [`DelayedPaymentOutputDescriptor::per_commitment_point`] to [`chan_utils::derive_private_key`]. The DelayedPaymentKey can be
276-
/// generated without the secret key using [`DelayedPaymentKey::from_basepoint`] and only the
277-
/// [`ChannelPublicKeys::delayed_payment_basepoint`] which appears in [`ChannelSigner::pubkeys`].
273+
/// holder [`InMemorySigner::delayed_payment_base_key`] (i.e., the private key which
274+
/// corresponds to the [`ChannelPublicKeys::delayed_payment_basepoint`] in
275+
/// [`ChannelSigner::new_pubkeys`]) and the provided
276+
/// [`DelayedPaymentOutputDescriptor::per_commitment_point`] to
277+
/// [`chan_utils::derive_private_key`]. The DelayedPaymentKey can be generated without the
278+
/// secret key using [`DelayedPaymentKey::from_basepoint`] and only the
279+
/// [`ChannelPublicKeys::delayed_payment_basepoint`] which appears in
280+
/// [`ChannelSigner::new_pubkeys`].
278281
///
279282
/// To derive the [`DelayedPaymentOutputDescriptor::revocation_pubkey`] provided here (which is
280283
/// used in the witness script generation), you must pass the counterparty
@@ -289,7 +292,7 @@ pub enum SpendableOutputDescriptor {
289292
/// [`chan_utils::get_revokeable_redeemscript`].
290293
DelayedPaymentOutput(DelayedPaymentOutputDescriptor),
291294
/// An output spendable exclusively by our payment key (i.e., the private key that corresponds
292-
/// to the `payment_point` in [`ChannelSigner::pubkeys`]). The output type depends on the
295+
/// to the `payment_point` in [`ChannelSigner::new_pubkeys`]). The output type depends on the
293296
/// channel type negotiated.
294297
///
295298
/// On an anchor outputs channel, the witness in the spending input is:
@@ -789,14 +792,17 @@ pub trait ChannelSigner {
789792
/// and pause future signing operations until this validation completes.
790793
fn validate_counterparty_revocation(&self, idx: u64, secret: &SecretKey) -> Result<(), ()>;
791794

792-
/// Returns the holder's channel public keys and basepoints.
795+
/// Returns a *new* set of holder channel public keys and basepoints. They may be the same as a
796+
/// previous value, but are also allowed to change arbitrarily. Signing methods must still
797+
/// support signing for any keys which have ever been returned. This should only be called
798+
/// either for new channels or new splices.
793799
///
794800
/// `splice_parent_funding_txid` can be used to compute a tweak to rotate the funding key in the
795801
/// 2-of-2 multisig script during a splice. See [`compute_funding_key_tweak`] for an example
796802
/// tweak and more details.
797803
///
798804
/// This method is *not* asynchronous. Instead, the value must be cached locally.
799-
fn pubkeys(
805+
fn new_pubkeys(
800806
&self, splice_parent_funding_txid: Option<Txid>, secp_ctx: &Secp256k1<secp256k1::All>,
801807
) -> ChannelPublicKeys;
802808

@@ -1095,7 +1101,7 @@ mod sealed {
10951101
use bitcoin::secp256k1::{Scalar, SecretKey};
10961102

10971103
#[derive(Clone, PartialEq)]
1098-
pub struct MaybeTweakedSecretKey(SecretKey);
1104+
pub struct MaybeTweakedSecretKey(pub(super) SecretKey);
10991105

11001106
impl From<SecretKey> for MaybeTweakedSecretKey {
11011107
fn from(value: SecretKey) -> Self {
@@ -1163,8 +1169,6 @@ pub struct InMemorySigner {
11631169
pub htlc_base_key: SecretKey,
11641170
/// Commitment seed.
11651171
pub commitment_seed: [u8; 32],
1166-
/// Holder public keys and basepoints.
1167-
pub(crate) holder_channel_pubkeys: ChannelPublicKeys,
11681172
/// Key derivation parameters.
11691173
channel_keys_id: [u8; 32],
11701174
/// A source of random bytes.
@@ -1180,7 +1184,6 @@ impl PartialEq for InMemorySigner {
11801184
&& self.delayed_payment_base_key == other.delayed_payment_base_key
11811185
&& self.htlc_base_key == other.htlc_base_key
11821186
&& self.commitment_seed == other.commitment_seed
1183-
&& self.holder_channel_pubkeys == other.holder_channel_pubkeys
11841187
&& self.channel_keys_id == other.channel_keys_id
11851188
}
11861189
}
@@ -1195,7 +1198,6 @@ impl Clone for InMemorySigner {
11951198
delayed_payment_base_key: self.delayed_payment_base_key.clone(),
11961199
htlc_base_key: self.htlc_base_key.clone(),
11971200
commitment_seed: self.commitment_seed.clone(),
1198-
holder_channel_pubkeys: self.holder_channel_pubkeys.clone(),
11991201
channel_keys_id: self.channel_keys_id,
12001202
entropy_source: RandomBytes::new(self.get_secure_random_bytes()),
12011203
}
@@ -1204,21 +1206,11 @@ impl Clone for InMemorySigner {
12041206

12051207
impl InMemorySigner {
12061208
#[cfg(any(feature = "_test_utils", test))]
1207-
pub fn new<C: Signing>(
1208-
secp_ctx: &Secp256k1<C>, funding_key: SecretKey, revocation_base_key: SecretKey,
1209-
payment_key_v1: SecretKey, payment_key_v2: SecretKey, delayed_payment_base_key: SecretKey,
1210-
htlc_base_key: SecretKey, commitment_seed: [u8; 32], channel_keys_id: [u8; 32],
1211-
rand_bytes_unique_start: [u8; 32],
1209+
pub fn new(
1210+
funding_key: SecretKey, revocation_base_key: SecretKey, payment_key_v1: SecretKey,
1211+
payment_key_v2: SecretKey, delayed_payment_base_key: SecretKey, htlc_base_key: SecretKey,
1212+
commitment_seed: [u8; 32], channel_keys_id: [u8; 32], rand_bytes_unique_start: [u8; 32],
12121213
) -> InMemorySigner {
1213-
// TODO: Make the key used dynamic
1214-
let holder_channel_pubkeys = InMemorySigner::make_holder_keys(
1215-
secp_ctx,
1216-
&funding_key,
1217-
&revocation_base_key,
1218-
&payment_key_v1,
1219-
&delayed_payment_base_key,
1220-
&htlc_base_key,
1221-
);
12221214
InMemorySigner {
12231215
funding_key: sealed::MaybeTweakedSecretKey::from(funding_key),
12241216
revocation_base_key,
@@ -1227,28 +1219,17 @@ impl InMemorySigner {
12271219
delayed_payment_base_key,
12281220
htlc_base_key,
12291221
commitment_seed,
1230-
holder_channel_pubkeys,
12311222
channel_keys_id,
12321223
entropy_source: RandomBytes::new(rand_bytes_unique_start),
12331224
}
12341225
}
12351226

12361227
#[cfg(not(any(feature = "_test_utils", test)))]
1237-
fn new<C: Signing>(
1238-
secp_ctx: &Secp256k1<C>, funding_key: SecretKey, revocation_base_key: SecretKey,
1239-
payment_key_v1: SecretKey, payment_key_v2: SecretKey, delayed_payment_base_key: SecretKey,
1240-
htlc_base_key: SecretKey, commitment_seed: [u8; 32], channel_keys_id: [u8; 32],
1241-
rand_bytes_unique_start: [u8; 32],
1228+
fn new(
1229+
funding_key: SecretKey, revocation_base_key: SecretKey, payment_key_v1: SecretKey,
1230+
payment_key_v2: SecretKey, delayed_payment_base_key: SecretKey, htlc_base_key: SecretKey,
1231+
commitment_seed: [u8; 32], channel_keys_id: [u8; 32], rand_bytes_unique_start: [u8; 32],
12421232
) -> InMemorySigner {
1243-
// TODO: Make the key used dynamic
1244-
let holder_channel_pubkeys = InMemorySigner::make_holder_keys(
1245-
secp_ctx,
1246-
&funding_key,
1247-
&revocation_base_key,
1248-
&payment_key_v1,
1249-
&delayed_payment_base_key,
1250-
&htlc_base_key,
1251-
);
12521233
InMemorySigner {
12531234
funding_key: sealed::MaybeTweakedSecretKey::from(funding_key),
12541235
revocation_base_key,
@@ -1257,7 +1238,6 @@ impl InMemorySigner {
12571238
delayed_payment_base_key,
12581239
htlc_base_key,
12591240
commitment_seed,
1260-
holder_channel_pubkeys,
12611241
channel_keys_id,
12621242
entropy_source: RandomBytes::new(rand_bytes_unique_start),
12631243
}
@@ -1271,22 +1251,6 @@ impl InMemorySigner {
12711251
self.funding_key.with_tweak(tweak)
12721252
}
12731253

1274-
fn make_holder_keys<C: Signing>(
1275-
secp_ctx: &Secp256k1<C>, funding_key: &SecretKey, revocation_base_key: &SecretKey,
1276-
payment_key: &SecretKey, delayed_payment_base_key: &SecretKey, htlc_base_key: &SecretKey,
1277-
) -> ChannelPublicKeys {
1278-
let from_secret = |s: &SecretKey| PublicKey::from_secret_key(secp_ctx, s);
1279-
ChannelPublicKeys {
1280-
funding_pubkey: from_secret(&funding_key),
1281-
revocation_basepoint: RevocationBasepoint::from(from_secret(&revocation_base_key)),
1282-
payment_point: from_secret(&payment_key),
1283-
delayed_payment_basepoint: DelayedPaymentBasepoint::from(from_secret(
1284-
&delayed_payment_base_key,
1285-
)),
1286-
htlc_basepoint: HtlcBasepoint::from(from_secret(&htlc_base_key)),
1287-
}
1288-
}
1289-
12901254
/// Sign the single input of `spend_tx` at index `input_idx`, which spends the output described
12911255
/// by `descriptor`, returning the witness stack for the input.
12921256
///
@@ -1476,10 +1440,21 @@ impl ChannelSigner for InMemorySigner {
14761440
Ok(())
14771441
}
14781442

1479-
fn pubkeys(
1443+
fn new_pubkeys(
14801444
&self, splice_parent_funding_txid: Option<Txid>, secp_ctx: &Secp256k1<secp256k1::All>,
14811445
) -> ChannelPublicKeys {
1482-
let mut pubkeys = self.holder_channel_pubkeys.clone();
1446+
let from_secret = |s: &SecretKey| PublicKey::from_secret_key(secp_ctx, s);
1447+
let mut pubkeys = ChannelPublicKeys {
1448+
funding_pubkey: from_secret(&self.funding_key.0),
1449+
revocation_basepoint: RevocationBasepoint::from(from_secret(&self.revocation_base_key)),
1450+
// TODO: Make the payment_key used dynamic
1451+
payment_point: from_secret(&self.payment_key_v1),
1452+
delayed_payment_basepoint: DelayedPaymentBasepoint::from(from_secret(
1453+
&self.delayed_payment_base_key,
1454+
)),
1455+
htlc_basepoint: HtlcBasepoint::from(from_secret(&self.htlc_base_key)),
1456+
};
1457+
14831458
if splice_parent_funding_txid.is_some() {
14841459
pubkeys.funding_pubkey =
14851460
self.funding_key(splice_parent_funding_txid).public_key(secp_ctx);
@@ -2135,7 +2110,6 @@ impl KeysManager {
21352110
u64::from_le_bytes(commitment_seed[..8].try_into().expect("8 bytes"));
21362111

21372112
InMemorySigner::new(
2138-
&self.secp_ctx,
21392113
funding_key,
21402114
revocation_base_key,
21412115
payment_key_v1,

0 commit comments

Comments
 (0)