diff --git a/zingolib/src/commands.rs b/zingolib/src/commands.rs index baeff45ef..256a73834 100644 --- a/zingolib/src/commands.rs +++ b/zingolib/src/commands.rs @@ -1677,6 +1677,46 @@ impl Command for NewAddressCommand { } } +struct NotesCommand {} +impl Command for NotesCommand { + fn help(&self) -> &'static str { + indoc! {r#" + Show all shielded notes and transparent coins in this wallet + Usage: + notes [all] + If you supply the "all" parameter, all previously spent shielded notes and transparent coins are also included + "#} + } + + fn short_help(&self) -> &'static str { + "Show all shielded notes and transparent coins in this wallet" + } + + fn exec(&self, args: &[&str], lightclient: &LightClient) -> String { + // Parse the args. + if args.len() > 1 { + return self.short_help().to_string(); + } + + // Make sure we can parse the amount + let all_notes = if args.len() == 1 { + match args[0] { + "all" => true, + a => { + return format!( + "Invalid argument \"{}\". Specify 'all' to include unspent notes", + a + ) + } + } + } else { + false + }; + + RT.block_on(async move { lightclient.do_list_notes(all_notes).await.pretty(2) }) + } +} + struct QuitCommand {} impl Command for QuitCommand { fn help(&self) -> &'static str { @@ -1796,6 +1836,7 @@ pub fn get_commands() -> HashMap<&'static str, Box> { ("shield", Box::new(ShieldCommand {})), ("save", Box::new(DeprecatedNoCommand {})), ("quit", Box::new(QuitCommand {})), + ("notes", Box::new(NotesCommand {})), ("new", Box::new(NewAddressCommand {})), ("defaultfee", Box::new(DefaultFeeCommand {})), ("seed", Box::new(SeedCommand {})),