Example #1
0
        private async Task CheckReceivedDividendTransactions()
        {
            var assets = (await _assetTracker.GetOwnedAssetsSince(_lastBalanceMatchBlock.Height))
                         .Where(a => a.Account != _walletRepository.NxtAccount.AccountRs);

            foreach (var asset in assets)
            {
                var dividendTransactions = await _nxtServer.GetDividendTransactionsAsync(asset.Account, _lastBalanceMatchBlock.Timestamp);

                foreach (var dividendTransaction in dividendTransactions.Except(_knownTransactions))
                {
                    var attachment = (ColoredCoinsDividendPaymentAttachment)dividendTransaction.Attachment;
                    var ownership  = await _assetTracker.GetOwnership(attachment.AssetId, attachment.Height);

                    if (ownership?.BalanceQnt > 0)
                    {
                        dividendTransaction.NqtAmount = attachment.AmountPerQnt.Nqt * ownership.BalanceQnt;
                        _newTransactions.Add(dividendTransaction);
                    }
                }
            }
        }