Skip to content

Commit 357ded4

Browse files
committed
common: Add derive_node_pk convenience fn
1 parent a3a6cce commit 357ded4

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

common/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ rustls = { version = "0.20", default-features = false, features = [
7272
rustls-pemfile = "1"
7373
# A wrapper type for carefully handling secrets
7474
secrecy = "0.8"
75-
# Serializing/deserializing types
75+
# Serialization / deserialization framework
7676
serde = { version = "1", features = ["derive"] }
7777
serde_qs = "0"
7878
serde_json = "1"

common/src/root_seed.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::fmt;
22
use std::str::FromStr;
33

44
use anyhow::format_err;
5-
use bitcoin::secp256k1::Secp256k1;
5+
use bitcoin::secp256k1::{PublicKey, Secp256k1};
66
use bitcoin::util::bip32::{ChildNumber, ExtendedPrivKey};
77
use bitcoin::{KeyPair, Network};
88
use rand_core::{CryptoRng, RngCore};
@@ -118,6 +118,11 @@ impl RootSeed {
118118
KeyPair::from_secret_key(&secp_ctx, node_sk)
119119
}
120120

121+
/// Derive the Lightning node pubkey.
122+
pub fn derive_node_pk<R: Crng>(&self, rng: &mut R) -> PublicKey {
123+
PublicKey::from(self.derive_node_key_pair(rng))
124+
}
125+
121126
#[cfg(test)]
122127
fn as_bytes(&self) -> &[u8] {
123128
self.0.expose_secret().as_slice()

0 commit comments

Comments
 (0)