Fix default keypair paths
This commit is contained in:
committed by
Greg Fitzgerald
parent
eb6a30cb7c
commit
77543d83ff
@ -5,6 +5,7 @@ extern crate serde_json;
|
|||||||
use clap::{App, Arg};
|
use clap::{App, Arg};
|
||||||
use ring::rand::SystemRandom;
|
use ring::rand::SystemRandom;
|
||||||
use ring::signature::Ed25519KeyPair;
|
use ring::signature::Ed25519KeyPair;
|
||||||
|
use std::env;
|
||||||
use std::error;
|
use std::error;
|
||||||
use std::fs::{self, File};
|
use std::fs::{self, File};
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
@ -18,7 +19,6 @@ fn main() -> Result<(), Box<error::Error>> {
|
|||||||
.long("outfile")
|
.long("outfile")
|
||||||
.value_name("PATH")
|
.value_name("PATH")
|
||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
.default_value("~/.config/solana/id.json")
|
|
||||||
.help("Number of tokens with which to initialize mint"),
|
.help("Number of tokens with which to initialize mint"),
|
||||||
)
|
)
|
||||||
.get_matches();
|
.get_matches();
|
||||||
@ -27,7 +27,13 @@ fn main() -> Result<(), Box<error::Error>> {
|
|||||||
let pkcs8_bytes = Ed25519KeyPair::generate_pkcs8(&rnd)?;
|
let pkcs8_bytes = Ed25519KeyPair::generate_pkcs8(&rnd)?;
|
||||||
let serialized = serde_json::to_string(&pkcs8_bytes.to_vec())?;
|
let serialized = serde_json::to_string(&pkcs8_bytes.to_vec())?;
|
||||||
|
|
||||||
let outfile = matches.value_of("outfile").unwrap();
|
let mut path = env::home_dir().expect("home directory");
|
||||||
|
let outfile = if matches.is_present("outfile") {
|
||||||
|
matches.value_of("outfile").unwrap()
|
||||||
|
} else {
|
||||||
|
path.extend(&[".config", "solana", "id.json"]);
|
||||||
|
path.to_str().unwrap()
|
||||||
|
};
|
||||||
|
|
||||||
if outfile == "-" {
|
if outfile == "-" {
|
||||||
println!("{}", serialized);
|
println!("{}", serialized);
|
||||||
|
@ -13,6 +13,7 @@ use solana::drone::DroneRequest;
|
|||||||
use solana::fullnode::Config;
|
use solana::fullnode::Config;
|
||||||
use solana::signature::{read_keypair, KeyPair, KeyPairUtil, PublicKey, Signature};
|
use solana::signature::{read_keypair, KeyPair, KeyPairUtil, PublicKey, Signature};
|
||||||
use solana::thin_client::ThinClient;
|
use solana::thin_client::ThinClient;
|
||||||
|
use std::env;
|
||||||
use std::error;
|
use std::error;
|
||||||
use std::fmt;
|
use std::fmt;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
@ -88,7 +89,6 @@ fn parse_args() -> Result<WalletConfig, Box<error::Error>> {
|
|||||||
.long("keypair")
|
.long("keypair")
|
||||||
.value_name("PATH")
|
.value_name("PATH")
|
||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
.default_value("~/.config/solana/id.json")
|
|
||||||
.help("/path/to/id.json"),
|
.help("/path/to/id.json"),
|
||||||
)
|
)
|
||||||
.subcommand(
|
.subcommand(
|
||||||
@ -148,7 +148,14 @@ fn parse_args() -> Result<WalletConfig, Box<error::Error>> {
|
|||||||
leader = NodeInfo::new_leader(&server_addr);
|
leader = NodeInfo::new_leader(&server_addr);
|
||||||
};
|
};
|
||||||
|
|
||||||
let id = read_keypair(matches.value_of("keypair").unwrap()).expect("client keypair");
|
let mut path = env::home_dir().expect("home directory");
|
||||||
|
let id_path = if matches.is_present("keypair") {
|
||||||
|
matches.value_of("keypair").unwrap()
|
||||||
|
} else {
|
||||||
|
path.extend(&[".config", "solana", "id.json"]);
|
||||||
|
path.to_str().unwrap()
|
||||||
|
};
|
||||||
|
let id = read_keypair(id_path).expect("client keypair");
|
||||||
|
|
||||||
let mut drone_addr = leader.contact_info.tpu;
|
let mut drone_addr = leader.contact_info.tpu;
|
||||||
drone_addr.set_port(9900);
|
drone_addr.set_port(9900);
|
||||||
|
Reference in New Issue
Block a user