C # Coinbase api возвращает ошибки ": [{" id ":" authentication_error "," message ":" неверная подпись "}]} - PullRequest
0 голосов
/ 06 ноября 2018

Я попытался выполнить команду BTC, но получил неверную ошибку доступа. Код, который я использую позади.

public string Transfer()
        {
            unixTimestamp = (Int32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
            TransferInput data = new TransferInput();
            data.to = "3d64cd26-9c1e-5b24-8a6a-242cbb48a40a";
            data.amount = "0.00000001";
            data.type = "transfer";
            data.currency = "BTC";
            string body = Newtonsoft.Json.JsonConvert.SerializeObject(data);
            string message = unixTimestamp.ToString() + "POST" + "/v2/accounts/5ebedea2-b646-5fda-9409-8b1d9f1add1c/transactions" + body;
            string signature = GetSignature(message);
            var _client = new RestClient("https://api.coinbase.com/v2/");
            var request = new RestRequest("accounts/5ebedea2-b646-5fda-9409-8b1d9f1add1c/transactions", Method.POST);
            request.AddHeader("Content-Type", "application/json");
            request.AddHeader("CB-ACCESS-KEY", ApiKey);
            request.AddHeader("CB-ACCESS-SIGN", signature);
            request.AddHeader("CB-ACCESS-TIMESTAMP", unixTimestamp.ToString());
            request.OnBeforeDeserialization = resp => { resp.ContentType = "application/json"; resp.Content = body; };
            var response = _client.Execute(request);
            string a= _client.Execute(request).Content;
            return a;
        }

А

public string GetSignature(string message)
        {
            byte[] secretKey = Encoding.UTF8.GetBytes(ApiSecret);
            HMACSHA256 hmac = new HMACSHA256(secretKey);
            hmac.Initialize();
            byte[] bytes = Encoding.UTF8.GetBytes(message);
            byte[] rawHmac = hmac.ComputeHash(bytes);
            string signature = rawHmac.ByteArrayToHexString();
            return signature;
        }

Сгенерировать ошибку: [{"id": "authentication_error", "message": "неверная подпись"}]}

Пожалуйста, помогите мне! Большое спасибо!

...