Skip to content

Commit

Permalink
Merge pull request #678 from breez/fix-confirmed-balance
Browse files Browse the repository at this point in the history
fix confirmed balance
  • Loading branch information
roeierez authored Jan 20, 2025
2 parents 746b6e0 + 58e9533 commit 8076549
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions lib/core/src/sdk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2519,21 +2519,17 @@ impl LiquidSdk {

async fn update_wallet_info(&self) -> Result<()> {
let transactions = self.onchain_wallet.transactions().await?;
let wallet_amount_sat = transactions
.into_iter()
.filter(|tx| tx.height.is_some())
.map(|tx| {
tx.balance
.into_iter()
.filter_map(|(asset_id, balance)| {
if asset_id == utils::lbtc_asset_id(self.config.network) {
return Some(balance);
}
None
})
.sum::<i64>()
let mut wallet_amount_sat: i64 = 0;
transactions.into_iter().for_each(|tx| {
tx.balance.into_iter().for_each(|(asset_id, balance)| {
if asset_id == utils::lbtc_asset_id(self.config.network) {
//consider only confirmed unspent outputs (confirmed transactions output reduced by unconfirmed spent outputs)
if tx.height.is_some() || balance < 0 {
wallet_amount_sat += balance;
}
}
})
.sum::<i64>();
});
debug!("Onchain wallet balance: {wallet_amount_sat} sats");

let mut pending_send_sat = 0;
Expand Down

0 comments on commit 8076549

Please sign in to comment.