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 0e6d04f commit d6dc51f
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/subcommand/wallet/batch_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl Batch {
}
.inscribe(
&locked_utxos.into_keys().collect(),
wallet.get_runic_outputs()?,
wallet.get_runic_outputs()?.unwrap_or_default(),
utxos,
&wallet,
)
Expand Down
2 changes: 1 addition & 1 deletion src/subcommand/wallet/burn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ impl Burn {
script_pubkey: ScriptBuf,
burn_amount: Amount,
) -> Result<Transaction> {
let runic_outputs = wallet.get_runic_outputs()?;
let runic_outputs = wallet.get_runic_outputs()?.unwrap_or_default();

ensure!(
!runic_outputs.contains(&satpoint.outpoint),
Expand Down
2 changes: 1 addition & 1 deletion src/subcommand/wallet/cardinals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub(crate) fn run(wallet: Wallet) -> SubcommandResult {
.map(|satpoint| satpoint.outpoint)
.collect::<BTreeSet<OutPoint>>();

let runic_utxos = wallet.get_runic_outputs()?;
let runic_utxos = wallet.get_runic_outputs()?.unwrap_or_default();

let cardinal_utxos = unspent_outputs
.iter()
Expand Down
2 changes: 1 addition & 1 deletion src/subcommand/wallet/inscribe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ impl Inscribe {
}
.inscribe(
&wallet.locked_utxos().clone().into_keys().collect(),
wallet.get_runic_outputs()?,
wallet.get_runic_outputs()?.unwrap_or_default(),
wallet.utxos(),
&wallet,
)
Expand Down
4 changes: 3 additions & 1 deletion src/subcommand/wallet/runics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ pub struct RunicUtxo {

pub(crate) fn run(wallet: Wallet) -> SubcommandResult {
let unspent_outputs = wallet.utxos();
let runic_utxos = wallet.get_runic_outputs()?;
let Some(runic_utxos) = wallet.get_runic_outputs()? else {
bail!("`ord wallet runics` requires index created with `--index-runes`")
};

let runic_utxos = unspent_outputs
.iter()
Expand Down
1 change: 1 addition & 0 deletions src/subcommand/wallet/split.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ impl Split {

let balances = wallet
.get_runic_outputs()?
.unwrap_or_default()
.into_iter()
.filter(|output| !inscribed_outputs.contains(output))
.map(|output| {
Expand Down
15 changes: 10 additions & 5 deletions src/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ impl Wallet {
.utxos()
.keys()
.filter(|utxo| inscriptions.contains(utxo))
.chain(self.get_runic_outputs()?.iter())
.chain(self.get_runic_outputs()?.unwrap_or_default().iter())
.cloned()
.filter(|utxo| !locked.contains(utxo))
.collect::<Vec<OutPoint>>();
Expand Down Expand Up @@ -250,15 +250,19 @@ impl Wallet {
Ok(parent_info)
}

pub(crate) fn get_runic_outputs(&self) -> Result<BTreeSet<OutPoint>> {
pub(crate) fn get_runic_outputs(&self) -> Result<Option<BTreeSet<OutPoint>>> {
let mut runic_outputs = BTreeSet::new();
for (output, info) in &self.output_info {
if !info.runes.clone().unwrap_or_default().is_empty() {
let Some(runes) = &info.runes else {
return Ok(None);
};

if !runes.is_empty() {
runic_outputs.insert(*output);
}
}

Ok(runic_outputs)
Ok(Some(runic_outputs))
}

pub(crate) fn get_runes_balances_in_output(
Expand Down Expand Up @@ -874,7 +878,7 @@ impl Wallet {
}
}

let runic_outputs = self.get_runic_outputs()?;
let runic_outputs = self.get_runic_outputs()?.unwrap_or_default();

ensure!(
!runic_outputs.contains(&satpoint.outpoint),
Expand Down Expand Up @@ -935,6 +939,7 @@ impl Wallet {

let balances = self
.get_runic_outputs()?
.unwrap_or_default()
.into_iter()
.filter(|output| !inscribed_outputs.contains(output))
.map(|output| {
Expand Down

0 comments on commit d6dc51f

Please sign in to comment.