Add decode-transaction
This commit is contained in:
@ -51,6 +51,7 @@ use solana_stake_program::{
|
|||||||
stake_state::{Lockup, StakeAuthorize},
|
stake_state::{Lockup, StakeAuthorize},
|
||||||
};
|
};
|
||||||
use solana_storage_program::storage_instruction::StorageAccountType;
|
use solana_storage_program::storage_instruction::StorageAccountType;
|
||||||
|
use solana_transaction_status::{EncodedTransaction, TransactionEncoding};
|
||||||
use solana_vote_program::vote_state::VoteAuthorize;
|
use solana_vote_program::vote_state::VoteAuthorize;
|
||||||
use std::{
|
use std::{
|
||||||
error,
|
error,
|
||||||
@ -399,6 +400,7 @@ pub enum CliCommand {
|
|||||||
},
|
},
|
||||||
Cancel(Pubkey),
|
Cancel(Pubkey),
|
||||||
Confirm(Signature),
|
Confirm(Signature),
|
||||||
|
DecodeTransaction(Transaction),
|
||||||
Pay(PayCommand),
|
Pay(PayCommand),
|
||||||
ResolveSigner(Option<String>),
|
ResolveSigner(Option<String>),
|
||||||
ShowAccount {
|
ShowAccount {
|
||||||
@ -798,11 +800,23 @@ pub fn parse_command(
|
|||||||
command: CliCommand::Confirm(signature),
|
command: CliCommand::Confirm(signature),
|
||||||
signers: vec![],
|
signers: vec![],
|
||||||
}),
|
}),
|
||||||
_ => {
|
_ => Err(CliError::BadParameter("Invalid signature".to_string())),
|
||||||
eprintln!("{}", matches.usage());
|
|
||||||
Err(CliError::BadParameter("Invalid signature".to_string()))
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
("decode-transaction", Some(matches)) => {
|
||||||
|
let encoded_transaction = EncodedTransaction::Binary(
|
||||||
|
matches.value_of("base85_transaction").unwrap().to_string(),
|
||||||
|
);
|
||||||
|
if let Some(transaction) = encoded_transaction.decode() {
|
||||||
|
Ok(CliCommandInfo {
|
||||||
|
command: CliCommand::DecodeTransaction(transaction),
|
||||||
|
signers: vec![],
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
Err(CliError::BadParameter(
|
||||||
|
"Unable to decode transaction".to_string(),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
}
|
||||||
("pay", Some(matches)) => {
|
("pay", Some(matches)) => {
|
||||||
let lamports = lamports_of_sol(matches, "amount").unwrap();
|
let lamports = lamports_of_sol(matches, "amount").unwrap();
|
||||||
let to = pubkey_of_signer(matches, "to", wallet_manager)?.unwrap();
|
let to = pubkey_of_signer(matches, "to", wallet_manager)?.unwrap();
|
||||||
@ -1178,10 +1192,9 @@ fn process_confirm(
|
|||||||
Ok(status) => {
|
Ok(status) => {
|
||||||
if let Some(transaction_status) = status {
|
if let Some(transaction_status) = status {
|
||||||
if config.verbose {
|
if config.verbose {
|
||||||
match rpc_client.get_confirmed_transaction(
|
match rpc_client
|
||||||
signature,
|
.get_confirmed_transaction(signature, TransactionEncoding::Binary)
|
||||||
solana_transaction_status::TransactionEncoding::Binary,
|
{
|
||||||
) {
|
|
||||||
Ok(confirmed_transaction) => {
|
Ok(confirmed_transaction) => {
|
||||||
println!(
|
println!(
|
||||||
"\nTransaction executed in slot {}:",
|
"\nTransaction executed in slot {}:",
|
||||||
@ -1216,6 +1229,11 @@ fn process_confirm(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn process_decode_transaction(transaction: &Transaction) -> ProcessResult {
|
||||||
|
crate::display::println_transaction(transaction, &None, "");
|
||||||
|
Ok("".to_string())
|
||||||
|
}
|
||||||
|
|
||||||
fn process_show_account(
|
fn process_show_account(
|
||||||
rpc_client: &RpcClient,
|
rpc_client: &RpcClient,
|
||||||
config: &CliConfig,
|
config: &CliConfig,
|
||||||
@ -2099,6 +2117,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
|
|||||||
CliCommand::Cancel(pubkey) => process_cancel(&rpc_client, config, &pubkey),
|
CliCommand::Cancel(pubkey) => process_cancel(&rpc_client, config, &pubkey),
|
||||||
// Confirm the last client transaction by signature
|
// Confirm the last client transaction by signature
|
||||||
CliCommand::Confirm(signature) => process_confirm(&rpc_client, config, signature),
|
CliCommand::Confirm(signature) => process_confirm(&rpc_client, config, signature),
|
||||||
|
CliCommand::DecodeTransaction(transaction) => process_decode_transaction(transaction),
|
||||||
// If client has positive balance, pay lamports to another address
|
// If client has positive balance, pay lamports to another address
|
||||||
CliCommand::Pay(PayCommand {
|
CliCommand::Pay(PayCommand {
|
||||||
lamports,
|
lamports,
|
||||||
@ -2376,6 +2395,18 @@ pub fn app<'ab, 'v>(name: &str, about: &'ab str, version: &'v str) -> App<'ab, '
|
|||||||
.help("The transaction signature to confirm"),
|
.help("The transaction signature to confirm"),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
.subcommand(
|
||||||
|
SubCommand::with_name("decode-transaction")
|
||||||
|
.about("Decode a base-85 binary transaction")
|
||||||
|
.arg(
|
||||||
|
Arg::with_name("base85_transaction")
|
||||||
|
.index(1)
|
||||||
|
.value_name("BASE58_TRANSACTION")
|
||||||
|
.takes_value(true)
|
||||||
|
.required(true)
|
||||||
|
.help("The transaction to decode"),
|
||||||
|
),
|
||||||
|
)
|
||||||
.subcommand(
|
.subcommand(
|
||||||
SubCommand::with_name("create-address-with-seed")
|
SubCommand::with_name("create-address-with-seed")
|
||||||
.about("Generate a derived account address with a seed")
|
.about("Generate a derived account address with a seed")
|
||||||
|
Reference in New Issue
Block a user