Esempio n. 1
0
        public override DictionaryObject GetJson()
        {
            var result = new DictionaryObject
            {
                { "type", (byte)TransactionType.Transfer },
                { "senderPublicKey", SenderPublicKey.ToBase58() },
                { "recipient", Recipient },
                { "amount", Asset.AmountToLong(Amount) },
                { "assetId", Asset.IdOrNull },
                { "fee", FeeAsset.AmountToLong(Fee) },
                { "feeAsset", FeeAsset.IdOrNull },  // legacy v0.11.1 compat
                { "feeAssetId", FeeAsset.IdOrNull },
                { "timestamp", Timestamp.ToLong() },
                { "attachment", Attachment.ToBase58() }
            };

            if (Version > 1)
            {
                result.Add("version", Version);
            }

            if (Sender != null)
            {
                result.Add("sender", Sender);
            }

            return(result);
        }
Esempio n. 2
0
        public byte[] GetBytes(bool skipSignature = false)
        {
            int assetSize = 0;

            using (MemoryStream stream = new MemoryStream())
            {
                using (BinaryWriter writer = new BinaryWriter(stream))
                {
                    writer.Write((byte)Type);
                    writer.Write(Timestamp);
                    writer.Write(SenderPublicKey.FromHex());
                    if (RecipientId != null)
                    {
                        var recId = new BigInteger(RecipientId.Replace("L", ""));
                        writer.Write(recId.ToByteArray());
                    }
                    else
                    {
                        writer.Write(new byte[] { 0, 0, 0, 0, 0, 0, 0, 0 });
                    }
                    writer.Write(Amount);
                    if (Asset != null)
                    {
                        writer.Write(Asset.GetBytes());
                    }
                    if (!skipSignature && !string.IsNullOrWhiteSpace(Signature))
                    {
                        writer.Write(Signature.FromHex());
                    }
                }
                return(stream.ToArray());
            }
        }
Esempio n. 3
0
 private String CalulateHash() // TODO replace to GetHashCode()
 {
     return(SHA.ComputeSHA256Hash
            (
                SenderPublicKey.ToString() + ReciepientPublicKey.ToString() + Value
            ));
 }
 public override Dictionary <string, object> GetJson()
 {
     return(new Dictionary <string, object>
     {
         { "type", TransactionType.LeaseCancel },
         { "senderPublicKey", SenderPublicKey.ToBase58() },
         { "leaseId", TransactionId },
         { "fee", Assets.TN.AmountToLong(Fee) },
         { "timestamp", Timestamp.ToLong() }
     });
 }
Esempio n. 5
0
 public override Dictionary <string, object> GetJson()
 {
     return(new Dictionary <string, object>
     {
         { "type", TransactionType.Alias },
         { "senderPublicKey", SenderPublicKey.ToBase58() },
         { "alias", Alias },
         { "fee", Assets.WAVES.AmountToLong(Fee) },
         { "timestamp", Timestamp.ToLong() }
     });
 }
Esempio n. 6
0
 public override Dictionary <string, object> GetJson()
 {
     return(new Dictionary <string, object> {
         { "type", TransactionType.Lease },
         { "senderPublicKey", SenderPublicKey.ToBase58() },
         { "recipient", Recipient },
         { "amount", Assets.TN.AmountToLong(Amount) },
         { "fee", Assets.TN.AmountToLong(Fee) },
         { "timestamp", Timestamp.ToLong() }
     });
 }
Esempio n. 7
0
 public override Dictionary <string, object> GetJson()
 {
     return(new Dictionary <string, object>
     {
         { "type", TransactionType.Burn },
         { "senderPublicKey", SenderPublicKey.ToBase58() },
         { "assetId", Asset.Id },
         { "quantity", Asset.AmountToLong(Quantity) },
         { "fee", Assets.TN.AmountToLong(Fee) },
         { "timestamp", Timestamp.ToLong() }
     });
 }
