private async Task <IWalletBalance> UpdateBalance(string address, long balance, int lastBlock) { if (balance != 0) { var walletBalanceEntity = WalletBalance.Create(address, balance, lastBlock); await _balanceRepository.InsertOrReplace(walletBalanceEntity); return(walletBalanceEntity); } await _balanceRepository.DeleteIfExist(address); return(null); }
private async Task UpdateBalanceInRepo(int lastBlock, string address, decimal balance, string assetId) { if (balance != 0) { _log.Info($"[{lastBlock}] Detected balance on {address}: {balance} {assetId}"); await _walletBalanceRepository.InsertOrReplace( WalletBalance.Create(address, balance: balance, assetId: assetId, updatedAtBlock: lastBlock)); } else { await _walletBalanceRepository.DeleteIfExist(address, assetId); } }
public async Task <IWalletBalance> UpdateBalance(IObservableWallet wallet) { if (wallet != null) { var balance = await _blockChainProvider.GetBalanceSatoshi(wallet.Address); if (balance != 0) { var walletBalanceEntity = WalletBalance.Create(wallet.Address, balance); await _balanceRepository.InsertOrReplace(walletBalanceEntity); return(walletBalanceEntity); } else { await _balanceRepository.DeleteIfExist(wallet.Address); } } return(null); }
public async Task <IWalletBalance> UpdateBalance(IObservableWallet wallet) { if (wallet != null) { var balance = await _blockChainProvider.GetBalanceSatoshiFromUnspentOutputs(wallet.Address, _confirmationsSettings.MinConfirmationsToDetectOperation); var lastBlock = await _blockChainProvider.GetLastBlockHeight(); if (balance != 0) { var walletBalanceEntity = WalletBalance.Create(wallet.Address, balance, lastBlock); await _balanceRepository.InsertOrReplace(walletBalanceEntity); return(walletBalanceEntity); } await _balanceRepository.DeleteIfExist(wallet.Address); } return(null); }