Ejemplo n.º 1
0
        private void CheckTransactionTypeValues(TransactionSubType expectedSubType)
        {
            var expectedName = GetAttributeName(expectedSubType);

            var actual = _getConstantsReply.TransactionTypes
                         [TransactionTypeMapper.GetMainTypeByte(expectedSubType)]
                         [TransactionTypeMapper.GetSubTypeByte(expectedSubType)];

            if (actual == null)
            {
                Logger.Fail($"Did not find expected transaction type {expectedName}");
                return;
            }
            if (!actual.Name.Equals(expectedName))
            {
                Logger.Fail($"Transaction type name mismatch, expected: {expectedName}, actual: {actual.Name}");
            }
            else
            {
                var expectedValues = _transactionTypes[expectedSubType];
                AssertEquals(expectedValues.CanHaveRecipient, actual.CanHaveRecipient, "CanHaveRecipient");
                AssertEquals(expectedValues.IsPhasingSafe, actual.IsPhasingSafe, "IsPhasingSafe");
                AssertEquals(expectedValues.MustHaveRecipient, actual.MustHaveRecipient, "MustHaveRecipient");
            }
        }
Ejemplo n.º 2
0
        public async Task <TransactionListReply> GetBlockchainTransactions(Account account, DateTime?timeStamp = null,
                                                                           TransactionSubType?transactionType  = null, int?firstIndex   = null, int?lastIndex             = null,
                                                                           int?numberOfConfirmations           = null, bool?withMessage = null, bool?phasedOnly           = null,
                                                                           bool?nonPhasedOnly = null, bool?includeExpiredPrunable       = null, bool?includePhasingResult = null,
                                                                           bool?executedOnly  = null, ulong?requireBlock = null, ulong?requireLastBlock                   = null)
        {
            var queryParameters = new Dictionary <string, string> {
                { Parameters.Account, account.AccountId.ToString() }
            };

            if (transactionType.HasValue)
            {
                queryParameters.Add(Parameters.Type, TransactionTypeMapper.GetMainTypeByte(transactionType.Value).ToString());
                queryParameters.Add(Parameters.SubType, TransactionTypeMapper.GetSubTypeByte(transactionType.Value).ToString());
            }
            queryParameters.AddIfHasValue(Parameters.Timestamp, timeStamp);
            queryParameters.AddIfHasValue(Parameters.FirstIndex, firstIndex);
            queryParameters.AddIfHasValue(Parameters.LastIndex, lastIndex);
            queryParameters.AddIfHasValue(Parameters.NumberOfConfirmations, numberOfConfirmations);
            queryParameters.AddIfHasValue(Parameters.WithMessage, withMessage);
            queryParameters.AddIfHasValue(Parameters.PhasedOnly, phasedOnly);
            queryParameters.AddIfHasValue(Parameters.NonPhasedOnly, nonPhasedOnly);
            queryParameters.AddIfHasValue(Parameters.IncludeExpiredPrunable, includeExpiredPrunable);
            queryParameters.AddIfHasValue(Parameters.IncludePhasingResult, includePhasingResult);
            queryParameters.AddIfHasValue(Parameters.ExecutedOnly, executedOnly);
            queryParameters.AddIfHasValue(Parameters.RequireBlock, requireBlock);
            queryParameters.AddIfHasValue(Parameters.RequireLastBlock, requireLastBlock);
            return(await Get <TransactionListReply>("getBlockchainTransactions", queryParameters));
        }
Ejemplo n.º 3
0
        private static JObject BuildSignedTransaction(Transaction transaction, string referencedTransactionFullHash,
                                                      BinaryHexString signature, JToken attachment)
        {
            var resultJson = new JObject();

            resultJson.Add(Parameters.Type, (int)TransactionTypeMapper.GetMainTypeByte(transaction.Type));
            resultJson.Add(Parameters.SubType, (int)TransactionTypeMapper.GetSubTypeByte(transaction.SubType));
            resultJson.Add(Parameters.Timestamp, new DateTimeConverter().GetNxtTimestamp(transaction.Timestamp));
            resultJson.Add(Parameters.Deadline, transaction.Deadline);
            resultJson.Add(Parameters.SenderPublicKey, transaction.SenderPublicKey.ToHexString());
            resultJson.Add(Parameters.AmountNqt, transaction.Amount.Nqt.ToString());
            resultJson.Add(Parameters.FeeNqt, transaction.Fee.Nqt.ToString());
            if (!string.IsNullOrEmpty(referencedTransactionFullHash))
            {
                resultJson.Add(Parameters.ReferencedTransactionFullHash, referencedTransactionFullHash);
            }
            resultJson.Add(Parameters.Signature, signature.ToHexString());
            resultJson.Add(Parameters.Version, transaction.Version);
            if (attachment != null && attachment.Children().Any())
            {
                resultJson.Add(Parameters.Attachment, attachment);
            }
            resultJson.Add(Parameters.EcBlockHeight, transaction.EcBlockHeight);
            resultJson.Add(Parameters.EcBlockId, transaction.EcBlockId.ToString());
            if (transaction.Recipient.HasValue)
            {
                resultJson.Add(Parameters.Recipient, transaction.Recipient.ToString());
            }
            return(resultJson);
        }