From e9a2dd0bc14d40da1a709b3f9810f53ab81fc7fe Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Sat, 5 Sep 2020 16:52:38 +0000 Subject: [PATCH] Add --show-transactions flag to transaction-history command (#12071) (cherry picked from commit 2332dd774f46788cc01d722d9bb392e2ce6ee509) Co-authored-by: Michael Vines --- cli/src/cli.rs | 12 +++++++++++- cli/src/cluster_query.rs | 36 +++++++++++++++++++++++++++++++++++- 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/cli/src/cli.rs b/cli/src/cli.rs index 890ed768f4..3f2be908a4 100644 --- a/cli/src/cli.rs +++ b/cli/src/cli.rs @@ -234,6 +234,7 @@ pub enum CliCommand { before: Option, until: Option, limit: usize, + show_transactions: bool, }, // Nonce commands AuthorizeNonceAccount { @@ -1907,7 +1908,16 @@ pub fn process_command(config: &CliConfig) -> ProcessResult { before, until, limit, - } => process_transaction_history(&rpc_client, config, address, *before, *until, *limit), + show_transactions, + } => process_transaction_history( + &rpc_client, + config, + address, + *before, + *until, + *limit, + *show_transactions, + ), // Nonce Commands diff --git a/cli/src/cluster_query.rs b/cli/src/cluster_query.rs index e22d7a2bd4..6ed6afd363 100644 --- a/cli/src/cluster_query.rs +++ b/cli/src/cluster_query.rs @@ -1,7 +1,9 @@ use crate::{ cli::{CliCommand, CliCommandInfo, CliConfig, CliError, ProcessResult}, cli_output::*, - display::{format_labeled_address, new_spinner_progress_bar, println_name_value}, + display::{ + format_labeled_address, new_spinner_progress_bar, println_name_value, println_transaction, + }, spend_utils::{resolve_spend_tx_and_check_account_balance, SpendAmount}, }; use clap::{value_t, value_t_or_exit, App, AppSettings, Arg, ArgMatches, SubCommand}; @@ -33,6 +35,7 @@ use solana_sdk::{ }, transaction::Transaction, }; +use solana_transaction_status::UiTransactionEncoding; use std::{ collections::{BTreeMap, HashMap, VecDeque}, net::SocketAddr, @@ -283,6 +286,12 @@ impl ClusterQuerySubCommands for App<'_, '_> { .takes_value(true) .help("Start with the first signature older than this one"), ) + .arg( + Arg::with_name("show_transactions") + .long("show-transactions") + .takes_value(false) + .help("Display the full transactions"), + ) ) } } @@ -454,6 +463,7 @@ pub fn parse_transaction_history( None => None, }; let limit = value_t_or_exit!(matches, "limit", usize); + let show_transactions = matches.is_present("show_transactions"); Ok(CliCommandInfo { command: CliCommand::TransactionHistory { @@ -461,6 +471,7 @@ pub fn parse_transaction_history( before, until, limit, + show_transactions, }, signers: vec![], }) @@ -1323,6 +1334,7 @@ pub fn process_transaction_history( before: Option, until: Option, limit: usize, + show_transactions: bool, ) -> ProcessResult { let results = rpc_client.get_confirmed_signatures_for_address2_with_config( address, @@ -1350,6 +1362,28 @@ pub fn process_transaction_history( } else { println!("{}", result.signature); } + + if show_transactions { + if let Ok(signature) = result.signature.parse::() { + match rpc_client + .get_confirmed_transaction(&signature, UiTransactionEncoding::Base64) + { + Ok(confirmed_transaction) => { + println_transaction( + &confirmed_transaction + .transaction + .transaction + .decode() + .expect("Successful decode"), + &confirmed_transaction.transaction.meta, + " ", + ); + } + Err(err) => println!(" Unable to get confirmed transaction details: {}", err), + } + } + println!(); + } } Ok(transactions_found) }