gui(daemon): filter coins for pending txs

This commit is contained in:
jp1ac4 2024-02-06 14:09:14 +00:00
parent 46121590c3
commit aa578ba1fd
No known key found for this signature in database
GPG Key ID: A7ACD32423568D7B

View File

@ -225,7 +225,11 @@ pub trait Daemon: Debug {
fn list_pending_txs(&self) -> Result<Vec<model::HistoryTransaction>, DaemonError> {
let info = self.get_info()?;
let coins = self.list_coins(&[], &[])?.coins;
// We want coins that are inputs to and/or outputs of a pending tx,
// which can only be unconfirmed and spending coins.
let coins = self
.list_coins(&[CoinStatus::Unconfirmed, CoinStatus::Spending], &[])?
.coins;
let mut txids: Vec<Txid> = Vec::new();
for coin in &coins {
if coin.block_height.is_none() && !txids.contains(&coin.outpoint.txid) {
@ -233,7 +237,7 @@ pub trait Daemon: Debug {
}
if let Some(spend) = coin.spend_info {
if spend.height.is_none() && !txids.contains(&spend.txid) {
if !txids.contains(&spend.txid) {
txids.push(spend.txid);
}
}