diff --git a/book/src/wallet.md b/book/src/wallet.md index 448be47232..7f734788b6 100644 --- a/book/src/wallet.md +++ b/book/src/wallet.md @@ -284,6 +284,18 @@ ARGS: /path/to/program.o ``` +```manpage +solana-wallet-fees +Display current cluster fees + +USAGE: + solana-wallet fees + +FLAGS: + -h, --help Prints help information + -V, --version Prints version information +``` + ```manpage solana-wallet-get-transaction-count Get current transaction count diff --git a/wallet/src/wallet.rs b/wallet/src/wallet.rs index fed7331bf2..cf5509d031 100644 --- a/wallet/src/wallet.rs +++ b/wallet/src/wallet.rs @@ -42,6 +42,7 @@ const USERDATA_CHUNK_SIZE: usize = 229; // Keep program chunks under PACKET_DATA #[allow(clippy::large_enum_variant)] pub enum WalletCommand { Address, + Fees, Airdrop(u64), Balance(Pubkey), Cancel(Pubkey), @@ -164,6 +165,7 @@ pub fn parse_command( ) -> Result> { let response = match matches.subcommand() { ("address", Some(_address_matches)) => Ok(WalletCommand::Address), + ("fees", Some(_fees_matches)) => Ok(WalletCommand::Fees), ("airdrop", Some(airdrop_matches)) => { let lamports = airdrop_matches.value_of("lamports").unwrap().parse()?; Ok(WalletCommand::Airdrop(lamports)) @@ -375,6 +377,14 @@ pub fn parse_command( type ProcessResult = Result>; +fn process_fees(rpc_client: &RpcClient) -> ProcessResult { + let (recent_blockhash, fee_calculator) = rpc_client.get_recent_blockhash()?; + + Ok(format!( + "blockhash: {}\nlamports per signature: {}", + recent_blockhash, fee_calculator.lamports_per_signature + )) +} fn process_airdrop( rpc_client: &RpcClient, config: &WalletConfig, @@ -988,6 +998,8 @@ pub fn process_command(config: &WalletConfig) -> ProcessResult { // Get address of this client WalletCommand::Address => unreachable!(), + WalletCommand::Fees => process_fees(&rpc_client), + // Request an airdrop from Solana Drone; WalletCommand::Airdrop(lamports) => { process_airdrop(&rpc_client, config, drone_addr, *lamports) @@ -1258,6 +1270,7 @@ pub fn app<'ab, 'v>(name: &str, about: &'ab str, version: &'v str) -> App<'ab, ' .version(version) .setting(AppSettings::SubcommandRequiredElseHelp) .subcommand(SubCommand::with_name("address").about("Get your public key")) + .subcommand(SubCommand::with_name("fees").about("Display current cluster fees")) .subcommand( SubCommand::with_name("airdrop") .about("Request a batch of lamports") diff --git a/wallet/wallet-help.sh b/wallet/wallet-help.sh index a95c53ed89..40f357da9f 100755 --- a/wallet/wallet-help.sh +++ b/wallet/wallet-help.sh @@ -11,7 +11,7 @@ solana-wallet --help echo "\`\`\`" echo "" -commands=(address airdrop balance cancel confirm deploy get-transaction-count pay send-signature send-timestamp) +commands=(address airdrop balance cancel confirm deploy fees get-transaction-count pay send-signature send-timestamp) for x in "${commands[@]}"; do echo "\`\`\`manpage"