Esempio n. 8
0
 public override Dictionary <string, object> GetJson()
 {
     return(new Dictionary <string, object>
     {
         { "type", TransactionType.SetScript },
         { "version", Version },
         { "senderPublicKey", SenderPublicKey.ToBase58() },
         { "script", Script == null ? null : Script.ToBase64() },
         { "fee", Assets.WAVES.AmountToLong(Fee) },
         { "timestamp", Timestamp.ToLong() }
     });
 }
        public override DictionaryObject GetJson()
        {
            var result = new DictionaryObject
            {
                {"type", (byte) TransactionType.Burn},
                {"senderPublicKey", SenderPublicKey.ToBase58()},
                {"assetId", Asset.Id},
                {"amount", Asset.AmountToLong(Quantity)},
                {"fee", Assets.WAVES.AmountToLong(Fee)},
                {"timestamp", Timestamp.ToLong()}
            };

            if (Sender != null)
                result.Add("sender", Sender);

            return result;
        }
Esempio n. 10
0
        public override DictionaryObject GetJson()
        {
            var result = new DictionaryObject
            {
                { "type", (byte)TransactionType.LeaseCancel },
                { "senderPublicKey", SenderPublicKey.ToBase58() },
                { "leaseId", LeaseId },
                { "fee", Assets.ZBS.AmountToLong(Fee) },
                { "timestamp", Timestamp.ToLong() }
            };

            if (Sender != null)
            {
                result.Add("sender", Sender);
            }

            return(result);
        }
Esempio n. 11
0
        public override DictionaryObject GetJson()
        {
            var result = new DictionaryObject {
                { "type", (byte)TransactionType.Lease },
                { "senderPublicKey", SenderPublicKey.ToBase58() },
                { "recipient", Recipient },
                { "amount", Assets.WAVES.AmountToLong(Amount) },
                { "fee", Assets.WAVES.AmountToLong(Fee) },
                { "timestamp", Timestamp.ToLong() }
            };

            if (Sender != null)
            {
                result.Add("sender", Sender);
            }

            return(result);
        }
Esempio n. 12
0
        public override DictionaryObject GetJson()
        {
            var result = new DictionaryObject
            {
                { "type", (byte)TransactionType.Alias },
                { "senderPublicKey", SenderPublicKey.ToBase58() },
                { "alias", Alias },
                { "fee", Assets.ZBS.AmountToLong(Fee) },
                { "timestamp", Timestamp.ToLong() }
            };

            if (Sender != null)
            {
                result.Add("sender", AddressEncoding.GetAddressFromPublicKey(SenderPublicKey, ChainId));
            }

            return(result);
        }
Esempio n. 13
0
        public DictionaryObject GetJson()
        {
            var json = new DictionaryObject
            {
                { "amount", AmountAsset.AmountToLong(Amount) },
                { "price", Asset.PriceToLong(AmountAsset, PriceAsset, Price) },
                { "timestamp", Timestamp.ToLong() },
                { "expiration", Expiration.ToLong() },
                { "senderPublicKey", SenderPublicKey.ToBase58() },
                { "matcherPublicKey", MatcherPublicKey.ToBase58() },
                { "matcherFee", Assets.BCT.AmountToLong(MatcherFee) },
                { "assetPair", new DictionaryObject
                  {
                      { "amountAsset", AmountAsset.IdOrNull },
                      { "priceAsset", PriceAsset.IdOrNull }
                  } },
                { "orderType", Side.ToString().ToLower() },
                { "version", Version }
            };

            var proofs = Proofs
                         .Take(Array.FindLastIndex(Proofs, p => p != null && p.Length > 0) + 1)
                         .Select(p => p == null ? "" : p.ToBase58())
                         .ToArray();

            if (SupportsProofs())
            {
                json.Add("proofs", proofs);
            }
            else
            {
                if (proofs.Length == 0)
                {
                    throw new InvalidOperationException("Order is not signed");
                }
                if (proofs.Length > 1)
                {
                    throw new InvalidOperationException("Order version doesn't support multiple proofs");
                }
                json.Add("signature", proofs.Single());
            }

            return(json);
        }
Esempio n. 14
0
        public override DictionaryObject GetJson()
        {
            var result = new DictionaryObject
            {
                { "type", (byte)TransactionType.SetScript },
                { "version", Version },
                { "senderPublicKey", SenderPublicKey.ToBase58() },
                { "script", Script?.ToBase64() },
                { "fee", Assets.WAVES.AmountToLong(Fee) },
                { "timestamp", Timestamp.ToLong() }
            };

            if (Sender != null)
            {
                result.Add("sender", Sender);
            }

            return(result);
        }
