Ejemplo n.º 1
0
        public async Task <string> PutResponsePool(string Mkey, string Msecret, string id, string fields)
        {
            hash_hmac hmac     = new hash_hmac();
            string    ID       = id;
            string    Key      = Mkey;
            string    Secret   = Msecret;
            double    mtime    = Math.Round((DateTime.Now.ToUniversalTime() - new DateTime(1970, 1, 1)).TotalSeconds * 10000);
            string    endpoint = "/rig/" + ID + "/pool";
            //string endpoint = "/rig/141972/pool";
            string sign_string = Key + mtime.ToString() + endpoint;

            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
            var req = WebRequest.Create(@"https://www.miningrigrentals.com/api/v2" + endpoint + fields);

            //Console.WriteLine(req.RequestUri);
            req.Headers.Add("x-api-sign:" + hmac.sha1(sign_string, Secret));
            req.Headers.Add("x-api-key:" + Key);
            req.Headers.Add("x-api-nonce:" + mtime.ToString());
            req.Method      = "PUT";
            req.ContentType = "application/x-www-form-urlencoded";
            WebResponse r = await req.GetResponseAsync();

            StreamReader responseReader = new StreamReader(r.GetResponseStream());

            //Console.WriteLine(req.RequestUri.AbsoluteUri);
            //Console.WriteLine(await responseReader.ReadToEndAsync());
            return(await responseReader.ReadToEndAsync());
        }
Ejemplo n.º 2
0
        public async Task <dynamic> GetResponseRig(string Mkey, string Msecret)
        {
            hash_hmac hmac        = new hash_hmac();
            string    Key         = Mkey;
            string    Secret      = Msecret;
            double    mtime       = Math.Round((DateTime.Now.ToUniversalTime() - new DateTime(1970, 1, 1)).TotalSeconds * 10000);
            string    endpoint    = "/rig/mine";
            string    sign_string = Key + mtime.ToString() + endpoint;

            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
            var req = WebRequest.Create(@"https://www.miningrigrentals.com/api/v2" + endpoint);

            req.Headers.Add("x-api-sign:" + hmac.sha1(sign_string, Secret));
            req.Headers.Add("x-api-key:" + Key);
            req.Headers.Add("x-api-nonce:" + mtime.ToString());
            var r = await req.GetResponseAsync();

            StreamReader responseReader = new StreamReader(r.GetResponseStream());

            return(await responseReader.ReadToEndAsync());
        }