Пример #1
0
        public void List(ulong transactionId)
        {
            var transaction = _transactionService.GetTransaction(GetTransactionLocator.ByTransactionId(transactionId)).Result;
            var attachment  = (ColoredCoinsDividendPaymentAttachment)transaction.Attachment;

            _asset = _assetService.GetAsset(attachment.AssetId, true).Result;
            var decimalMultiplier = (decimal)Math.Pow(10, _asset.Decimals);
            var assetOwners       = GetOwners(attachment.Height).Where(FilterOwners()).OrderByDescending(d => d.QuantityQnt).ToList();
            var totalSpent        = Amount.CreateAmountFromNqt(assetOwners.Sum(o => o.QuantityQnt) * attachment.AmountPerQnt.Nqt);

            Console.WriteLine($"Using dividend transaction: {transactionId} ({transaction.BlockTimestamp?.ToString("yyyy-MM-dd HH:mm")})");
            Console.WriteLine("Fetching dividend payments for asset: {0} ({1})", _asset.Name, _asset.AssetId);
            Console.WriteLine("Total in dividend: {0} NXT", totalSpent.Nxt);
            Console.WriteLine("Per share: {0} NXT", attachment.AmountPerQnt.Nxt * decimalMultiplier);
            Console.WriteLine("Number of shareholders at height {0}: {1}", attachment.Height, assetOwners.Count());
            Console.WriteLine("----------------------------------------------------------------");

            foreach (var assetOwner in assetOwners)
            {
                var quantityQnt    = assetOwner.QuantityQnt;
                var amountRecieved = Amount.CreateAmountFromNqt(quantityQnt * attachment.AmountPerQnt.Nqt);
                Console.WriteLine("Account: {0}, Shares: {1}, Amount: {2} NXT",
                                  assetOwner.AccountRs, assetOwner.QuantityQnt / decimalMultiplier, amountRecieved.Nxt);
            }

            Console.WriteLine("----------------------------------------------------------------");
        }
Пример #2
0
        public async Task <Transaction> GetTransaction(ulong transactionId)
        {
            try
            {
                var transactionReply = await _transactionService.GetTransaction(GetTransactionLocator.ByTransactionId(transactionId));

                return((Transaction)transactionReply);
            }
            catch (NxtException)
            {
                return(null);
            }
        }
Пример #3
0
        static void Main(string[] args)
        {
            var options = Parse(args);

            _service = new AssetExchangeService();
            var transactionService = new TransactionService();

            _asset = _service.GetAsset(options.AssetId, true).Result;
            _assetDecimalFactor = (decimal)Math.Pow(10, -_asset.Decimals);

            var transfers             = GetAssetTransfers(_asset);
            var trades                = GetAssetTrades(_asset);
            var assetIssueTransaction = transactionService.GetTransaction(GetTransactionLocator.ByTransactionId(_asset.AssetId)).Result;

            if (assetIssueTransaction.Timestamp.CompareTo(options.StartDate) > 0)
            {
                options.StartDate = assetIssueTransaction.Timestamp;
            }

            Console.WriteLine($"Asset Name     : {_asset.Name}");
            Console.WriteLine($"Asset ID       : {_asset.AssetId}");
            Console.WriteLine($"Asset Trades   : {_asset.NumberOfTrades}");
            Console.WriteLine($"Asset Transfers: {_asset.NumberOfTransfers}");
            Console.WriteLine($"Issue Date     : {assetIssueTransaction.Timestamp:g}");
            Console.WriteLine($"Start Date     : {options.StartDate:d}");
            Console.WriteLine("------------------------------------------------");

            if (options.Range == Range.Daily)
            {
                WriteDailyData(options.StartDate, trades, transfers);
            }
            if (options.Range == Range.Weekly)
            {
                WriteWeeklyData(options.StartDate, trades, transfers);
            }
            if (options.Range == Range.Monthly)
            {
                WriteMonthlyData(options.StartDate, trades, transfers);
            }
            if (options.Range == Range.Yearly)
            {
                WriteYearlyData(options.StartDate, trades, transfers);
            }

            Console.WriteLine("Press enter to quit");
            Console.ReadLine();
        }
