diff --git a/zingolib/src/commands.rs b/zingolib/src/commands.rs index 76382b853..89c58346b 100644 --- a/zingolib/src/commands.rs +++ b/zingolib/src/commands.rs @@ -1679,6 +1679,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 { @@ -1798,6 +1838,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 {})), diff --git a/zingolib/src/wallet/transaction_records_by_id.rs b/zingolib/src/wallet/transaction_records_by_id.rs index c7ed509d0..24e6fd496 100644 --- a/zingolib/src/wallet/transaction_records_by_id.rs +++ b/zingolib/src/wallet/transaction_records_by_id.rs @@ -781,16 +781,6 @@ impl TransactionRecordsById { if let Ok(notes_from_tx) = transaction_record.get_spendable_note_ids_and_values(sources, exclude) { - if transaction_record - .outgoing_tx_data - .iter() - .any(|outgoing_tx_data| outgoing_tx_data.output_index.is_none()) - { - missing_output_index.push(( - transaction_record.txid, - transaction_record.status.get_height(), - )); - } notes_from_tx } else { missing_output_index.push((