diff --git a/book/src/api-reference/cli.md b/book/src/api-reference/cli.md index 9c1ab1e7ef..68d5a12f61 100644 --- a/book/src/api-reference/cli.md +++ b/book/src/api-reference/cli.md @@ -352,15 +352,20 @@ FLAGS: -v, --verbose Show extra information header OPTIONS: - --ask-seed-phrase Recover a keypair using a seed phrase and optional passphrase [possible - values: keypair] - -C, --config Configuration file to use [default: - ~/.config/solana/cli/config.yml] - -u, --url JSON RPC URL for the solana cluster - -k, --keypair /path/to/id.json - --nonce-authority Specify nonce authority if different from account - --seed Seed for address generation; if specified, the resulting account will be at - a derived address of the NONCE_ACCOUNT pubkey + --ask-seed-phrase + Recover a keypair using a seed phrase and optional passphrase [possible values: keypair] + + -C, --config + Configuration file to use [default: ~/.config/solana/cli/config.yml] + + -u, --url JSON RPC URL for the solana cluster + -k, --keypair /path/to/id.json + --nonce-authority + Provide the nonce authority keypair to use when signing a nonced transaction + + --seed + Seed for address generation; if specified, the resulting account will be at a derived address of the + NONCE_ACCOUNT pubkey ARGS: Address of the nonce account @@ -813,21 +818,25 @@ FLAGS: -v, --verbose Show extra information header OPTIONS: - --ask-seed-phrase Recover a keypair using a seed phrase and optional passphrase [possible - values: keypair] - --blockhash Use the supplied blockhash - -C, --config Configuration file to use [default: - ~/.config/solana/cli/config.yml] - -u, --url JSON RPC URL for the solana cluster - -k, --keypair /path/to/id.json - --nonce Provide the nonce account to use when creating a nonced - transaction. Nonced transactions are useful when a transaction - requires a lengthy signing process. Learn more about nonced - transactions at https://docs.solana.com/offline-signing/durable-nonce - --nonce-authority Provide the nonce authority keypair to use when signing a nonced - transaction - --signer ... Provide a public-key/signature pair for the transaction - --stake-authority Public key of authorized staker (defaults to cli config pubkey) + --ask-seed-phrase + Recover a keypair using a seed phrase and optional passphrase [possible values: keypair] + + --blockhash Use the supplied blockhash + -C, --config + Configuration file to use [default: ~/.config/solana/cli/config.yml] + + -u, --url JSON RPC URL for the solana cluster + -k, --keypair /path/to/id.json + --nonce + Provide the nonce account to use when creating a nonced + transaction. Nonced transactions are useful when a transaction + requires a lengthy signing process. Learn more about nonced + transactions at https://docs.solana.com/offline-signing/durable-nonce + --nonce-authority + Provide the nonce authority keypair to use when signing a nonced transaction + + --signer ... Provide a public-key/signature pair for the transaction + --stake-authority Public key of authorized staker (defaults to cli config pubkey) ARGS: Stake account to be deactivated. @@ -850,21 +859,25 @@ FLAGS: -v, --verbose Show extra information header OPTIONS: - --ask-seed-phrase Recover a keypair using a seed phrase and optional passphrase [possible - values: keypair] - --blockhash Use the supplied blockhash - -C, --config Configuration file to use [default: - ~/.config/solana/cli/config.yml] - -u, --url JSON RPC URL for the solana cluster - -k, --keypair /path/to/id.json - --nonce Provide the nonce account to use when creating a nonced - transaction. Nonced transactions are useful when a transaction - requires a lengthy signing process. Learn more about nonced - transactions at https://docs.solana.com/offline-signing/durable-nonce - --nonce-authority Provide the nonce authority keypair to use when signing a nonced - transaction - --signer ... Provide a public-key/signature pair for the transaction - --stake-authority Public key of authorized staker (defaults to cli config pubkey) + --ask-seed-phrase + Recover a keypair using a seed phrase and optional passphrase [possible values: keypair] + + --blockhash Use the supplied blockhash + -C, --config + Configuration file to use [default: ~/.config/solana/cli/config.yml] + + -u, --url JSON RPC URL for the solana cluster + -k, --keypair /path/to/id.json + --nonce + Provide the nonce account to use when creating a nonced + transaction. Nonced transactions are useful when a transaction + requires a lengthy signing process. Learn more about nonced + transactions at https://docs.solana.com/offline-signing/durable-nonce + --nonce-authority + Provide the nonce authority keypair to use when signing a nonced transaction + + --signer ... Provide a public-key/signature pair for the transaction + --stake-authority Public key of authorized staker (defaults to cli config pubkey) ARGS: Stake account to delegate @@ -1023,13 +1036,17 @@ FLAGS: -v, --verbose Show extra information header OPTIONS: - --ask-seed-phrase Recover a keypair using a seed phrase and optional passphrase [possible - values: keypair] - -C, --config Configuration file to use [default: - ~/.config/solana/cli/config.yml] - -u, --url JSON RPC URL for the solana cluster - -k, --keypair /path/to/id.json - --nonce-authority Specify nonce authority if different from account + --ask-seed-phrase + Recover a keypair using a seed phrase and optional passphrase [possible values: keypair] + + -C, --config + Configuration file to use [default: ~/.config/solana/cli/config.yml] + + -u, --url JSON RPC URL for the solana cluster + -k, --keypair /path/to/id.json + --nonce-authority + Provide the nonce authority keypair to use when signing a nonced transaction + ARGS: Address of the nonce account @@ -1108,23 +1125,27 @@ FLAGS: -v, --verbose Show extra information header OPTIONS: - --ask-seed-phrase Recover a keypair using a seed phrase and optional passphrase [possible - values: keypair] - --blockhash Use the supplied blockhash - -C, --config Configuration file to use [default: - ~/.config/solana/cli/config.yml] - -u, --url JSON RPC URL for the solana cluster - -k, --keypair /path/to/id.json - --nonce Provide the nonce account to use when creating a nonced - transaction. Nonced transactions are useful when a transaction - requires a lengthy signing process. Learn more about nonced - transactions at https://docs.solana.com/offline-signing/durable-nonce - --nonce-authority Provide the nonce authority keypair to use when signing a nonced - transaction - --signer ... Provide a public-key/signature pair for the transaction - --after A timestamp after which transaction will execute - --require-timestamp-from Require timestamp from this third party - --require-signature-from ... Any third party signatures required to unlock the lamports + --ask-seed-phrase + Recover a keypair using a seed phrase and optional passphrase [possible values: keypair] + + --blockhash Use the supplied blockhash + -C, --config + Configuration file to use [default: ~/.config/solana/cli/config.yml] + + -u, --url JSON RPC URL for the solana cluster + -k, --keypair /path/to/id.json + --nonce + Provide the nonce account to use when creating a nonced + transaction. Nonced transactions are useful when a transaction + requires a lengthy signing process. Learn more about nonced + transactions at https://docs.solana.com/offline-signing/durable-nonce + --nonce-authority + Provide the nonce authority keypair to use when signing a nonced transaction + + --signer ... Provide a public-key/signature pair for the transaction + --after A timestamp after which transaction will execute + --require-timestamp-from Require timestamp from this third party + --require-signature-from ... Any third party signatures required to unlock the lamports ARGS: The pubkey of recipient @@ -1316,21 +1337,25 @@ FLAGS: -v, --verbose Show extra information header OPTIONS: - --ask-seed-phrase Recover a keypair using a seed phrase and optional passphrase [possible - values: keypair] - --blockhash Use the supplied blockhash - -C, --config Configuration file to use [default: - ~/.config/solana/cli/config.yml] - -u, --url JSON RPC URL for the solana cluster - -k, --keypair /path/to/id.json - --nonce Provide the nonce account to use when creating a nonced - transaction. Nonced transactions are useful when a transaction - requires a lengthy signing process. Learn more about nonced - transactions at https://docs.solana.com/offline-signing/durable-nonce - --nonce-authority Provide the nonce authority keypair to use when signing a nonced - transaction - --signer ... Provide a public-key/signature pair for the transaction - --stake-authority Public key of authorized staker (defaults to cli config pubkey) + --ask-seed-phrase + Recover a keypair using a seed phrase and optional passphrase [possible values: keypair] + + --blockhash Use the supplied blockhash + -C, --config + Configuration file to use [default: ~/.config/solana/cli/config.yml] + + -u, --url JSON RPC URL for the solana cluster + -k, --keypair /path/to/id.json + --nonce + Provide the nonce account to use when creating a nonced + transaction. Nonced transactions are useful when a transaction + requires a lengthy signing process. Learn more about nonced + transactions at https://docs.solana.com/offline-signing/durable-nonce + --nonce-authority + Provide the nonce authority keypair to use when signing a nonced transaction + + --signer ... Provide a public-key/signature pair for the transaction + --stake-authority Public key of authorized staker (defaults to cli config pubkey) ARGS: Stake account in which to set the authorized staker @@ -1354,21 +1379,25 @@ FLAGS: -v, --verbose Show extra information header OPTIONS: - --ask-seed-phrase Recover a keypair using a seed phrase and optional passphrase [possible - values: keypair] - --blockhash Use the supplied blockhash - -C, --config Configuration file to use [default: - ~/.config/solana/cli/config.yml] - -u, --url JSON RPC URL for the solana cluster - -k, --keypair /path/to/id.json - --nonce Provide the nonce account to use when creating a nonced - transaction. Nonced transactions are useful when a transaction - requires a lengthy signing process. Learn more about nonced - transactions at https://docs.solana.com/offline-signing/durable-nonce - --nonce-authority Provide the nonce authority keypair to use when signing a nonced - transaction - --signer ... Provide a public-key/signature pair for the transaction - --withdraw-authority Public key of authorized withdrawer (defaults to cli config pubkey) + --ask-seed-phrase + Recover a keypair using a seed phrase and optional passphrase [possible values: keypair] + + --blockhash Use the supplied blockhash + -C, --config + Configuration file to use [default: ~/.config/solana/cli/config.yml] + + -u, --url JSON RPC URL for the solana cluster + -k, --keypair /path/to/id.json + --nonce + Provide the nonce account to use when creating a nonced + transaction. Nonced transactions are useful when a transaction + requires a lengthy signing process. Learn more about nonced + transactions at https://docs.solana.com/offline-signing/durable-nonce + --nonce-authority + Provide the nonce authority keypair to use when signing a nonced transaction + + --signer ... Provide a public-key/signature pair for the transaction + --withdraw-authority Public key of authorized withdrawer (defaults to cli config pubkey) ARGS: Stake account in which to set the authorized withdrawer @@ -1692,13 +1721,17 @@ FLAGS: -v, --verbose Show extra information header OPTIONS: - --ask-seed-phrase Recover a keypair using a seed phrase and optional passphrase [possible - values: keypair] - -C, --config Configuration file to use [default: - ~/.config/solana/cli/config.yml] - -u, --url JSON RPC URL for the solana cluster - -k, --keypair /path/to/id.json - --nonce-authority Specify nonce authority if different from account + --ask-seed-phrase + Recover a keypair using a seed phrase and optional passphrase [possible values: keypair] + + -C, --config + Configuration file to use [default: ~/.config/solana/cli/config.yml] + + -u, --url JSON RPC URL for the solana cluster + -k, --keypair /path/to/id.json + --nonce-authority + Provide the nonce authority keypair to use when signing a nonced transaction + ARGS: Nonce account from to withdraw from @@ -1723,13 +1756,15 @@ FLAGS: -v, --verbose Show extra information header OPTIONS: - --ask-seed-phrase Recover a keypair using a seed phrase and optional passphrase [possible - values: keypair] - -C, --config Configuration file to use [default: - ~/.config/solana/cli/config.yml] - -u, --url JSON RPC URL for the solana cluster - -k, --keypair /path/to/id.json - --withdraw-authority Public key of authorized withdrawer (defaults to cli config pubkey) + --ask-seed-phrase + Recover a keypair using a seed phrase and optional passphrase [possible values: keypair] + + -C, --config + Configuration file to use [default: ~/.config/solana/cli/config.yml] + + -u, --url JSON RPC URL for the solana cluster + -k, --keypair /path/to/id.json + --withdraw-authority Public key of authorized withdrawer (defaults to cli config pubkey) ARGS: Stake account from which to withdraw diff --git a/cli/src/cli.rs b/cli/src/cli.rs index 39584e2430..e8ed6360bc 100644 --- a/cli/src/cli.rs +++ b/cli/src/cli.rs @@ -1,7 +1,7 @@ use crate::{ cluster_query::*, display::{println_name_value, println_signers}, - nonce::*, + nonce::{self, *}, stake::*, storage::*, validator_info::*, @@ -146,6 +146,10 @@ impl PartialEq for SigningAuthority { } } +pub fn nonce_authority_arg<'a, 'b>() -> Arg<'a, 'b> { + nonce::nonce_authority_arg().requires(NONCE_ARG.name) +} + #[derive(Default, Debug, PartialEq)] pub struct PayCommand { pub lamports: u64, @@ -1985,23 +1989,8 @@ pub fn app<'ab, 'v>(name: &str, about: &'ab str, version: &'v str) -> App<'ab, ' .takes_value(false) .help("Sign the transaction offline"), ) - .arg( - Arg::with_name(NONCE_ARG.name) - .long(NONCE_ARG.long) - .takes_value(true) - .value_name("PUBKEY") - .requires("blockhash") - .validator(is_pubkey_or_keypair) - .help(NONCE_ARG.help), - ) - .arg( - Arg::with_name(NONCE_AUTHORITY_ARG.name) - .long(NONCE_AUTHORITY_ARG.long) - .takes_value(true) - .requires(NONCE_ARG.name) - .validator(is_pubkey_or_keypair_or_ask_keyword) - .help(NONCE_AUTHORITY_ARG.help), - ) + .arg(nonce_arg()) + .arg(nonce_authority_arg()) .arg( Arg::with_name("signer") .long("signer") diff --git a/cli/src/nonce.rs b/cli/src/nonce.rs index 9038b886b0..8364e73c71 100644 --- a/cli/src/nonce.rs +++ b/cli/src/nonce.rs @@ -49,13 +49,23 @@ pub trait NonceSubCommands { fn nonce_subcommands(self) -> Self; } -fn nonce_authority_arg<'a, 'b>() -> Arg<'a, 'b> { - Arg::with_name("nonce_authority") - .long("nonce-authority") +pub fn nonce_arg<'a, 'b>() -> Arg<'a, 'b> { + Arg::with_name(NONCE_ARG.name) + .long(NONCE_ARG.long) .takes_value(true) - .value_name("KEYPAIR") + .value_name("PUBKEY") + .requires("blockhash") + .validator(is_pubkey) + .help(NONCE_ARG.help) +} + +pub fn nonce_authority_arg<'a, 'b>() -> Arg<'a, 'b> { + Arg::with_name(NONCE_AUTHORITY_ARG.name) + .long(NONCE_AUTHORITY_ARG.long) + .takes_value(true) + .value_name("KEYPAIR or PUBKEY") .validator(is_pubkey_or_keypair_or_ask_keyword) - .help("Specify nonce authority if different from account") + .help(NONCE_AUTHORITY_ARG.help) } impl NonceSubCommands for App<'_, '_> { @@ -120,8 +130,8 @@ impl NonceSubCommands for App<'_, '_> { .help("Specify unit to use for request"), ) .arg( - Arg::with_name("nonce_authority") - .long("nonce-authority") + Arg::with_name(NONCE_AUTHORITY_ARG.name) + .long(NONCE_AUTHORITY_ARG.long) .takes_value(true) .value_name("BASE58_PUBKEY") .validator(is_pubkey_or_keypair) @@ -246,7 +256,7 @@ pub fn parse_nonce_create_account(matches: &ArgMatches<'_>) -> Result() -> Arg<'a, 'b> { Arg::with_name(STAKE_AUTHORITY_ARG.name) .long(STAKE_AUTHORITY_ARG.long) .takes_value(true) - .value_name("KEYPAIR") + .value_name("KEYPAIR of PUBKEY") .validator(is_pubkey_or_keypair_or_ask_keyword) .help(STAKE_AUTHORITY_ARG.help) } @@ -56,7 +56,7 @@ fn withdraw_authority_arg<'a, 'b>() -> Arg<'a, 'b> { Arg::with_name(WITHDRAW_AUTHORITY_ARG.name) .long(WITHDRAW_AUTHORITY_ARG.long) .takes_value(true) - .value_name("KEYPAIR") + .value_name("KEYPAIR or PUBKEY") .validator(is_pubkey_or_keypair_or_ask_keyword) .help(WITHDRAW_AUTHORITY_ARG.help) } @@ -195,23 +195,8 @@ impl StakeSubCommands for App<'_, '_> { .validator(is_hash) .help("Use the supplied blockhash"), ) - .arg( - Arg::with_name(NONCE_ARG.name) - .long(NONCE_ARG.long) - .takes_value(true) - .value_name("PUBKEY") - .requires("blockhash") - .validator(is_pubkey) - .help(NONCE_ARG.help) - ) - .arg( - Arg::with_name(NONCE_AUTHORITY_ARG.name) - .long(NONCE_AUTHORITY_ARG.long) - .takes_value(true) - .requires(NONCE_ARG.name) - .validator(is_keypair_or_ask_keyword) - .help(NONCE_AUTHORITY_ARG.help) - ), + .arg(nonce_arg()) + .arg(nonce_authority_arg()) ) .subcommand( SubCommand::with_name("stake-authorize-staker") @@ -258,23 +243,8 @@ impl StakeSubCommands for App<'_, '_> { .validator(is_hash) .help("Use the supplied blockhash"), ) - .arg( - Arg::with_name(NONCE_ARG.name) - .long(NONCE_ARG.long) - .takes_value(true) - .value_name("PUBKEY") - .requires("blockhash") - .validator(is_pubkey) - .help(NONCE_ARG.help) - ) - .arg( - Arg::with_name(NONCE_AUTHORITY_ARG.name) - .long(NONCE_AUTHORITY_ARG.long) - .takes_value(true) - .requires(NONCE_ARG.name) - .validator(is_keypair_or_ask_keyword) - .help(NONCE_AUTHORITY_ARG.help) - ), + .arg(nonce_arg()) + .arg(nonce_authority_arg()) ) .subcommand( SubCommand::with_name("stake-authorize-withdrawer") @@ -321,23 +291,8 @@ impl StakeSubCommands for App<'_, '_> { .validator(is_hash) .help("Use the supplied blockhash"), ) - .arg( - Arg::with_name(NONCE_ARG.name) - .long(NONCE_ARG.long) - .takes_value(true) - .value_name("PUBKEY") - .requires("blockhash") - .validator(is_pubkey) - .help(NONCE_ARG.help) - ) - .arg( - Arg::with_name(NONCE_AUTHORITY_ARG.name) - .long(NONCE_AUTHORITY_ARG.long) - .takes_value(true) - .requires(NONCE_ARG.name) - .validator(is_keypair_or_ask_keyword) - .help(NONCE_AUTHORITY_ARG.help) - ), + .arg(nonce_arg()) + .arg(nonce_authority_arg()) ) .subcommand( SubCommand::with_name("deactivate-stake") @@ -374,23 +329,8 @@ impl StakeSubCommands for App<'_, '_> { .validator(is_hash) .help("Use the supplied blockhash"), ) - .arg( - Arg::with_name(NONCE_ARG.name) - .long(NONCE_ARG.long) - .takes_value(true) - .value_name("PUBKEY") - .requires("blockhash") - .validator(is_pubkey) - .help(NONCE_ARG.help) - ) - .arg( - Arg::with_name(NONCE_AUTHORITY_ARG.name) - .long(NONCE_AUTHORITY_ARG.long) - .takes_value(true) - .requires(NONCE_ARG.name) - .validator(is_keypair_or_ask_keyword) - .help(NONCE_AUTHORITY_ARG.help) - ), + .arg(nonce_arg()) + .arg(nonce_authority_arg()) ) .subcommand( SubCommand::with_name("withdraw-stake")