mirror of
https://github.com/mimblewimble/grin.git
synced 2025-02-01 17:01:09 +03:00
add flag to show spent outputs in wallet output command (#263)
This commit is contained in:
parent
d7fd730153
commit
855602e98a
2 changed files with 19 additions and 3 deletions
|
@ -179,6 +179,11 @@ fn main() {
|
|||
.long("external")
|
||||
.help("Listen on 0.0.0.0 interface to allow external connections (default is 127.0.0.1)")
|
||||
.takes_value(false))
|
||||
.arg(Arg::with_name("show_spent")
|
||||
.short("s")
|
||||
.long("show_spent")
|
||||
.help("Show spent outputs on wallet output command")
|
||||
.takes_value(false))
|
||||
.arg(Arg::with_name("api_server_address")
|
||||
.short("a")
|
||||
.long("api_server_address")
|
||||
|
@ -368,6 +373,11 @@ fn wallet_command(wallet_args: &ArgMatches) {
|
|||
wallet_config.check_node_api_http_addr = sa.to_string().clone();
|
||||
}
|
||||
|
||||
let mut show_spent=false;
|
||||
if wallet_args.is_present("show_spent") {
|
||||
show_spent=true;
|
||||
}
|
||||
|
||||
// Derive the keychain based on seed from seed file and specified passphrase.
|
||||
// Generate the initial wallet seed if we are running "wallet init".
|
||||
if let ("init", Some(_)) = wallet_args.subcommand() {
|
||||
|
@ -446,7 +456,7 @@ fn wallet_command(wallet_args: &ArgMatches) {
|
|||
wallet::show_info(&wallet_config, &keychain);
|
||||
}
|
||||
("outputs", Some(_)) => {
|
||||
wallet::show_outputs(&wallet_config, &keychain);
|
||||
wallet::show_outputs(&wallet_config, &keychain, show_spent);
|
||||
}
|
||||
_ => panic!("Unknown wallet command, use 'grin help wallet' for details"),
|
||||
}
|
||||
|
|
|
@ -15,12 +15,12 @@
|
|||
use checker;
|
||||
use keychain::Keychain;
|
||||
use core::core;
|
||||
use types::{WalletConfig, WalletData};
|
||||
use types::{WalletConfig, WalletData, OutputStatus};
|
||||
use prettytable;
|
||||
use term;
|
||||
use std::io::prelude::*;
|
||||
|
||||
pub fn show_outputs(config: &WalletConfig, keychain: &Keychain) {
|
||||
pub fn show_outputs(config: &WalletConfig, keychain: &Keychain, show_spent:bool) {
|
||||
let root_key_id = keychain.root_key_id();
|
||||
let result = checker::refresh_outputs(&config, &keychain);
|
||||
|
||||
|
@ -40,6 +40,12 @@ pub fn show_outputs(config: &WalletConfig, keychain: &Keychain) {
|
|||
.outputs
|
||||
.values()
|
||||
.filter(|out| out.root_key_id == root_key_id)
|
||||
.filter(|out|
|
||||
if show_spent {
|
||||
true
|
||||
} else {
|
||||
out.status != OutputStatus::Spent
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
outputs.sort_by_key(|out| out.n_child);
|
||||
|
||||
|
|
Loading…
Reference in a new issue