Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

re-added notes command #1535

Merged
merged 1 commit into from
Nov 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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