add flag to show spent outputs in wallet output command (#263)

This commit is contained in:
Yeastplume
2017-11-14 16:13:58 +00:00
committed by GitHub
parent d7fd730153
commit 855602e98a
2 changed files with 19 additions and 3 deletions
+8 -2
View File
@@ -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);