mirror of
https://github.com/mimblewimble/grin.git
synced 2025-02-08 12:21: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")
|
.long("external")
|
||||||
.help("Listen on 0.0.0.0 interface to allow external connections (default is 127.0.0.1)")
|
.help("Listen on 0.0.0.0 interface to allow external connections (default is 127.0.0.1)")
|
||||||
.takes_value(false))
|
.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")
|
.arg(Arg::with_name("api_server_address")
|
||||||
.short("a")
|
.short("a")
|
||||||
.long("api_server_address")
|
.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();
|
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.
|
// Derive the keychain based on seed from seed file and specified passphrase.
|
||||||
// Generate the initial wallet seed if we are running "wallet init".
|
// Generate the initial wallet seed if we are running "wallet init".
|
||||||
if let ("init", Some(_)) = wallet_args.subcommand() {
|
if let ("init", Some(_)) = wallet_args.subcommand() {
|
||||||
|
@ -446,7 +456,7 @@ fn wallet_command(wallet_args: &ArgMatches) {
|
||||||
wallet::show_info(&wallet_config, &keychain);
|
wallet::show_info(&wallet_config, &keychain);
|
||||||
}
|
}
|
||||||
("outputs", Some(_)) => {
|
("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"),
|
_ => panic!("Unknown wallet command, use 'grin help wallet' for details"),
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,12 +15,12 @@
|
||||||
use checker;
|
use checker;
|
||||||
use keychain::Keychain;
|
use keychain::Keychain;
|
||||||
use core::core;
|
use core::core;
|
||||||
use types::{WalletConfig, WalletData};
|
use types::{WalletConfig, WalletData, OutputStatus};
|
||||||
use prettytable;
|
use prettytable;
|
||||||
use term;
|
use term;
|
||||||
use std::io::prelude::*;
|
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 root_key_id = keychain.root_key_id();
|
||||||
let result = checker::refresh_outputs(&config, &keychain);
|
let result = checker::refresh_outputs(&config, &keychain);
|
||||||
|
|
||||||
|
@ -40,6 +40,12 @@ pub fn show_outputs(config: &WalletConfig, keychain: &Keychain) {
|
||||||
.outputs
|
.outputs
|
||||||
.values()
|
.values()
|
||||||
.filter(|out| out.root_key_id == root_key_id)
|
.filter(|out| out.root_key_id == root_key_id)
|
||||||
|
.filter(|out|
|
||||||
|
if show_spent {
|
||||||
|
true
|
||||||
|
} else {
|
||||||
|
out.status != OutputStatus::Spent
|
||||||
|
})
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
outputs.sort_by_key(|out| out.n_child);
|
outputs.sort_by_key(|out| out.n_child);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue