Skip to content

Commit

Permalink
re-added notes command
Browse files Browse the repository at this point in the history
  • Loading branch information
fluidvanadium committed Nov 19, 2024
1 parent bc3c525 commit bcf1861
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions zingolib/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -1796,6 +1836,7 @@ pub fn get_commands() -> HashMap<&'static str, Box<dyn Command>> {
("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 {})),
Expand Down

0 comments on commit bcf1861

Please sign in to comment.