Esempio n. 15
0
        public override DictionaryObject GetJson()
        {
            var result = new DictionaryObject
            {
                { "type", (byte)TransactionType.Reissue },
                { "senderPublicKey", SenderPublicKey.ToBase58() },
                { "assetId", Asset.Id },
                { "quantity", Asset.AmountToLong(Quantity) },
                { "reissuable", Reissuable },
                { "fee", Assets.ZBS.AmountToLong(Fee) },
                { "timestamp", Timestamp.ToLong() }
            };

            if (Sender != null)
            {
                result.Add("sender", Sender);
            }

            return(result);
        }
Esempio n. 16
0
 public DictionaryObject GetJson()
 {
     return(new DictionaryObject
     {
         { "amount", AmountAsset.AmountToLong(Amount) },
         { "price", Asset.PriceToLong(AmountAsset, PriceAsset, Price) },
         { "timestamp", Timestamp.ToLong() },
         { "expiration", Expiration.ToLong() },
         { "senderPublicKey", SenderPublicKey.ToBase58() },
         { "matcherPublicKey", MatcherPublicKey.ToBase58() },
         { "matcherFee", Assets.ZBS.AmountToLong(MatcherFee) },
         { "assetPair", new DictionaryObject
           {
               { "amountAsset", AmountAsset.IdOrNull },
               { "priceAsset", PriceAsset.IdOrNull }
           } },
         { "orderType", Side.ToString().ToLower() },
         { "signature", Signature.ToBase58() },
         { "version", Version }
     });
 }
Esempio n. 17
0
        public override Dictionary <string, object> GetJson()
        {
            var result = new Dictionary <string, object>
            {
                { "type", TransactionType.Transfer },
                { "senderPublicKey", SenderPublicKey.ToBase58() },
                { "recipient", Recipient },
                { "amount", Asset.AmountToLong(Amount) },
                { "assetId", Asset.IdOrNull },
                { "fee", FeeAsset.AmountToLong(Fee) },
                { "feeAssetId", FeeAsset.IdOrNull },
                { "timestamp", Timestamp.ToLong() },
                { "attachment", Attachment.ToBase58() }
            };

            if (Version > 1)
            {
                result.Add("version", Version);
            }
            return(result);
        }
Esempio n. 18
0
        public byte[] GetBytes()
        {
            using (MemoryStream stream = new MemoryStream())
            {
                using (BinaryWriter writer = new BinaryWriter(stream))
                {
                    writer.Write((byte)Type);
                    writer.Write(Timestamp);
                    writer.Write(SenderPublicKey.FromHex());

                    if (!string.IsNullOrWhiteSpace(RecipientId))
                    {
                        var recId = new BigInteger(RecipientId.Replace(Constants.AddressSuffix, ""));
                        writer.Write(recId.ToByteArray());
                    }
                    else
                    {
                        writer.Write(new byte[] { 0, 0, 0, 0, 0, 0, 0, 0 });
                    }

                    writer.Write(Amount);

                    if (Asset != null)
                    {
                        writer.Write(Asset.GetBytes());
                    }

                    if (!string.IsNullOrWhiteSpace(Signature))
                    {
                        writer.Write(Signature.FromHex());
                    }

                    if (!string.IsNullOrWhiteSpace(SignSignature))
                    {
                        writer.Write(Signature.FromHex());
                    }
                }
                return(stream.ToArray());
            }
        }
Esempio n. 19
0
        public override DictionaryObject GetJson()
        {
            var result = new DictionaryObject
            {
                {"version", Version },
                {"type", (byte) TransactionType.Exchange},
                {"senderPublicKey", SenderPublicKey.ToBase58() },
                {"fee", Assets.WAVES.AmountToLong(Fee)},
                {"timestamp", Timestamp.ToLong()},
                {"order1", BuyOrder.GetJson()},
                {"order2", SellOrder.GetJson()},
                {"price", Asset.PriceToLong(AmountAsset, PriceAsset, Price) },
                {"amount", AmountAsset.AmountToLong(Amount) },
                {"buyMatcherFee", Assets.WAVES.AmountToLong(BuyMatcherFee)},
                {"sellMatcherFee", Assets.WAVES.AmountToLong(SellMatcherFee)}
            };

            if (Sender != null)
                result.Add("sender", Sender);

            return result;
        }