Пример #1
0
        public String IssueAsset(PrivateKeyAccount account,
                                 String name, String description, long quantity, int decimals, bool reissuable, long fee)
        {
            Transaction transaction = Transaction.MakeIssueTransaction(account, name, description, quantity, decimals, reissuable, fee);

            return(Post(transaction));
        }
Пример #2
0
        public string PutData(PrivateKeyAccount account, DictionaryObject entries, decimal?fee = null)
        {
            var tx = new DataTransaction(ChainId, account.PublicKey, entries, fee);

            tx.Sign(account);
            return(Broadcast(tx));
        }
Пример #3
0
        public string CreateAlias(PrivateKeyAccount account, string alias, char scheme, long fee)
        {
            var tx = new AliasTransaction(account.PublicKey, alias, scheme);

            tx.Sign(account);
            return(Broadcast(tx));
        }
Пример #4
0
        public String TransferAsset(PrivateKeyAccount from, String toAddress,
                                    long amount, String assetId, long fee, String feeAssetId, String message)
        {
            Transaction transaction = Transaction.MakeTransferTransaction(from, toAddress, amount, assetId, fee, feeAssetId, message);

            return(Post(transaction));
        }
Пример #5
0
        public string SponsoredFeeForAsset(PrivateKeyAccount account, Asset asset, decimal minimalFeeInAssets, decimal fee = 1m)
        {
            var tx = new SponsoredFeeTransaction(ChainId, account.PublicKey, asset, minimalFeeInAssets, fee);

            tx.Sign(account);
            return(Broadcast(tx));
        }
Пример #6
0
        public string ReissueAsset(PrivateKeyAccount account, Asset asset, decimal quantity, bool reissuable, decimal fee = 1m)
        {
            var tx = new ReissueTransaction(ChainId, account.PublicKey, asset, quantity, reissuable, fee);

            tx.Sign(account);
            return(Broadcast(tx));
        }
Пример #7
0
        public string Lease(PrivateKeyAccount sender, string recipient, decimal amount, decimal fee = 0.001m)
        {
            var tx = new LeaseTransaction(ChainId, sender.PublicKey, recipient, amount, fee);

            tx.Sign(sender);
            return(Broadcast(tx));
        }
Пример #8
0
        public string PutData(PrivateKeyAccount account, DictionaryObject entries)
        {
            var tx = new DataTransaction(account.PublicKey, entries);

            tx.Sign(account);
            return(Broadcast(tx));
        }
Пример #9
0
        public string CreateAlias(PrivateKeyAccount account, string alias, char chainId, decimal fee = 0.001m)
        {
            var tx = new AliasTransaction(account.PublicKey, alias, chainId, fee);

            tx.Sign(account);
            return(Broadcast(tx));
        }
Пример #10
0
        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));
        }
Пример #11
0
        public void CancelOrder(PrivateKeyAccount account,
                                String amountAssetId, String priceAssetId, String orderId, long fee)
        {
            Transaction transaction = Transaction.MakeOrderCancelTransaction(account, amountAssetId, priceAssetId, orderId, fee);

            Request(transaction, true);
        }
Пример #12
0
        public string BurnAsset(PrivateKeyAccount account, Asset asset, decimal amount, decimal fee = 0.001m)
        {
            var tx = new BurnTransaction(ChainId, account.PublicKey, asset, amount, fee).Sign(account);

            tx.Sign(account);
            return(Broadcast(tx));
        }
Пример #13
0
        public string CancelAll(PrivateKeyAccount account)
        {
            var request = MakeCancelAllRequest(account);
            var url     = $"{_host}/matcher/orderbook/cancel";

            return(Http.Post(url, request));
        }
Пример #14
0
        public string PlaceOrder(PrivateKeyAccount sender, OrderSide side,
                                 Asset amountAsset, Asset priceAsset, decimal price, decimal amount, DateTime expiration)
        {
            var order = MakeOrder(sender, MatcherKey, side, amountAsset, priceAsset, price, amount, expiration, 0.003m);

            return(Http.Post($"{_host}/matcher/orderbook", order));
        }
Пример #15
0
        public string SetAssetScript(PrivateKeyAccount account, Asset asset, byte[] script, char chainId, decimal fee = 1m)
        {
            var tx = new SetAssetScriptTransaction(ChainId, account.PublicKey, asset, script, fee = 1m);

            tx.Sign(account);
            return(Broadcast(tx));
        }
