Exemplo n.º 1
0
        protected override async Task ProcessRequestAsync(IHttpWebRequest request, Dictionary <string, object> payload)
        {
            if (CanMakeAuthenticatedRequest(payload))
            {
                if (payload.TryGetValue("body", out var body))
                {
                    payload.Remove("body");
                }

                var nonce = payload["nonce"].ToString();
                payload.Remove("nonce");

                var json = JsonConvert.SerializeObject(body ?? payload);
                if (json == "{}")
                {
                    json = "";
                }

                var passphrase = Passphrase?.ToUnsecureString();
                if (string.IsNullOrEmpty(passphrase))
                {
                    passphrase = PrivateApiKey?.ToUnsecureString();
                }

                var hexSha384 = CryptoUtility.SHA384Sign(
                    $"{request.RequestUri.AbsolutePath.Replace("/spot", string.Empty)}{nonce}{json}",
                    passphrase);
                request.AddHeader("btse-sign", hexSha384);
                request.AddHeader("btse-nonce", nonce);
                request.AddHeader("btse-api", PublicApiKey.ToUnsecureString());
                await request.WriteToRequestAsync(json);
            }

            await base.ProcessRequestAsync(request, payload);
        }
 protected override async Task ProcessRequestAsync(IHttpWebRequest request, Dictionary <string, object> payload)
 {
     if (CanMakeAuthenticatedRequest(payload))
     {
         string payloadForm = CryptoUtility.GetFormForPayload(payload, false);
         request.AddHeader("API-Key", PublicApiKey.ToUnsecureString());
         request.AddHeader("Sign", CryptoUtility.SHA256Sign(payloadForm, PrivateApiKey.ToBytesUTF8()).ToUpperInvariant());
         await request.WriteToRequestAsync(payloadForm);
     }
 }
Exemplo n.º 3
0
 protected override async Task ProcessRequestAsync(IHttpWebRequest request, Dictionary <string, object> payload)
 {
     if (CanMakeAuthenticatedRequest(payload))
     {
         if (request.Method == "POST")
         {
             request.AddHeader("content-type", "application/json");
             payload.Remove("nonce"); //移除随机数
             var msg = payload.GetJsonForPayload();
             await request.WriteToRequestAsync(msg);
         }
     }
 }