Add --show-transactions flag to transaction-history command (#12071)
(cherry picked from commit 2332dd774f
)
Co-authored-by: Michael Vines <mvines@gmail.com>
This commit is contained in:
@ -234,6 +234,7 @@ pub enum CliCommand {
|
|||||||
before: Option<Signature>,
|
before: Option<Signature>,
|
||||||
until: Option<Signature>,
|
until: Option<Signature>,
|
||||||
limit: usize,
|
limit: usize,
|
||||||
|
show_transactions: bool,
|
||||||
},
|
},
|
||||||
// Nonce commands
|
// Nonce commands
|
||||||
AuthorizeNonceAccount {
|
AuthorizeNonceAccount {
|
||||||
@ -1907,7 +1908,16 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
|
|||||||
before,
|
before,
|
||||||
until,
|
until,
|
||||||
limit,
|
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
|
// Nonce Commands
|
||||||
|
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
cli::{CliCommand, CliCommandInfo, CliConfig, CliError, ProcessResult},
|
cli::{CliCommand, CliCommandInfo, CliConfig, CliError, ProcessResult},
|
||||||
cli_output::*,
|
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},
|
spend_utils::{resolve_spend_tx_and_check_account_balance, SpendAmount},
|
||||||
};
|
};
|
||||||
use clap::{value_t, value_t_or_exit, App, AppSettings, Arg, ArgMatches, SubCommand};
|
use clap::{value_t, value_t_or_exit, App, AppSettings, Arg, ArgMatches, SubCommand};
|
||||||
@ -33,6 +35,7 @@ use solana_sdk::{
|
|||||||
},
|
},
|
||||||
transaction::Transaction,
|
transaction::Transaction,
|
||||||
};
|
};
|
||||||
|
use solana_transaction_status::UiTransactionEncoding;
|
||||||
use std::{
|
use std::{
|
||||||
collections::{BTreeMap, HashMap, VecDeque},
|
collections::{BTreeMap, HashMap, VecDeque},
|
||||||
net::SocketAddr,
|
net::SocketAddr,
|
||||||
@ -283,6 +286,12 @@ impl ClusterQuerySubCommands for App<'_, '_> {
|
|||||||
.takes_value(true)
|
.takes_value(true)
|
||||||
.help("Start with the first signature older than this one"),
|
.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,
|
None => None,
|
||||||
};
|
};
|
||||||
let limit = value_t_or_exit!(matches, "limit", usize);
|
let limit = value_t_or_exit!(matches, "limit", usize);
|
||||||
|
let show_transactions = matches.is_present("show_transactions");
|
||||||
|
|
||||||
Ok(CliCommandInfo {
|
Ok(CliCommandInfo {
|
||||||
command: CliCommand::TransactionHistory {
|
command: CliCommand::TransactionHistory {
|
||||||
@ -461,6 +471,7 @@ pub fn parse_transaction_history(
|
|||||||
before,
|
before,
|
||||||
until,
|
until,
|
||||||
limit,
|
limit,
|
||||||
|
show_transactions,
|
||||||
},
|
},
|
||||||
signers: vec![],
|
signers: vec![],
|
||||||
})
|
})
|
||||||
@ -1323,6 +1334,7 @@ pub fn process_transaction_history(
|
|||||||
before: Option<Signature>,
|
before: Option<Signature>,
|
||||||
until: Option<Signature>,
|
until: Option<Signature>,
|
||||||
limit: usize,
|
limit: usize,
|
||||||
|
show_transactions: bool,
|
||||||
) -> ProcessResult {
|
) -> ProcessResult {
|
||||||
let results = rpc_client.get_confirmed_signatures_for_address2_with_config(
|
let results = rpc_client.get_confirmed_signatures_for_address2_with_config(
|
||||||
address,
|
address,
|
||||||
@ -1350,6 +1362,28 @@ pub fn process_transaction_history(
|
|||||||
} else {
|
} else {
|
||||||
println!("{}", result.signature);
|
println!("{}", result.signature);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if show_transactions {
|
||||||
|
if let Ok(signature) = result.signature.parse::<Signature>() {
|
||||||
|
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)
|
Ok(transactions_found)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user