Bitcoin keys now load into SideNode

This commit is contained in:
Dave Hrycyszyn
2024-06-18 17:03:31 +01:00
parent 706a671902
commit 8e7d24ec7b
3 changed files with 24 additions and 11 deletions

View File

@@ -1,4 +1,4 @@
use bitcoin::secp256k1::{rand, Keypair, Secp256k1, SecretKey};
use bitcoin::secp256k1::{rand, Keypair, PublicKey, Secp256k1, SecretKey};
use std::{
fs::{self, File},
io::Write,
@@ -6,14 +6,18 @@ use std::{
str::FromStr,
};
pub(crate) fn write(key_path: &PathBuf) -> Result<(), std::io::Error> {
pub fn make_keypair() -> bitcoin::secp256k1::Keypair {
let secp = Secp256k1::new();
let (secret_key, public_key) = secp.generate_keypair(&mut rand::thread_rng());
let (secret_key, _) = secp.generate_keypair(&mut rand::thread_rng());
Keypair::from_secret_key(&secp, &secret_key)
}
pub(crate) fn write(key_path: &PathBuf) -> Result<(), std::io::Error> {
let key_pair = make_keypair();
let mut file = File::create(key_path)?;
let pub_str = public_key.to_string();
let priv_str = secret_key.display_secret().to_string();
let pub_str = key_pair.public_key().to_string();
let priv_str = key_pair.display_secret().to_string();
println!("private key: {priv_str}");
let out = format!("{pub_str}/{priv_str}");
println!("out: {out}");

View File

@@ -6,7 +6,7 @@ use tokio::{sync::mpsc, task};
use websocket::WebSocketClient;
pub mod bft_crdt_keys;
pub(crate) mod bitcoin_keys;
pub mod bitcoin_keys;
pub(crate) mod cli;
pub mod crdt;
pub(crate) mod init;