internal TransactionInfo CreateTransactionInfo(JObject jsonObject) { jsonObject = jsonObject["meta"].ToObject <JObject>(); if (jsonObject["hash"] != null && jsonObject["id"] != null) { return(TransactionInfo.Create(ExtractBigInteger(jsonObject, "height"), Int32.Parse(jsonObject["index"].ToString()), jsonObject["id"].ToString(), jsonObject["hash"].ToString(), jsonObject["merkleComponentHash"].ToString())); } if (jsonObject["aggregateHash"] != null && jsonObject["id"] != null) { return(TransactionInfo.CreateAggregate(ExtractBigInteger( jsonObject, "height"), Int32.Parse(jsonObject["index"].ToString()), jsonObject["id"].ToString(), jsonObject["aggregateHash"].ToString(), jsonObject["aggregateId"].ToString())); } return(TransactionInfo.Create(ExtractBigInteger(jsonObject, "height"), jsonObject["hash"].ToString(), jsonObject["merkleComponentHash"].ToString())); }
public new ModifyMultisigAccountTransaction Apply(string input) { var tx = JsonConvert.DeserializeObject <MultisigModificationTransactionInfoDTO>(input); var txInfo = TransactionInfo.Create(tx.Meta.Height, tx.Meta.Index, tx.Meta.Id, tx.Meta.Hash, tx.Meta.MerkleComponentHash); var deadline = new Deadline(tx.Transaction.Deadline); List <MultisigCosignatoryModification> modifications = tx.Transaction.Modifications != null ? tx .Transaction.Modifications .Select(e => new MultisigCosignatoryModification( MultisigCosignatoryModificationType.GetRawValue(e.Type), new PublicAccount(e.CosignatoryPublicKey, ExtractNetworkType(tx.Transaction.Version)) ) ).ToList() : new List <MultisigCosignatoryModification>(); return(new ModifyMultisigAccountTransaction( ExtractNetworkType(tx.Transaction.Version), 3, deadline, tx.Transaction.Fee, tx.Transaction.MinApprovalDelta, tx.Transaction.MinRemovalDelta, modifications, tx.Transaction.Signature, new PublicAccount(tx.Transaction.Signer, ExtractNetworkType(tx.Transaction.Version)), txInfo )); }
internal new MosaicDefinitionTransaction Apply(string input) { var tx = JsonConvert.DeserializeObject <MosaicCreationTransactionInfoDTO>(input); var transaction = tx.Transaction; var mosaicProperties = tx.Transaction.Properties; var flags = "00" + Convert.ToString((long)mosaicProperties[0].value, 2); var bitMapFlags = flags.Substring(flags.Length - 3, 3); var properties = new MosaicProperties(bitMapFlags.ToCharArray()[2] == '1', bitMapFlags.ToCharArray()[1] == '1', bitMapFlags.ToCharArray()[0] == '1', (int)mosaicProperties[1].value, mosaicProperties.Count == 3 ? mosaicProperties[2].value : 0); return(new MosaicDefinitionTransaction( ExtractNetworkType(tx.Transaction.Version), ExtractTransactionVersion(tx.Transaction.Version), new Deadline(tx.Transaction.Deadline), transaction.Fee, transaction.Name, new NamespaceId(transaction.ParentId), new MosaicId(transaction.MosaicId), properties, transaction.Signature, new PublicAccount(transaction.Signer, ExtractNetworkType(tx.Transaction.Version)), TransactionInfo.Create(tx.Meta.Height, tx.Meta.Index, tx.Meta.Id, tx.Meta.Hash, tx.Meta.MerkleComponentHash) )); }
/// <summary> /// Create transaction info based on the provided transaction meta json object /// </summary> /// <param name="jsonObject">The json object</param> /// <returns>TransactionInfo</returns> public static TransactionInfo CreateTransactionInfo(JObject jsonObject) { var meta = jsonObject["meta"].ToObject <JObject>(); var heightOjb = meta["height"].ToObject <UInt64DTO>().ToUInt64(); var indexObj = meta["index"]?.ToObject <int>(); //standard transaction info based on hash + id if (meta.ContainsKey("hash") && meta.ContainsKey("id")) { return(TransactionInfo.Create(heightOjb, indexObj, meta["id"].ToObject <string>(), meta["hash"].ToObject <string>(), meta["merkleComponentHash"].ToObject <string>() )); } // aggregateHash and id indicate aggregate transaction if (meta.ContainsKey("aggregateHash") && meta.ContainsKey("id")) { return(TransactionInfo.CreateAggregate(heightOjb, indexObj, meta["id"].ToObject <string>(), meta["aggregateHash"].ToObject <string>(), meta["aggregateId"].ToObject <string>() )); } // missing id return(TransactionInfo.Create(heightOjb, meta["hash"].ToObject <string>(), meta["merkleComponentHash"].ToObject <string>())); }
public void CreateATransactionInfoWithStaticConstructorCreateForStandaloneTransactions() { TransactionInfo transactionInfo = TransactionInfo.Create(121855, 1, "B6C7648A3DDF71415650805E9E7801424FE03BBEE7D21F9C57B60220D3E95B2F"); Assert.AreEqual((ulong)121855, transactionInfo.Height); Assert.IsTrue(transactionInfo.Hash == "B6C7648A3DDF71415650805E9E7801424FE03BBEE7D21F9C57B60220D3E95B2F"); Assert.IsTrue(transactionInfo.Id == 1); Assert.IsNull(transactionInfo.InnerHash); }
protected TransactionInfo CreateTransactionInfo(JObject metaJsonObject) { if (metaJsonObject["innerHash"].ToString() == "{}") // Not a Multisig { return(TransactionInfo.Create(ulong.Parse(metaJsonObject["height"].ToString()), int.Parse(metaJsonObject["id"].ToString()), metaJsonObject["hash"]["data"].ToString())); } return(TransactionInfo.CreateMultisig(ulong.Parse(metaJsonObject["height"].ToString()), int.Parse(metaJsonObject["id"].ToString()), metaJsonObject["hash"]["data"].ToString(), metaJsonObject["innerHash"]["data"].ToString())); }
public void CreateATransactionInfoWithStaticConstructorCreateForTransactionsGetUsingListener() { TransactionInfo transactionInfo = TransactionInfo.Create(121855, "B6C7648A3DDF71415650805E9E7801424FE03BBEE7D21F9C57B60220D3E95B2F", "B6C7648A3DDF71415650805E9E7801424FE03BBEE7D21F9C57B60220D3E95B2F"); Assert.AreEqual((ulong)121855, transactionInfo.Height); Assert.IsFalse(transactionInfo.Index.HasValue); Assert.IsNull(transactionInfo.Id); Assert.IsNull(transactionInfo.AggregateHash); Assert.IsNull(transactionInfo.AggregateId); Assert.IsNotNull(transactionInfo.Hash); Assert.IsNotNull(transactionInfo.MerkleComponentHash); Assert.AreEqual("B6C7648A3DDF71415650805E9E7801424FE03BBEE7D21F9C57B60220D3E95B2F", transactionInfo.Hash); Assert.AreEqual("B6C7648A3DDF71415650805E9E7801424FE03BBEE7D21F9C57B60220D3E95B2F", transactionInfo.MerkleComponentHash); }
public void CreateATransactionInfoWithStaticConstructorCreateForStandaloneTransactions() { TransactionInfo transactionInfo = TransactionInfo.Create(121855, 1, "5A3D23889CD1E800015929A9", "B6C7648A3DDF71415650805E9E7801424FE03BBEE7D21F9C57B60220D3E95B2F", "B6C7648A3DDF71415650805E9E7801424FE03BBEE7D21F9C57B60220D3E95B2F"); Assert.AreEqual((ulong)121855, transactionInfo.Height); Assert.IsNotNull(transactionInfo.Index); Assert.IsNotNull(transactionInfo.Id); Assert.IsNull(transactionInfo.AggregateHash); Assert.IsNull(transactionInfo.AggregateId); Assert.IsNotNull(transactionInfo.Hash); Assert.IsNotNull(transactionInfo.MerkleComponentHash); Assert.IsNotNull(1 == transactionInfo.Index); Assert.AreEqual("5A3D23889CD1E800015929A9", transactionInfo.Id); Assert.AreEqual("B6C7648A3DDF71415650805E9E7801424FE03BBEE7D21F9C57B60220D3E95B2F", transactionInfo.Hash); Assert.AreEqual("B6C7648A3DDF71415650805E9E7801424FE03BBEE7D21F9C57B60220D3E95B2F", transactionInfo.MerkleComponentHash); }
protected TransactionInfo CreateTransactionInfo(JObject jsonObject) { var metaJsonObject = jsonObject["meta"].ToObject <JObject>(); if (metaJsonObject["hash"] != null && metaJsonObject["id"] != null && metaJsonObject["innerHash"].ToString() == "{}") { return(TransactionInfo.Create(ulong.Parse(metaJsonObject["height"].ToString()), int.Parse(metaJsonObject["id"].ToString()), metaJsonObject["hash"]["data"].ToString(), int.Parse(jsonObject["transaction"]["timeStamp"].ToString()))); } return(TransactionInfo.CreateMultisig(ulong.Parse(metaJsonObject["height"].ToString()), int.Parse(metaJsonObject["id"].ToString()), metaJsonObject["hash"]["data"].ToString(), int.Parse(jsonObject["transaction"]["timeStamp"].ToString()), metaJsonObject["innerHash"]["data"].ToString())); }
public new SecretProofTransaction Apply(string input) { var tx = JsonConvert.DeserializeObject <SecretProofTransactionInfoDTO>(input); var transactionInfo = TransactionInfo.Create(tx.Meta.Height, tx.Meta.Index, tx.Meta.Id, tx.Meta.Hash, tx.Meta.MerkleComponentHash); var transaction = tx.Transaction; return(new SecretProofTransaction( ExtractNetworkType(tx.Transaction.Version), ExtractTransactionVersion(tx.Transaction.Version), new Deadline(transaction.Deadline), transaction.Fee, HashType.GetRawValue(transaction.HashAlgorithm), transaction.Secret, transaction.Proof, transaction.Signature, new PublicAccount(transaction.Signer, ExtractNetworkType(tx.Transaction.Version)), transactionInfo )); }
internal new MosaicSupplyChangeTransaction Apply(string input) { var tx = JsonConvert.DeserializeObject <MosaicSupplyChangeTransactionInfoDTO>(input); var transactionInfo = TransactionInfo.Create(tx.Meta.Height, tx.Meta.Index, tx.Meta.Id, tx.Meta.Hash, tx.Meta.MerkleComponentHash); var transaction = tx.Transaction; return(new MosaicSupplyChangeTransaction( ExtractNetworkType(tx.Transaction.Version), ExtractTransactionVersion(tx.Transaction.Version), new Deadline(transaction.Deadline), transaction.Fee, new MosaicId(transaction.MosaicId), MosaicSupplyType.GetRawValue(transaction.Direction), transaction.Delta, transaction.Signature, new PublicAccount(transaction.Signer, ExtractNetworkType(tx.Transaction.Version)), transactionInfo )); }
public new RegisterNamespaceTransaction Apply(string input) { var tx = JsonConvert.DeserializeObject <NamespaceTransactionInfoDTO>(input); var transactionInfo = TransactionInfo.Create(tx.Meta.Height, tx.Meta.Index, tx.Meta.Id, tx.Meta.Hash, tx.Meta.MerkleComponentHash); var namespaceType = NamespaceTypes.GetRawValue(tx.Transaction.NamespaceType); return(new RegisterNamespaceTransaction( ExtractNetworkType(tx.Transaction.Version), ExtractTransactionVersion(tx.Transaction.Version), new Deadline(tx.Transaction.Deadline), tx.Transaction.Fee, tx.Transaction.NamespaceType, namespaceType == NamespaceTypes.Types.RootNamespace ? tx.Transaction.Duration : 0, namespaceType == NamespaceTypes.Types.SubNamespace ? new NamespaceId(tx.Transaction.ParentId) : null, new NamespaceId(tx.Transaction.Name), new PublicAccount(tx.Transaction.Signer, ExtractNetworkType(tx.Transaction.Version)), tx.Transaction.Signature, transactionInfo )); }
public new LockFundsTransaction Apply(string input) { var tx = JsonConvert.DeserializeObject <LockFundsTransactionInfoDTO>(input); var transactionInfo = TransactionInfo.Create(tx.Meta.Height, tx.Meta.Index, tx.Meta.Id, tx.Meta.Hash, tx.Meta.MerkleComponentHash); var transaction = tx.Transaction; var mosaic = new Mosaic(new MosaicId(transaction.MosaicId), transaction.Amount); return(new LockFundsTransaction( ExtractNetworkType(tx.Transaction.Version), ExtractTransactionVersion(tx.Transaction.Version), new Deadline(transaction.Deadline), transaction.Fee, mosaic, transaction.Duration, new SignedTransaction("", transaction.Hash, "", TransactionTypes.Types.AggregateBonded), transaction.Signature, new PublicAccount(transaction.Signer, ExtractNetworkType(tx.Transaction.Version)), transactionInfo )); }
internal new TransferTransaction Apply(string input) { var tx = JsonConvert.DeserializeObject <TransferTransactionInfoDTO>(input); var txInfo = TransactionInfo.Create(tx.Meta.Height, tx.Meta.Index, tx.Meta.Id, tx.Meta.Hash, tx.Meta.MerkleComponentHash); var deadline = new Deadline(tx.Transaction.Deadline); var mosaics = tx.Transaction.Mosaics.Select(m => new Mosaic(new MosaicId(BitConverter.ToUInt64(m.MosaicId.FromHex(), 0)), m.Amount)).ToList(); IMessage message; try { message = PlainMessage.Create(Encoding.UTF8.GetString(tx.Transaction.Message.Payload.FromHex())); } catch (Exception) { try { message = PlainMessage.Create(tx.Transaction.Message.Payload); } catch (Exception) { message = EmptyMessage.Create(); } } return(new TransferTransaction( ExtractNetworkType(tx.Transaction.Version), ExtractTransactionVersion(tx.Transaction.Version), deadline, tx.Transaction.Fee, Address.CreateFromEncoded(tx.Transaction.Recipient), mosaics, message, tx.Transaction.Signature, new PublicAccount(tx.Transaction.Signer, ExtractNetworkType(tx.Transaction.Version)), txInfo )); }
internal new SecretLockTransaction Apply(string input) { var tx = JsonConvert.DeserializeObject <SecretLockTransactionInfoDTO>(input); var transactionInfo = TransactionInfo.Create(tx.Meta.Height, tx.Meta.Index, tx.Meta.Id, tx.Meta.Hash, tx.Meta.MerkleComponentHash); var transaction = tx.Transaction; var mosaic = new Mosaic(new MosaicId(transaction.MosaicId), transaction.Amount); return(new SecretLockTransaction( ExtractNetworkType(tx.Transaction.Version), ExtractTransactionVersion(tx.Transaction.Version), new Deadline(transaction.Deadline), transaction.Fee, mosaic, transaction.Duration, HashType.GetRawValue(transaction.HashAlgorithm), transaction.Secret, Address.CreateFromHex(transaction.Recipient), transaction.Signature, new PublicAccount(transaction.Signer, ExtractNetworkType(tx.Transaction.Version)), transactionInfo )); }