Beispiel #1
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));
        }
Beispiel #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));
        }
Beispiel #3
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));
        }
Beispiel #4
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));
        }
Beispiel #5
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));
        }
Beispiel #6
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));
        }
Beispiel #7
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));
        }
Beispiel #8
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));
        }
Beispiel #9
0
        public string CancelAll(PrivateKeyAccount account)
        {
            var request = MakeCancelAllRequest(account);
            var url     = $"{_host}/matcher/orderbook/cancel";

            return(Http.Post(url, request));
        }
Beispiel #10
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));
        }
Beispiel #11
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));
        }
Beispiel #12
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));
        }
Beispiel #13
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));
        }
Beispiel #14
0
        public string PlaceOrder(PrivateKeyAccount sender, Order order)
        {
            order.Sign(sender);

            var json = order.GetJson();

            return(Http.Post($"{_host}/matcher/orderbook", json));
        }
Beispiel #15
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));
        }
Beispiel #16
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));
        }
Beispiel #17
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());
        }
Beispiel #18
0
        public Asset IssueAsset(PrivateKeyAccount account,
                                string name, string description, decimal quantity, byte decimals, bool reissuable, byte[] script = null, decimal fee = 1m)
        {
            var tx = new IssueTransaction(account.PublicKey, name, description, quantity, decimals, reissuable, ChainId, fee, script);

            tx.Sign(account);
            var response = Broadcast(tx);
            var assetId  = response.ParseJsonObject().GetString("id");

            return(new Asset(assetId, name, decimals, script));
        }
Beispiel #19
0
        private static NameValueCollection GetProtectionHeaders(PrivateKeyAccount account)
        {
            long timestamp = Utils.CurrentTimestamp();
            var  stream    = new MemoryStream(40);
            var  writer    = new BinaryWriter(stream);

            writer.Write(account.PublicKey);
            writer.WriteLong(timestamp);
            var signature = account.Sign(stream);

            return(new NameValueCollection
            {
                { "Timestamp", Convert.ToString(timestamp) },
                { "Signature", signature.ToBase58() }
            });
        }
Beispiel #20
0
        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() }
            });
        }
Beispiel #21
0
        public static DictionaryObject MakeCancelAllRequest(PrivateKeyAccount sender)
        {
            long timestamp = Utils.CurrentTimestamp();
            var  stream    = new MemoryStream();
            var  writer    = new BinaryWriter(stream);

            writer.Write(sender.PublicKey);
            writer.WriteLong(timestamp);
            var signature = sender.Sign(stream);

            return(new DictionaryObject
            {
                { "sender", sender.PublicKey.ToBase58() },
                { "timestamp", timestamp },
                { "signature", signature.ToBase58() }
            });
        }
Beispiel #22
0
        public string MassTransfer(PrivateKeyAccount sender, Asset asset, string recipientsListFile,
                                   string message = "", decimal?fee = null)
        {
            string line;
            List <MassTransferItem> transfers = new List <MassTransferItem>();

            System.IO.StreamReader file =
                new System.IO.StreamReader(recipientsListFile);
            while ((line = file.ReadLine()) != null)
            {
                var item   = line.Split(new char[] { ',' });
                var amount = decimal.Parse(item[1], CultureInfo.GetCultureInfo("en-US"));
                transfers.Add(new MassTransferItem(item[0], amount));
            }
            file.Close();

            var tx = new MassTransferTransaction(ChainId, sender.PublicKey, asset, transfers, message, fee);

            tx.Sign(sender);
            return(Broadcast(tx));
        }
Beispiel #23
0
 public static Order Sign(this Order order, PrivateKeyAccount account, int proofIndex = 0)
 {
     order.Proofs[proofIndex] = account.Sign(order.GetBody());
     return(order);
 }