-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make keygen easier for usage in scripts (#105)
- Loading branch information
1 parent
3735454
commit eb75ff4
Showing
3 changed files
with
32 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,20 @@ | ||
use libp2p::{identity::ed25519, PeerId}; | ||
use std::io::Write; | ||
use clap::{self, command, Parser}; | ||
use libp2p::PeerId; | ||
use std::path::PathBuf; | ||
use subsquid_network_transport::util; | ||
|
||
fn main() -> std::io::Result<()> { | ||
let keypair = ed25519::Keypair::generate(); | ||
#[derive(Parser)] | ||
#[command(version)] | ||
struct Cli { | ||
/// Path to the generated key | ||
filename: PathBuf, | ||
} | ||
|
||
#[tokio::main] | ||
async fn main() -> anyhow::Result<()> { | ||
let filename = Cli::parse().filename; | ||
let keypair = util::get_keypair(Some(filename)).await?; | ||
let peer_id = PeerId::from_public_key(&keypair.public().into()); | ||
eprintln!("Your peer ID: {peer_id}"); | ||
std::io::stdout().write_all(&keypair.to_bytes())?; | ||
println!("{peer_id}"); | ||
Ok(()) | ||
} |