CLI: Support dumping the TX message in sign-only mode

This commit is contained in:
Trent Nelson
2021-03-12 19:37:39 -07:00
committed by Trent Nelson
parent 98ea058ebe
commit 672e9c640f
12 changed files with 305 additions and 13 deletions

View File

@@ -18,8 +18,8 @@ use solana_clap_utils::{
};
use solana_cli_output::{
display::{build_balance_message, println_name_value},
return_signers, CliAccount, CliSignature, CliSignatureVerificationStatus, CliTransaction,
CliTransactionConfirmation, OutputFormat,
return_signers_with_config, CliAccount, CliSignature, CliSignatureVerificationStatus,
CliTransaction, CliTransactionConfirmation, OutputFormat, ReturnSignersConfig,
};
use solana_client::{
blockhash_query::BlockhashQuery,
@@ -198,6 +198,7 @@ pub enum CliCommand {
lockup: Lockup,
amount: SpendAmount,
sign_only: bool,
dump_transaction_message: bool,
blockhash_query: BlockhashQuery,
nonce_account: Option<Pubkey>,
nonce_authority: SignerIndex,
@@ -208,6 +209,7 @@ pub enum CliCommand {
stake_account_pubkey: Pubkey,
stake_authority: SignerIndex,
sign_only: bool,
dump_transaction_message: bool,
blockhash_query: BlockhashQuery,
nonce_account: Option<Pubkey>,
nonce_authority: SignerIndex,
@@ -219,6 +221,7 @@ pub enum CliCommand {
stake_authority: SignerIndex,
force: bool,
sign_only: bool,
dump_transaction_message: bool,
blockhash_query: BlockhashQuery,
nonce_account: Option<Pubkey>,
nonce_authority: SignerIndex,
@@ -228,6 +231,7 @@ pub enum CliCommand {
stake_account_pubkey: Pubkey,
stake_authority: SignerIndex,
sign_only: bool,
dump_transaction_message: bool,
blockhash_query: BlockhashQuery,
nonce_account: Option<Pubkey>,
nonce_authority: SignerIndex,
@@ -241,6 +245,7 @@ pub enum CliCommand {
source_stake_account_pubkey: Pubkey,
stake_authority: SignerIndex,
sign_only: bool,
dump_transaction_message: bool,
blockhash_query: BlockhashQuery,
nonce_account: Option<Pubkey>,
nonce_authority: SignerIndex,
@@ -257,6 +262,7 @@ pub enum CliCommand {
stake_account_pubkey: Pubkey,
new_authorizations: Vec<(StakeAuthorize, Pubkey, SignerIndex)>,
sign_only: bool,
dump_transaction_message: bool,
blockhash_query: BlockhashQuery,
nonce_account: Option<Pubkey>,
nonce_authority: SignerIndex,
@@ -268,6 +274,7 @@ pub enum CliCommand {
lockup: LockupArgs,
custodian: SignerIndex,
sign_only: bool,
dump_transaction_message: bool,
blockhash_query: BlockhashQuery,
nonce_account: Option<Pubkey>,
nonce_authority: SignerIndex,
@@ -280,6 +287,7 @@ pub enum CliCommand {
withdraw_authority: SignerIndex,
custodian: Option<SignerIndex>,
sign_only: bool,
dump_transaction_message: bool,
blockhash_query: BlockhashQuery,
nonce_account: Option<Pubkey>,
nonce_authority: SignerIndex,
@@ -351,6 +359,7 @@ pub enum CliCommand {
to: Pubkey,
from: SignerIndex,
sign_only: bool,
dump_transaction_message: bool,
no_wait: bool,
blockhash_query: BlockhashQuery,
nonce_account: Option<Pubkey>,
@@ -847,6 +856,7 @@ pub fn parse_command(
let amount = SpendAmount::new_from_matches(matches, "amount");
let to = pubkey_of_signer(matches, "to", wallet_manager)?.unwrap();
let sign_only = matches.is_present(SIGN_ONLY_ARG.name);
let dump_transaction_message = matches.is_present(DUMP_TRANSACTION_MESSAGE.name);
let no_wait = matches.is_present("no_wait");
let blockhash_query = BlockhashQuery::new_from_matches(matches);
let nonce_account = pubkey_of_signer(matches, NONCE_ARG.name, wallet_manager)?;
@@ -875,6 +885,7 @@ pub fn parse_command(
amount,
to,
sign_only,
dump_transaction_message,
no_wait,
blockhash_query,
nonce_account,
@@ -1127,6 +1138,7 @@ fn process_transfer(
to: &Pubkey,
from: SignerIndex,
sign_only: bool,
dump_transaction_message: bool,
no_wait: bool,
blockhash_query: &BlockhashQuery,
nonce_account: Option<&Pubkey>,
@@ -1193,7 +1205,13 @@ fn process_transfer(
if sign_only {
tx.try_partial_sign(&config.signers, recent_blockhash)?;
return_signers(&tx, &config.output_format)
return_signers_with_config(
&tx,
&config.output_format,
&ReturnSignersConfig {
dump_transaction_message,
},
)
} else {
if let Some(nonce_account) = &nonce_account {
let nonce_account = nonce_utils::get_account_with_commitment(
@@ -1445,6 +1463,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
lockup,
amount,
sign_only,
dump_transaction_message,
blockhash_query,
ref nonce_account,
nonce_authority,
@@ -1460,6 +1479,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
lockup,
*amount,
*sign_only,
*dump_transaction_message,
blockhash_query,
nonce_account.as_ref(),
*nonce_authority,
@@ -1470,6 +1490,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
stake_account_pubkey,
stake_authority,
sign_only,
dump_transaction_message,
blockhash_query,
nonce_account,
nonce_authority,
@@ -1480,6 +1501,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
&stake_account_pubkey,
*stake_authority,
*sign_only,
*dump_transaction_message,
blockhash_query,
*nonce_account,
*nonce_authority,
@@ -1491,6 +1513,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
stake_authority,
force,
sign_only,
dump_transaction_message,
blockhash_query,
nonce_account,
nonce_authority,
@@ -1503,6 +1526,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
*stake_authority,
*force,
*sign_only,
*dump_transaction_message,
blockhash_query,
*nonce_account,
*nonce_authority,
@@ -1512,6 +1536,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
stake_account_pubkey,
stake_authority,
sign_only,
dump_transaction_message,
blockhash_query,
nonce_account,
nonce_authority,
@@ -1525,6 +1550,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
&stake_account_pubkey,
*stake_authority,
*sign_only,
*dump_transaction_message,
blockhash_query,
*nonce_account,
*nonce_authority,
@@ -1538,6 +1564,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
source_stake_account_pubkey,
stake_authority,
sign_only,
dump_transaction_message,
blockhash_query,
nonce_account,
nonce_authority,
@@ -1549,6 +1576,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
&source_stake_account_pubkey,
*stake_authority,
*sign_only,
*dump_transaction_message,
blockhash_query,
*nonce_account,
*nonce_authority,
@@ -1570,6 +1598,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
stake_account_pubkey,
ref new_authorizations,
sign_only,
dump_transaction_message,
blockhash_query,
nonce_account,
nonce_authority,
@@ -1582,6 +1611,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
new_authorizations,
*custodian,
*sign_only,
*dump_transaction_message,
blockhash_query,
*nonce_account,
*nonce_authority,
@@ -1592,6 +1622,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
mut lockup,
custodian,
sign_only,
dump_transaction_message,
blockhash_query,
nonce_account,
nonce_authority,
@@ -1603,6 +1634,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
&mut lockup,
*custodian,
*sign_only,
*dump_transaction_message,
blockhash_query,
*nonce_account,
*nonce_authority,
@@ -1615,6 +1647,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
withdraw_authority,
custodian,
sign_only,
dump_transaction_message,
blockhash_query,
ref nonce_account,
nonce_authority,
@@ -1628,6 +1661,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
*withdraw_authority,
*custodian,
*sign_only,
*dump_transaction_message,
blockhash_query,
nonce_account.as_ref(),
*nonce_authority,
@@ -1787,6 +1821,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
to,
from,
sign_only,
dump_transaction_message,
no_wait,
ref blockhash_query,
ref nonce_account,
@@ -1801,6 +1836,7 @@ pub fn process_command(config: &CliConfig) -> ProcessResult {
to,
*from,
*sign_only,
*dump_transaction_message,
*no_wait,
blockhash_query,
nonce_account.as_ref(),
@@ -2612,6 +2648,7 @@ mod tests {
},
amount: SpendAmount::Some(30),
sign_only: false,
dump_transaction_message: false,
blockhash_query: BlockhashQuery::All(blockhash_query::Source::Cluster),
nonce_account: None,
nonce_authority: 0,
@@ -2631,6 +2668,7 @@ mod tests {
withdraw_authority: 0,
custodian: None,
sign_only: false,
dump_transaction_message: false,
blockhash_query: BlockhashQuery::All(blockhash_query::Source::Cluster),
nonce_account: None,
nonce_authority: 0,
@@ -2645,6 +2683,7 @@ mod tests {
stake_account_pubkey,
stake_authority: 0,
sign_only: false,
dump_transaction_message: false,
blockhash_query: BlockhashQuery::default(),
nonce_account: None,
nonce_authority: 0,
@@ -2659,6 +2698,7 @@ mod tests {
stake_account_pubkey,
stake_authority: 0,
sign_only: false,
dump_transaction_message: false,
blockhash_query: BlockhashQuery::default(),
nonce_account: None,
nonce_authority: 0,
@@ -2679,6 +2719,7 @@ mod tests {
source_stake_account_pubkey,
stake_authority: 1,
sign_only: false,
dump_transaction_message: false,
blockhash_query: BlockhashQuery::default(),
nonce_account: None,
nonce_authority: 0,
@@ -2866,6 +2907,7 @@ mod tests {
to: to_pubkey,
from: 0,
sign_only: false,
dump_transaction_message: false,
no_wait: false,
blockhash_query: BlockhashQuery::All(blockhash_query::Source::Cluster),
nonce_account: None,
@@ -2890,6 +2932,7 @@ mod tests {
to: to_pubkey,
from: 0,
sign_only: false,
dump_transaction_message: false,
no_wait: false,
blockhash_query: BlockhashQuery::All(blockhash_query::Source::Cluster),
nonce_account: None,
@@ -2918,6 +2961,7 @@ mod tests {
to: to_pubkey,
from: 0,
sign_only: false,
dump_transaction_message: false,
no_wait: true,
blockhash_query: BlockhashQuery::All(blockhash_query::Source::Cluster),
nonce_account: None,
@@ -2950,6 +2994,7 @@ mod tests {
to: to_pubkey,
from: 0,
sign_only: true,
dump_transaction_message: false,
no_wait: false,
blockhash_query: BlockhashQuery::None(blockhash),
nonce_account: None,
@@ -2987,6 +3032,7 @@ mod tests {
to: to_pubkey,
from: 0,
sign_only: false,
dump_transaction_message: false,
no_wait: false,
blockhash_query: BlockhashQuery::FeeCalculator(
blockhash_query::Source::Cluster,
@@ -3028,6 +3074,7 @@ mod tests {
to: to_pubkey,
from: 0,
sign_only: false,
dump_transaction_message: false,
no_wait: false,
blockhash_query: BlockhashQuery::FeeCalculator(
blockhash_query::Source::NonceAccount(nonce_address),
@@ -3067,6 +3114,7 @@ mod tests {
to: to_pubkey,
from: 0,
sign_only: false,
dump_transaction_message: false,
no_wait: false,
blockhash_query: BlockhashQuery::All(blockhash_query::Source::Cluster),
nonce_account: None,