Пример #4
0
 private void TestAllForExceptions()
 {
     using (Logger = new TestsessionLogger(_logger))
     {
         foreach (var pollId in _getPolls.Polls.Where(p => p.PollId != 9315232938245213980).Select(p => p.PollId))
         {
             var getPollResult = _votingSystemService.GetPollResult(pollId).Result;
             var transaction   = _transactionService.GetTransaction(GetTransactionLocator.ByTransactionId(pollId)).Result;
             var attachment    = (MessagingPollCreationAttachment)transaction.Attachment;
             AssetDecimals(attachment, getPollResult);
             AssertEquals(attachment.FinishHeight <= TestSettings.MaxHeight, getPollResult.Finished, "Finished");
             AssertHoldingId(attachment, getPollResult);
             AssertEquals(attachment.MinBalance, getPollResult.MinBalance, "MinBalance");
             AssertEquals(attachment.MinBalanceModel, getPollResult.MinBalanceModel, "MinBalanceModel");
             AssertEquals(attachment.Options, getPollResult.Options, "Options");
             AssertEquals(pollId, getPollResult.PollId, "PollId");
             AssertResults(attachment, getPollResult);
             AssertEquals(attachment.VotingModel, getPollResult.VotingModel, "VotingModel");
         }
     }
 }
Пример #5
0
        static void Main(string[] args)
        {
            IServiceFactory serviceFactory = new ServiceFactory(Constants.DefaultNxtUrl);

            transactionService = serviceFactory.CreateTransactionService();
            var shufflingService  = serviceFactory.CreateShufflingService();
            var serverInfoService = serviceFactory.CreateServerInfoService();

            var state               = serverInfoService.GetState().Result;
            var shufflingDeadline   = (state.IsTestnet ? 10 : 100) - 1;
            var shufflingDepositNxt = state.IsTestnet ? 7 : 1000;

            var allShufflings = shufflingService.GetAllShufflings(true, false).Result;

            foreach (var shuffling in allShufflings.Shufflings.Where(s => ShufflingFailed(s)))
            {
                var         shufflingTransaction  = transactionService.GetTransaction(GetTransactionLocator.ByTransactionId(shuffling.ShufflingId)).Result;
                var         shufflingParticipants = shufflingService.GetShufflingParticipants(shuffling.ShufflingId).Result;
                var         priorShufflingStage   = GetPriorShufflingStage(shufflingParticipants.Participants);
                var         blameAccountRs        = shuffling.AssigneeRs;
                int         height      = 0;
                Transaction transaction = null;

                if (priorShufflingStage == ShufflingStage.Processing)
                {
                    if (shufflingParticipants.Participants.All(p => p.State == ShufflingParticipantState.Registered))
                    {
                        var lastAccountRs = GetLastAccountRs(shufflingParticipants);
                        transaction = GetShufflingRegistrationTransaction(shufflingTransaction, lastAccountRs);
                    }
                    else // at least 1 participant processed
                    {
                        var previousAccountRs = GetPreviousAccountRs(shufflingParticipants, blameAccountRs);
                        transaction = GetShufflingProcessingTransaction(shuffling, shufflingTransaction, previousAccountRs);
                    }
                    height = transaction.Height + shufflingDeadline;
                }
                else // priorShufflingStage == ShufflingStage.Verification
                {
                    if (shufflingParticipants.Participants.All(p => p.State == ShufflingParticipantState.Processed))
                    {
                        var lastAccountRs = GetLastAccountRs(shufflingParticipants);
                        transaction = GetShufflingProcessingTransaction(shuffling, shufflingTransaction, lastAccountRs);
                    }
                    else // at least 1 participant verified
                    {
                        var previousAccountRs = GetPreviousAccountRs(shufflingParticipants, blameAccountRs);
                        transaction = GetShufflingVerificationTransaction(shuffling, shufflingTransaction, previousAccountRs);
                    }
                    height = transaction.Height + shufflingDeadline + shuffling.ParticipantCount;
                }

                var refund    = shuffling.Amount.Nqt - Amount.CreateAmountFromNxt(shufflingDepositNxt).Nqt;
                var refundNxt = Amount.CreateAmountFromNqt(refund).Nxt;
                Console.WriteLine($"{blameAccountRs} is to blame for shuffling {shuffling.ShufflingId} @ height {height} and only gets back {refundNxt} (from {shuffling.Amount.Nxt}) NXT.");
            }
            Console.WriteLine("Done and done!");
            Console.ReadLine();
        }
Пример #6
0
        private static ColoredCoinsDividendPaymentAttachment GetTransactionAttachment(ulong transactionId)
        {
            var transaction = TransactionService.GetTransaction(GetTransactionLocator.ByTransactionId(transactionId)).Result;

            return((ColoredCoinsDividendPaymentAttachment)transaction.Attachment);
        }