pub fn keypair_from_path(
    matches: &ArgMatches,
    path: &str,
    keypair_name: &str,
    confirm_pubkey: bool,
) -> Result<Keypair, Box<dyn error::Error>> {
    let SignerSource {
        kind,
        derivation_path,
        legacy,
    } = parse_signer_source(path)?;
    match kind {
        SignerSourceKind::Prompt => {
            let skip_validation = matches.is_present(SKIP_SEED_PHRASE_VALIDATION_ARG.name);
            Ok(keypair_from_seed_phrase(
                keypair_name,
                skip_validation,
                confirm_pubkey,
                derivation_path,
                legacy,
            )?)
        }
        SignerSourceKind::Filepath(path) => match read_keypair_file(&path) {
            Err(e) => Err(std::io::Error::new(
                std::io::ErrorKind::Other,
                format!(
                    "could not read keypair file \"{}\". \
                    Run \"solana-keygen new\" to create a keypair file: {}",
                    path, e
                ),
            )
            .into()),
            Ok(file) => Ok(file),
        },
        SignerSourceKind::Stdin => {
            let mut stdin = std::io::stdin();
            Ok(read_keypair(&mut stdin)?)
        }
        _ => Err(std::io::Error::new(
            std::io::ErrorKind::Other,
            format!(
                "signer of type `{:?}` does not support Keypair output",
                kind
            ),
        )
        .into()),
    }
}
/// Loads a [Keypair] from one of several possible sources.
///
/// The `path` is not strictly a file system path, but is interpreted as various
/// types of _signing source_, depending on its format, one of which is a path
/// to a keypair file. Some sources may require user interaction in the course
/// of calling this function.
///
/// This is the same as [`signer_from_path`] except that it only supports
/// signing sources that can result in a [Keypair]: prompt for seed phrase,
/// keypair file, and stdin.
///
/// If `confirm_pubkey` is `true` then after deriving the pubkey, the user will
/// be prompted to confirm that the pubkey is as expected.
///
/// See [`signer_from_path`] for full documentation of how this function
/// interprets its arguments.
///
/// # Examples
///
/// ```no_run
/// use clap::{App, Arg, value_t_or_exit};
/// use solana_clap_utils::keypair::keypair_from_path;
///
/// let clap_app = App::new("my-program")
///     // The argument we'll parse as a signer "path"
///     .arg(Arg::with_name("keypair")
///         .required(true)
///         .help("The default signer"));
///
/// let clap_matches = clap_app.get_matches();
/// let keypair_str = value_t_or_exit!(clap_matches, "keypair", String);
///
/// let signer = keypair_from_path(
///     &clap_matches,
///     &keypair_str,
///     "keypair",
///     false,
/// )?;
/// # Ok::<(), Box<dyn std::error::Error>>(())
/// ```
Loads a [Keypair] from one of several possible sources.
The `path` is not strictly a file system path, but is interpreted as various
types of _signing source_, depending on its format, one of which is a path
to a keypair file. Some sources may require user interaction in the course
of calling this function.

This is the same as [`signer_from_path`] except that it only supports
signing sources that can result in a [Keypair]: prompt for seed phrase,
keypair file, and stdin.

If `confirm_pubkey` is `true` then after deriving the pubkey, the user will
be prompted to confirm that the pubkey is as expected.

