private static void PutAsset(MemoryStream stream, String assetId) { if (assetId == null || assetId == string.Empty) { stream.WriteByte((byte)0); } else { stream.WriteByte((byte)1); var decoded = Base58.Decode(assetId); stream.Write(decoded, 0, decoded.Length); } }
public static void WriteAsset(this BinaryWriter stream, string assetId) { if (string.IsNullOrEmpty(assetId) || assetId == "WAVES") { stream.WriteByte(0); } else { stream.WriteByte(1); var decoded = Base58.Decode(assetId); stream.Write(decoded, 0, decoded.Length); } }
public static DictionaryObject MakeOrderCancelRequest(PrivateKeyAccount sender, string orderId) { var stream = new MemoryStream(); var writer = new BinaryWriter(stream); writer.Write(sender.PublicKey); writer.Write(Base58.Decode(orderId)); var signature = sender.Sign(stream); return(new DictionaryObject { { "sender", sender.PublicKey.ToBase58() }, { "orderId", orderId }, { "signature", signature.ToBase58() } }); }
//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 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 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() } }); }
private PrivateKeyAccount(string privateKey, char scheme) : this(Base58.Decode(privateKey), scheme) { }
private PrivateKeyAccount(string privateKey, char chainId) : this(Base58.Decode(privateKey), chainId) { }