From: Matt Corallo Date: Fri, 3 Mar 2023 20:03:57 +0000 (+0000) Subject: Expose the node secret key in `{Phantom,}KeysManager` X-Git-Tag: v0.0.114~5^2 X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=refs%2Fheads%2F2023-03-get-key;p=rust-lightning Expose the node secret key in `{Phantom,}KeysManager` When we removed the private keys from the signing interface we forgot to re-add them in the public interface of our own implementations, which users may need. --- diff --git a/lightning/src/chain/keysinterface.rs b/lightning/src/chain/keysinterface.rs index a2611e7df..21331fff4 100644 --- a/lightning/src/chain/keysinterface.rs +++ b/lightning/src/chain/keysinterface.rs @@ -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()); @@ -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