示例#1
0
        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);
     }
 }
示例#3
0
        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);
        }
示例#4
0
        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);
        }