Example #1
0
        public String CreateOrder(PrivateKeyAccount account, String matcherKey, String amountAssetId, String priceAssetId,
                                  Order.Type orderType, long price, long amount, long expiration, long matcherFee)
        {
            Transaction transaction = Transaction.MakeOrderTransaction(account, matcherKey, orderType,
                                                                       amountAssetId, priceAssetId, price, amount, expiration, matcherFee);

            return(Request(transaction, false));
        }
Example #2
0
        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));
        }