diff --git a/controller/src/command.rs b/controller/src/command.rs index 733222e4..976c304c 100644 --- a/controller/src/command.rs +++ b/controller/src/command.rs @@ -1106,6 +1106,7 @@ where pub struct TxsArgs { pub id: Option, pub tx_slate_id: Option, + pub count: Option, } pub fn txs( @@ -1125,11 +1126,15 @@ where let res = api.node_height(m)?; let (validated, txs) = api.retrieve_txs(m, true, args.id, args.tx_slate_id)?; let include_status = !args.id.is_some() && !args.tx_slate_id.is_some(); + // If view count is specified, restrict the TX list to `txs.len() - count` + let first_tx = args + .count + .map_or(0, |c| txs.len().saturating_sub(c as usize)); display::txs( &g_args.account, res.height, validated || updater_running, - &txs, + &txs[first_tx..], include_status, dark_scheme, )?; diff --git a/src/bin/grin-wallet.yml b/src/bin/grin-wallet.yml index bd8401f1..4166d20a 100644 --- a/src/bin/grin-wallet.yml +++ b/src/bin/grin-wallet.yml @@ -333,6 +333,11 @@ subcommands: short: t long: txid takes_value: true + - count: + help: Maximum number of transactions to show + short: c + long: count + takes_value: true - post: about: Posts a finalized transaction to the chain args: diff --git a/src/cmd/wallet_args.rs b/src/cmd/wallet_args.rs index 596a7862..55675bf1 100644 --- a/src/cmd/wallet_args.rs +++ b/src/cmd/wallet_args.rs @@ -840,9 +840,14 @@ pub fn parse_txs_args(args: &ArgMatches) -> Result let msg = format!("At most one of 'id' (-i) or 'txid' (-t) may be provided."); return Err(ParseError::ArgumentError(msg)); } + let count = match args.value_of("count") { + None => None, + Some(c) => Some(parse_u64(c, "count")? as u32), + }; Ok(command::TxsArgs { id: tx_id, tx_slate_id: tx_slate_id, + count: count, }) }