Пример #16
0
        public string SetScript(PrivateKeyAccount account, byte[] script, decimal fee = 1m)
        {
            var tx = new SetScriptTransaction(account.PublicKey, script, ChainId, fee = 0.014m);

            tx.Sign(account);
            return(Broadcast(tx));
        }
Пример #17
0
 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));
 }
Пример #18
0
        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));
        }
Пример #19
0
        public string CancelLease(PrivateKeyAccount account, string transactionId, decimal fee = 0.001m)
        {
            var tx = new CancelLeasingTransaction(ChainId, account.PublicKey, transactionId, fee);

            tx.Sign(account);
            return(Broadcast(tx));
        }
Пример #20
0
        public string CancelLease(PrivateKeyAccount account, string transactionId)
        {
            var tx = new CancelLeasingTransaction(account.PublicKey, transactionId);

            tx.Sign(account);
            return(Broadcast(tx));
        }
Пример #21
0
        public string MassTransfer(PrivateKeyAccount sender, Asset asset, IEnumerable <MassTransferItem> transfers,
                                   string message = "", decimal?fee = null)
        {
            var tx = new MassTransferTransaction(ChainId, sender.PublicKey, asset, transfers, message, fee);

            tx.Sign(sender);
            return(Broadcast(tx));
        }
Пример #22
0
        public string Transfer(PrivateKeyAccount sender, string recipient, Asset asset, decimal amount,
                               decimal fee, Asset feeAsset = null, byte[] message = null)
        {
            var tx = new TransferTransaction(ChainId, sender.PublicKey, recipient, asset, amount, fee, feeAsset, message);

            tx.Sign(sender);
            return(Broadcast(tx));
        }
Пример #23
0
        public string Transfer(PrivateKeyAccount sender, string recipient, Asset asset, decimal amount,
                               string message = "")
        {
            var tx = new TransferTransaction(sender.PublicKey, recipient, asset, amount, message);

            tx.Sign(sender);
            return(Broadcast(tx));
        }
Пример #24
0
        public string PlaceOrder(PrivateKeyAccount sender, Order order)
        {
            order.Sign(sender);

            var json = order.GetJson();

            return(Http.Post($"{_host}/matcher/orderbook", json));
        }
Пример #25
0
        public string DeleteOrder(PrivateKeyAccount account,
                                  Asset amountAsset, Asset priceAsset, string orderId)
        {
            var request = MakeOrderCancelRequest(account, orderId);
            var url     = $"{_host}/matcher/orderbook/{amountAsset.Id}/{priceAsset.Id}/delete";

            return(Http.Post(url, request));
        }
Пример #26
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));
        }
Пример #27
0
        public string InvokeScript(PrivateKeyAccount caller, string dappAddress,
                                   Dictionary <Asset, decimal> payment, decimal fee = 0.005m, Asset feeAsset = null)
        {
            var tx = new InvokeScriptTransaction(ChainId, caller.PublicKey, dappAddress,
                                                 payment, fee, feeAsset);

            tx.Sign(caller);
            return(Broadcast(tx));
        }
Пример #28
0
        public Order[] GetOrders(PrivateKeyAccount account, Asset amountAsset, Asset priceAsset)
        {
            string path = $"{_host}/matcher/orderbook/{amountAsset.Id}/{priceAsset.Id}/publicKey/{account.PublicKey.ToBase58()}";

            var headers  = GetProtectionHeaders(account);
            var response = Http.GetObjectsWithHeaders(path, headers);

            return(response.Select(j => Order.CreateFromJson(j, amountAsset, priceAsset)).ToArray());
        }
Пример #29
0
        public string Transfer(PrivateKeyAccount sender, string recipient, Asset asset, decimal amount,
                               string message = "")
        {
            var fee = 0.001m + (asset.Script != null ?  0.004m : 0);
            var tx  = new TransferTransaction(ChainId, sender.PublicKey, recipient, asset, amount, message);

            tx.Sign(sender);
            return(Broadcast(tx));
        }
Пример #30
0
        public string PlaceOrder(PrivateKeyAccount sender, Order order)
        {
            var bytes = order.GetBytes();

            order.Signature = sender.Sign(bytes);

            var json = order.GetJson();

            return(Http.Post($"{_host}/matcher/orderbook", json));
        }