See [`signer_from_path`] for full documentation of how this function
interprets its arguments.
Loads a [ Keypair ] from one of several possible sources . The ` path ` is not strictly a file system path but is interpreted as various types of _signing source_ depending on its format one of which is a path to a keypair file . Some sources may require user interaction in the course of calling this function . This is the same as [ ` signer_from_path ` ] except that it only supports signing sources that can result in a [ Keypair ] : prompt for seed phrase keypair file and stdin . If ` confirm_pubkey ` is ` true ` then after deriving the pubkey the user will be prompted to confirm that the pubkey is as expected . See [ ` signer_from_path ` ] for full documentation of how this function interprets its arguments .
pub fn keypair_from_path(
    matches: &ArgMatches,
    path: &str,
    keypair_name: &str,
    confirm_pubkey: bool,
) -> Result<Keypair, Box<dyn error::Error>> {
    let SignerSource {
        kind,
        derivation_path,
        legacy,
    } = parse_signer_source(path)?;
    match kind {
        SignerSourceKind::Prompt => {
            let skip_validation = matches.is_present(SKIP_SEED_PHRASE_VALIDATION_ARG.name);
            Ok(keypair_from_seed_phrase(
                keypair_name,
                skip_validation,
                confirm_pubkey,
                derivation_path,
                legacy,
            )?)
        }
        SignerSourceKind::Filepath(path) => match read_keypair_file(&path) {
            Err(e) => Err(std::io::Error::new(
                std::io::ErrorKind::Other,
                format!(
                    "could not read keypair file \"{}\". \
                    Run \"solana-keygen new\" to create a keypair file: {}",
                    path, e
                ),
            )
            .into()),
            Ok(file) => Ok(file),
        },
        SignerSourceKind::Stdin => {
            let mut stdin = std::io::stdin();
            Ok(read_keypair(&mut stdin)?)
        }
        _ => Err(std::io::Error::new(
            std::io::ErrorKind::Other,
            format!(
                "signer of type `{:?}` does not support Keypair output",
                kind
            ),
        )
        .into()),
    }
}
pub fn keypair_from_path ( matches : & ArgMatches , path : & str , keypair_name : & str , confirm_pubkey : bool , ) -> Result < Keypair , Box < dyn error :: Error > > { let SignerSource { kind , derivation_path , legacy , } = parse_signer_source ( path ) ? ; match kind { SignerSourceKind :: Prompt => { let skip_validation = matches . is_present ( SKIP_SEED_PHRASE_VALIDATION_ARG . name ) ; Ok ( keypair_from_seed_phrase ( keypair_name , skip_validation , confirm_pubkey , derivation_path , legacy , ) ? ) } SignerSourceKind :: Filepath ( path ) => match read_keypair_file ( & path ) { Err ( e ) => Err ( std :: io :: Error :: new ( std :: io :: ErrorKind :: Other , format ! ( " \" \" \
 \" \" " path e ) , ) . into ( ) ) , Ok ( file ) => Ok ( file ) , } , SignerSourceKind :: Stdin => { let mut stdin = std :: io :: stdin ( ) ; Ok ( read_keypair ( & mut stdin ) ? ) } _ => Err ( std :: io :: Error :: new ( std :: io :: ErrorKind :: Other , format ! ( " " kind ) , ) . into ( ) ) , } }
Loads a [Keypair] from one of several possible sources.
Loads a [ Keypair ] from one of several possible sources .
matches
&ArgMatches
path
&str
keypair_name
&str
confirm_pubkey
bool
examples
```no_run
use clap::{App, Arg, value_t_or_exit};
use solana_clap_utils::keypair::keypair_from_path.

let clap_app = App::new("my-program")
The argument we'll parse as a signer "path"
.arg(Arg::with_name("keypair")
.required(true)
.help("The default signer")).

let clap_matches = clap_app.get_matches();
let keypair_str = value_t_or_exit!(clap_matches, "keypair", String).

let signer = keypair_from_path(
&clap_matches,
&keypair_str,
"keypair",
false,
)?.
` ` ` no_run use clap :: { App Arg value_t_or_exit } ; use solana_clap_utils :: keypair :: keypair_from_path . let clap_app = App :: new ( " my - program " ) The argument we ' ll parse as a signer " path " . arg ( Arg :: with_name ( " keypair " ) . required ( true ) . help ( " The default signer " )) . let clap_matches = clap_app . get_matches () ; let keypair_str = value_t_or_exit! ( clap_matches " keypair " String ) . let signer = keypair_from_path ( &clap_matches &keypair_str " keypair " false ) ? .
ok::<(), box<dyn std::error::error>>(())
None