Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose the node secret key in {Phantom,}KeysManager #2070

Merged
merged 1 commit into from
Mar 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions lightning/src/chain/keysinterface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1064,6 +1064,12 @@ impl KeysManager {
Err(_) => panic!("Your rng is busted"),
}
}

/// Gets the "node_id" secret key used to sign gossip announcements, decode onion data, etc.
pub fn get_node_secret_key(&self) -> SecretKey {
self.node_secret
}

/// Derive an old [`WriteableEcdsaChannelSigner`] containing per-channel secrets based on a key derivation parameters.
pub fn derive_channel_keys(&self, channel_value_satoshis: u64, params: &[u8; 32]) -> InMemorySigner {
let chan_id = u64::from_be_bytes(params[0..8].try_into().unwrap());
Expand Down Expand Up @@ -1458,6 +1464,17 @@ impl PhantomKeysManager {
pub fn derive_channel_keys(&self, channel_value_satoshis: u64, params: &[u8; 32]) -> InMemorySigner {
self.inner.derive_channel_keys(channel_value_satoshis, params)
}

/// Gets the "node_id" secret key used to sign gossip announcements, decode onion data, etc.
pub fn get_node_secret_key(&self) -> SecretKey {
self.inner.get_node_secret_key()
}

/// Gets the "node_id" secret key of the phantom node used to sign invoices, decode the
/// last-hop onion data, etc.
pub fn get_phantom_node_secret_key(&self) -> SecretKey {
self.phantom_secret
}
}

// Ensure that EcdsaChannelSigner can have a vtable
Expand Down