Skip to content

Commit

Permalink
Amend
Browse files Browse the repository at this point in the history
  • Loading branch information
raphjaph committed Dec 20, 2024
1 parent 249d908 commit 7494843
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 38 deletions.
22 changes: 7 additions & 15 deletions src/subcommand/wallet/addresses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)| {
(
Expand All @@ -37,11 +32,8 @@ pub(crate) fn run(wallet: Wallet) -> SubcommandResult {
},
)
})
.collect(),
)
} else {
None
};
.collect()
});

let output = Output {
output: *output,
Expand Down
22 changes: 7 additions & 15 deletions src/subcommand/wallet/outputs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)| {
(
Expand All @@ -51,11 +46,8 @@ impl Outputs {
},
)
})
.collect(),
)
} else {
None
};
.collect()
});

let sat_ranges = if wallet.has_sat_index() && self.ranges {
Some(
Expand Down
10 changes: 2 additions & 8 deletions src/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,14 +217,8 @@ impl Wallet {
)
}

pub(crate) fn get_inscriptions_in_output(&self, output: &OutPoint) -> Vec<InscriptionId> {
self
.output_info
.get(output)
.unwrap()
.inscriptions
.clone()
.unwrap_or_default()
pub(crate) fn get_inscriptions_in_output(&self, output: &OutPoint) -> Option<Vec<InscriptionId>> {
self.output_info.get(output).unwrap().inscriptions.clone()
}

pub(crate) fn get_parent_info(&self, parents: &[InscriptionId]) -> Result<Vec<ParentInfo>> {
Expand Down

0 comments on commit 7494843

Please sign in to comment.