Update wallet to trigger keygen if no keypair provided and no keypair found in default location
This commit is contained in:
parent
10daa015c4
commit
a06f4b1d44
|
@ -13,6 +13,7 @@ use solana::thin_client::poll_gossip_for_leader;
|
||||||
use solana::wallet::{parse_command, process_command, WalletConfig, WalletError};
|
use solana::wallet::{parse_command, process_command, WalletConfig, WalletError};
|
||||||
use std::error;
|
use std::error;
|
||||||
use std::net::SocketAddr;
|
use std::net::SocketAddr;
|
||||||
|
use std::process::Command;
|
||||||
|
|
||||||
pub fn parse_args(matches: &ArgMatches) -> Result<WalletConfig, Box<error::Error>> {
|
pub fn parse_args(matches: &ArgMatches) -> Result<WalletConfig, Box<error::Error>> {
|
||||||
let network = if let Some(addr) = matches.value_of("network") {
|
let network = if let Some(addr) = matches.value_of("network") {
|
||||||
|
@ -35,6 +36,15 @@ pub fn parse_args(matches: &ArgMatches) -> Result<WalletConfig, Box<error::Error
|
||||||
matches.value_of("keypair").unwrap()
|
matches.value_of("keypair").unwrap()
|
||||||
} else {
|
} else {
|
||||||
path.extend(&[".config", "solana", "id.json"]);
|
path.extend(&[".config", "solana", "id.json"]);
|
||||||
|
if !path.exists() {
|
||||||
|
Command::new("cargo")
|
||||||
|
.arg("run")
|
||||||
|
.arg("--bin")
|
||||||
|
.arg("solana-keygen")
|
||||||
|
.status()
|
||||||
|
.expect("failed to execute process");
|
||||||
|
}
|
||||||
|
|
||||||
path.to_str().unwrap()
|
path.to_str().unwrap()
|
||||||
};
|
};
|
||||||
let id = read_keypair(id_path).or_else(|err| {
|
let id = read_keypair(id_path).or_else(|err| {
|
||||||
|
|
Loading…
Reference in New Issue