public static Transaction MakeReissueTransaction(PrivateKeyAccount account, String assetId, long quantity, bool reissuable, long fee) { long timestamp = Utils.CurrentTimestamp(); MemoryStream stream = new MemoryStream(MinBufferSize); BinaryWriter writer = new BinaryWriter(stream); writer.Write(Reissue); writer.Write(account.PublicKey); writer.Write(Base58.Decode(assetId)); Utils.WriteToNetwork(writer, quantity); writer.Write((byte)(reissuable ? 1 : 0)); Utils.WriteToNetwork(writer, fee); Utils.WriteToNetwork(writer, timestamp); String signature = Sign(account, stream); return(new Transaction(TransactionsBroadcastPath, "type", Reissue, "senderPublicKey", Base58.Encode(account.PublicKey), "signature", signature, "assetId", assetId, "quantity", quantity, "reissuable", reissuable, "fee", fee, "timestamp", timestamp)); }
public static String Sign(PrivateKeyAccount account, MemoryStream stream) { byte[] bytesToSign = new byte[stream.Position]; bytesToSign = stream.ToArray(); byte[] signature = cipher.calculateSignature(account.PrivateKey, bytesToSign); return(Base58.Encode(signature)); }
public override DictionaryObject GetJson() { var result = new DictionaryObject { { "type", (byte)TransactionType.MassTransfer }, { "version", Version }, { "senderPublicKey", Base58.Encode(SenderPublicKey) }, { "transfers", Transfers.Select(t => new DictionaryObject() { { "recipient", t.Recipient }, { "amount", Asset.AmountToLong(t.Amount) } }).ToArray() }, { "assetId", Asset.IdOrNull }, { "fee", Assets.WAVES.AmountToLong(Fee) }, { "timestamp", Timestamp.ToLong() }, { "attachment", Attachment.ToBase58() } }; if (Sender != null) { result.Add("sender", Sender); } return(result); }
public override DictionaryObject GetJson() { var result = new DictionaryObject { { "type", (byte)TransactionType.Issue }, { "senderPublicKey", Base58.Encode(SenderPublicKey) }, { "name", Name }, { "description", Description }, { "quantity", Asset.AmountToLong(Quantity) }, { "decimals", Decimals }, { "reissuable", Reissuable }, { "fee", Assets.WAVES.AmountToLong(Fee) }, { "timestamp", Timestamp.ToLong() }, { "script", Script?.ToBase64() } }; if (Version > 1) { result.Add("version", Version); } if (Sender != null) { result.Add("sender", Sender); } return(result); }
public static Transaction MakeAliasTransaction(PrivateKeyAccount account, String alias, char scheme, long fee) { long timestamp = Utils.CurrentTimestamp(); int aliaslen = alias.Length; MemoryStream stream = new MemoryStream(MinBufferSize + aliaslen); BinaryWriter writer = new BinaryWriter(stream); writer.Write(Transaction.Alias); writer.Write(account.PublicKey); Utils.WriteBigEndian(writer, (short)(alias.Length + 4)); writer.Write(0x02); writer.Write((byte)scheme); Utils.WriteBigEndian(writer, (short)alias.Length); writer.Write(Encoding.ASCII.GetBytes(alias)); Utils.WriteToNetwork(writer, fee); Utils.WriteToNetwork(writer, timestamp); String signature = Sign(account, stream); return(new Transaction(TransactionsBroadcastPath, "type", Alias, "senderPublicKey", Base58.Encode(account.PublicKey), "signature", signature, "alias", alias, "fee", fee, "timestamp", timestamp)); }
public override Dictionary <string, object> GetJson() => new Dictionary <string, object> { { "type", TransactionType.SponsoredFee }, { "version", Version }, { "senderPublicKey", Base58.Encode(SenderPublicKey) }, { "assetId", Asset.IdOrNull }, { "fee", Assets.WAVES.AmountToLong(Fee) }, { "timestamp", Timestamp.ToLong() }, { "minSponsoredAssetFee", Asset.AmountToLong(MinimalFeeInAssets) } };
public static string GetAddressFromPublicKey(byte[] publicKey, char chainId) { var stream = new MemoryStream(26); var hash = SecureHash(publicKey, 0, publicKey.Length); var writer = new BinaryWriter(stream); writer.Write((byte)1); writer.Write((byte)chainId); writer.Write(hash, 0, 20); var checksum = SecureHash(stream.ToArray(), 0, 22); writer.Write(checksum, 0, 4); return(Base58.Encode(stream.ToArray())); }
public String GetOrders(PrivateKeyAccount account) { long timestamp = Utils.CurrentTimestamp(); MemoryStream stream = new MemoryStream(40); BinaryWriter writer = new BinaryWriter(stream); writer.Write(account.PublicKey); Utils.WriteToNetwork(writer, timestamp); String signature = Transaction.Sign(account, stream); String path = OrderBook.BasePath + Base58.Encode(account.PublicKey); String json = Request <String>(path, "Timestamp", Convert.ToString(timestamp), "Signature", signature); return(json); }
public override Dictionary <string, object> GetJson() { return(new Dictionary <string, object> { { "type", TransactionType.Issue }, { "senderPublicKey", Base58.Encode(SenderPublicKey) }, { "name", Name }, { "description", Description }, { "quantity", Asset.AmountToLong(Quantity) }, { "decimals", Decimals }, { "reissuable", Reissuable }, { "fee", Assets.WAVES.AmountToLong(Fee) }, { "timestamp", Timestamp.ToLong() } }); }
//private static Dictionary<String, String> AssetPair(String amountAssetId, String priceAssetId) //{ // Dictionary<String, String> assetPair = new Dictionary<String, String> // { // ["amountAsset"] = amountAssetId, // ["priceAsset"] = priceAssetId // }; // return assetPair; //} public static Transaction MakeOrderCancelTransaction(PrivateKeyAccount sender, String amountAssetId, String priceAssetId, String orderId, long fee) { MemoryStream stream = new MemoryStream(MinBufferSize); BinaryWriter writer = new BinaryWriter(stream); writer.Write(sender.PublicKey); writer.Write(Base58.Decode(orderId)); String signature = Sign(sender, stream); amountAssetId = NormalizeAsset(amountAssetId); priceAssetId = NormalizeAsset(priceAssetId); return(new Transaction(String.Format("matcher/orderbook/{0}/{1}/cancel", amountAssetId, priceAssetId), "sender", Base58.Encode(sender.PublicKey), "orderId", orderId, "signature", signature)); }
public override Dictionary <string, object> GetJson() { return(new Dictionary <string, object> { { "type", TransactionType.MassTransfer }, { "version", Version }, { "senderPublicKey", Base58.Encode(SenderPublicKey) }, { "transfers", Transfers.Select(t => new Dictionary <string, object>() { { "recipient", t.Recipient }, { "amount", Asset.AmountToLong(t.Amount) } }).ToArray() }, { "assetId", Asset.IdOrNull }, { "fee", Assets.WAVES.AmountToLong(Fee) }, { "timestamp", Timestamp.ToLong() }, { "attachment", Attachment.ToBase58() } }); }
public override DictionaryObject GetJson() { var result = new DictionaryObject { { "type", (byte)TransactionType.SponsoredFee }, { "version", Version }, { "senderPublicKey", Base58.Encode(SenderPublicKey) }, { "assetId", Asset.IdOrNull }, { "fee", Assets.WAVES.AmountToLong(Fee) }, { "timestamp", Timestamp.ToLong() }, { "minSponsoredAssetFee", Asset.AmountToLong(MinimalFeeInAssets) } }; if (Sender != null) { result.Add("sender", Sender); } return(result); }
public static Transaction MakeLeaseCancelTransaction(PrivateKeyAccount account, String TransactionId, long fee) { long timestamp = Utils.CurrentTimestamp(); MemoryStream stream = new MemoryStream(MinBufferSize); BinaryWriter writer = new BinaryWriter(stream); writer.Write(LeaseCancel); writer.Write(account.PublicKey); Utils.WriteToNetwork(writer, fee); Utils.WriteToNetwork(writer, timestamp); writer.Write(Base58.Decode(TransactionId)); String signature = Sign(account, stream); return(new Transaction("leasing/broadcast/cancel", "type", LeaseCancel, "senderPublicKey", Base58.Encode(account.PublicKey), "signature", signature, "TransactionId", TransactionId, "fee", fee, "timestamp", timestamp)); }
public static Transaction MakeOrderTransaction(PrivateKeyAccount sender, String matcherKey, Order.Type orderType, String amountAssetId, String priceAssetId, long price, long amount, long expiration, long matcherFee) { long timestamp = Utils.CurrentTimestamp(); int datalen = MinBufferSize + (amountAssetId == null ? 0 : 32) + (priceAssetId == null ? 0 : 32); if (datalen == MinBufferSize) { throw new ArgumentException("Both spendAsset and receiveAsset are WAVES"); } MemoryStream stream = new MemoryStream(datalen); BinaryWriter writer = new BinaryWriter(stream); writer.Write(sender.PublicKey); writer.Write(Base58.Decode(matcherKey)); PutAsset(stream, amountAssetId); PutAsset(stream, priceAssetId); writer.Write((byte)orderType.Ordinal); Utils.WriteToNetwork(writer, price); Utils.WriteToNetwork(writer, amount); Utils.WriteToNetwork(writer, timestamp); Utils.WriteToNetwork(writer, expiration); Utils.WriteToNetwork(writer, matcherFee); String signature = Sign(sender, stream); return(new Transaction("matcher/orderbook", "senderPublicKey", Base58.Encode(sender.PublicKey), "matcherPublicKey", matcherKey, "assetPair", new AssetPair(amountAssetId, priceAssetId).GetDictionary(), "orderType", orderType.json, "price", price, "amount", amount, "timestamp", timestamp, "expiration", expiration, "matcherFee", matcherFee, "signature", signature)); }
public static Transaction MakeIssueTransaction(PrivateKeyAccount account, String name, String description, long quantity, int decimals, bool reissuable, long fee) { long timestamp = Utils.CurrentTimestamp(); int desclen = description == null ? 0 : description.Length; MemoryStream stream = new MemoryStream(MinBufferSize + name.Length + desclen); BinaryWriter writer = new BinaryWriter(stream); writer.Write(Issue); writer.Write(account.PublicKey); Utils.WriteBigEndian(writer, (short)name.Length); writer.Write(Encoding.ASCII.GetBytes(name)); Utils.WriteBigEndian(writer, (short)desclen); if (desclen > 0) { writer.Write(Encoding.ASCII.GetBytes(description)); } Utils.WriteToNetwork(writer, quantity); writer.Write((byte)decimals); writer.Write((byte)(reissuable ? 1 : 0)); Utils.WriteToNetwork(writer, fee); Utils.WriteToNetwork(writer, timestamp); String signature = Sign(account, stream); return(new Transaction(TransactionsBroadcastPath, "type", Issue, "senderPublicKey", Base58.Encode(account.PublicKey), "signature", signature, "name", name, "description", description, "quantity", quantity, "decimals", decimals, "reissuable", reissuable, "fee", fee, "timestamp", timestamp)); }
public static Transaction MakeLeaseTransaction(PrivateKeyAccount account, String toAddress, long amount, long fee) { long timestamp = Utils.CurrentTimestamp(); MemoryStream stream = new MemoryStream(MinBufferSize); BinaryWriter writer = new BinaryWriter(stream); writer.Write(Lease); writer.Write(account.PublicKey); writer.Write(Base58.Decode(toAddress)); Utils.WriteToNetwork(writer, amount); Utils.WriteToNetwork(writer, fee); Utils.WriteToNetwork(writer, timestamp); String signature = Sign(account, stream); return(new Transaction(TransactionsBroadcastPath, "type", Lease, "senderPublicKey", Base58.Encode(account.PublicKey), "signature", signature, "recipient", toAddress, "amount", amount, "fee", fee, "timestamp", timestamp)); }
public static Transaction MakeTransferTransaction(PrivateKeyAccount account, String toAddress, long amount, String assetId, long fee, String feeAssetId, String attachment) { byte[] attachmentBytes = Encoding.UTF8.GetBytes(attachment == null ? "" : attachment); int datalen = (assetId == null ? 0 : 32) + (feeAssetId == null ? 0 : 32) + attachmentBytes.Length + MinBufferSize; long timestamp = Utils.CurrentTimestamp(); MemoryStream stream = new MemoryStream(datalen); BinaryWriter writer = new BinaryWriter(stream); writer.Write(Transfer); writer.Write(account.PublicKey); PutAsset(stream, assetId); PutAsset(stream, feeAssetId); Utils.WriteToNetwork(writer, timestamp); Utils.WriteToNetwork(writer, amount); Utils.WriteToNetwork(writer, fee); writer.Write(Base58.Decode(toAddress)); //writer.Write((short)attachmentBytes.Length); Utils.WriteBigEndian(writer, (short)attachmentBytes.Length); writer.Write(attachmentBytes); String signature = Sign(account, stream); return(new Transaction(TransactionsBroadcastPath, "type", Transfer, "senderPublicKey", Base58.Encode(account.PublicKey), "signature", signature, "recipient", toAddress, "amount", amount, "assetId", assetId, "fee", fee, "feeAssetId", feeAssetId, "timestamp", timestamp, "attachment", Base58.Encode(attachmentBytes))); }
public static DictionaryObject MakeOrder(PrivateKeyAccount sender, string matcherKey, OrderSide side, Asset amountAsset, Asset priceAsset, decimal price, decimal amount, DateTime expiration, decimal matcherFee) { long timestamp = Utils.CurrentTimestamp(); var stream = new MemoryStream(); var writer = new BinaryWriter(stream); writer.Write(sender.PublicKey); writer.Write(Base58.Decode(matcherKey)); writer.WriteAsset(amountAsset.Id); writer.WriteAsset(priceAsset.Id); writer.Write((byte)(side == OrderSide.Buy ? 0x0 : 0x1)); writer.WriteLong(Asset.PriceToLong(amountAsset, priceAsset, price)); writer.WriteLong(amountAsset.AmountToLong(amount)); writer.WriteLong(timestamp); writer.WriteLong(expiration.ToLong()); writer.WriteLong(Assets.WAVES.AmountToLong(matcherFee)); var signature = sender.Sign(stream); return(new DictionaryObject { { "senderPublicKey", Base58.Encode(sender.PublicKey) }, { "matcherPublicKey", matcherKey }, { "assetPair", new DictionaryObject { { "amountAsset", amountAsset.IdOrNull }, { "priceAsset", priceAsset.IdOrNull } } }, { "orderType", side.ToString().ToLower() }, { "price", Asset.PriceToLong(amountAsset, priceAsset, price) }, { "amount", amountAsset.AmountToLong(amount) }, { "timestamp", timestamp }, { "expiration", expiration.ToLong() }, { "matcherFee", Assets.WAVES.AmountToLong(matcherFee) }, { "signature", signature.ToBase58() } }); }