diff --git a/src/subcommand/wallet/addresses.rs b/src/subcommand/wallet/addresses.rs index 36243f2de0..2119bf3133 100644 --- a/src/subcommand/wallet/addresses.rs +++ b/src/subcommand/wallet/addresses.rs @@ -16,17 +16,12 @@ pub(crate) fn run(wallet: Wallet) -> SubcommandResult { for (output, txout) in wallet.utxos() { let address = wallet.chain().address_from_script(&txout.script_pubkey)?; - let inscriptions = if wallet.has_inscription_index() { - Some(wallet.get_inscriptions_in_output(output)) - } else { - None - }; + let inscriptions = wallet.get_inscriptions_in_output(output); - let runes = if wallet.has_rune_index() { - Some( - wallet - .get_runes_balances_in_output(output)? - .unwrap_or_default() + let runes = wallet + .get_runes_balances_in_output(output)? + .map(|balances| { + balances .iter() .map(|(rune, pile)| { ( @@ -37,11 +32,8 @@ pub(crate) fn run(wallet: Wallet) -> SubcommandResult { }, ) }) - .collect(), - ) - } else { - None - }; + .collect() + }); let output = Output { output: *output, diff --git a/src/subcommand/wallet/outputs.rs b/src/subcommand/wallet/outputs.rs index 2cd6f062cf..1254fc2316 100644 --- a/src/subcommand/wallet/outputs.rs +++ b/src/subcommand/wallet/outputs.rs @@ -30,17 +30,12 @@ impl Outputs { .ok() .map(|address| address.as_unchecked().clone()); - let inscriptions = if wallet.has_inscription_index() { - Some(wallet.get_inscriptions_in_output(output)) - } else { - None - }; + let inscriptions = wallet.get_inscriptions_in_output(output); - let runes = if wallet.has_rune_index() { - Some( - wallet - .get_runes_balances_in_output(output)? - .unwrap_or_default() + let runes = wallet + .get_runes_balances_in_output(output)? + .map(|balances| { + balances .iter() .map(|(rune, pile)| { ( @@ -51,11 +46,8 @@ impl Outputs { }, ) }) - .collect(), - ) - } else { - None - }; + .collect() + }); let sat_ranges = if wallet.has_sat_index() && self.ranges { Some( diff --git a/src/wallet.rs b/src/wallet.rs index 5de258f498..ce2b4cc96b 100644 --- a/src/wallet.rs +++ b/src/wallet.rs @@ -217,14 +217,8 @@ impl Wallet { ) } - pub(crate) fn get_inscriptions_in_output(&self, output: &OutPoint) -> Vec { - self - .output_info - .get(output) - .unwrap() - .inscriptions - .clone() - .unwrap_or_default() + pub(crate) fn get_inscriptions_in_output(&self, output: &OutPoint) -> Option> { + self.output_info.get(output).unwrap().inscriptions.clone() } pub(crate) fn get_parent_info(&self, parents: &[InscriptionId]) -> Result> {