Skip to content

Commit

Permalink
indexers: prevent non-mined transactions from not getting into UTXO list
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-orlovsky committed Jul 10, 2024
1 parent 418bf29 commit 1fb5e8c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,8 @@ impl<T> TxStatus<T> {
TxStatus::Unknown => TxStatus::Unknown,
}
}

pub fn is_mined(&self) -> bool { matches!(self, Self::Mined(_)) }
}

impl<T> Display for TxStatus<T>
Expand Down
4 changes: 3 additions & 1 deletion src/indexers/electrum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,9 @@ impl Indexer for Client {
prev_tx.outputs.get_mut(credit.outpoint.vout_u32() as usize)
{
let outpoint = txout.outpoint;
cache.utxo.remove(&outpoint);
if tx.status.is_mined() {
cache.utxo.remove(&outpoint);
}
txout.spent = Some(credit.outpoint.into())
};
}
Expand Down
4 changes: 3 additions & 1 deletion src/indexers/esplora.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,9 @@ impl Indexer for BlockingClient {
prev_tx.outputs.get_mut(credit.outpoint.vout_u32() as usize)
{
let outpoint = txout.outpoint;
cache.utxo.remove(&outpoint);
if tx.status.is_mined() {
cache.utxo.remove(&outpoint);
}
txout.spent = Some(credit.outpoint.into())
};
}
Expand Down

0 comments on commit 1fb5e8c

Please sign in to comment.