Skip to content

Commit

Permalink
feat: explicitly handle 'UtxoDoesNotExistError' from sync (#587)
Browse files Browse the repository at this point in the history
  • Loading branch information
vindard authored Dec 15, 2024
1 parent 9ddfe63 commit 3b32770
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/job/sync_wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ use crate::{
address::*,
app::BlockchainConfig,
batch::*,
bdk::error::BdkError,
bdk::pg::{ConfirmedIncomeUtxo, ConfirmedSpendTransaction, Transactions, Utxos as BdkUtxos},
bdk::{
error::BdkError,
pg::{ConfirmedIncomeUtxo, ConfirmedSpendTransaction, Transactions, Utxos as BdkUtxos},
},
fees::{self, FeesClient},
ledger::*,
primitives::*,
utxo::{Utxos, WalletUtxo},
utxo::{error::UtxoError, Utxos, WalletUtxo},
wallet::*,
};
use std::collections::HashMap;
Expand Down Expand Up @@ -507,10 +509,18 @@ pub async fn execute(
bdk_txs
.delete_transaction_if_no_more_utxos_exist(&mut tx, outpoint)
.await?;
let detected_txn_id = deps
let detected_txn_id = match deps
.bria_utxos
.delete_utxo(&mut tx, outpoint, keychain_id)
.await?;
.await
{
Ok(txn_id) => txn_id,
Err(UtxoError::UtxoDoesNotExistError) => {
tx.commit().await?;
continue;
}
Err(e) => return Err(e.into()),
};
match deps
.ledger
.utxo_dropped(tx, LedgerTransactionId::new(), detected_txn_id)
Expand Down

0 comments on commit 3b32770

Please sign in to comment.