C-patex api 说:签名无效

发布于 2025-01-15 16:15:26 字数 1573 浏览 1 评论 0原文

我正在尝试为 Pascalabc 上的 c-patex 交换创建一个加密机器人。我被困在使用密钥和秘密密钥的私人请求上。我收到错误 - {"error":{"code":2005,"message":"签名不正确。"}}

这是我的代码:

function GetOrders.TGetOrders.GetOrders: string;
begin
  var hmac := new HMACSHA256(Encoding.UTF8.GetBytes('xxx'));
  var timestapm := (System.IO.StreamReader.Create(System.Net.WebRequest.CreateHttp('https://c-patex.com//api/v2/timestamp.json').GetResponse.GetResponseStream).ReadToEnd.ToBigInteger * 1000).ToString;
  var sigstring := 'GET|/api/v2/orders|access_key=yyy&tonce=' + timestapm.ToBigInteger / 100 + '&market=compdoge';
  var compute  := hmac.ComputeHash(Encoding.UTF8.GetBytes(sigstring), 0, Encoding.UTF8.GetBytes(sigstring).Length);
  var signature := System.BitConverter.ToString(compute).Replace('-', string.Empty).ToLower();
  var reqstring := 'https://c-patex.com//api/v2/orders?access_key=6BckEAz52cOwpx1gfT0nByhLxkNF8uzzTFdzT8Oa' +
  '&market=compdoge' + 
  '&signature=' + signature +
  '&tonce=' + timestapm;
  Writeln(reqstring);
  try
    var request := System.Net.WebClient.Create;
    var data := request.DownloadData(reqstring);
  except
    on ex: System.Net.WebException do
    begin
      var Response := ex.Response;
      var stream := Response.GetResponseStream;
      var Reader := new System.IO.BinaryReader(Stream);
      var res := Reader.ReadBytes(stream.Length);
      var chararr := Encoding.UTF8.GetChars(res);
      var output := System.string.Create(chararr);
      Writeln(output);
    end;
  end;
end;
end.

有人使用过此交易所的 api 吗?你有遇到过类似的问题吗? 提前致谢。

I am trying to create a crypto bot for the c-patex exchange on Pascalabc. I'm stuck on private requests using a key and a secret key. I get an error - {"error":{"code":2005,"message":"Signature is incorrect."}}

This is my code:

function GetOrders.TGetOrders.GetOrders: string;
begin
  var hmac := new HMACSHA256(Encoding.UTF8.GetBytes('xxx'));
  var timestapm := (System.IO.StreamReader.Create(System.Net.WebRequest.CreateHttp('https://c-patex.com//api/v2/timestamp.json').GetResponse.GetResponseStream).ReadToEnd.ToBigInteger * 1000).ToString;
  var sigstring := 'GET|/api/v2/orders|access_key=yyy&tonce=' + timestapm.ToBigInteger / 100 + '&market=compdoge';
  var compute  := hmac.ComputeHash(Encoding.UTF8.GetBytes(sigstring), 0, Encoding.UTF8.GetBytes(sigstring).Length);
  var signature := System.BitConverter.ToString(compute).Replace('-', string.Empty).ToLower();
  var reqstring := 'https://c-patex.com//api/v2/orders?access_key=6BckEAz52cOwpx1gfT0nByhLxkNF8uzzTFdzT8Oa' +
  '&market=compdoge' + 
  '&signature=' + signature +
  '&tonce=' + timestapm;
  Writeln(reqstring);
  try
    var request := System.Net.WebClient.Create;
    var data := request.DownloadData(reqstring);
  except
    on ex: System.Net.WebException do
    begin
      var Response := ex.Response;
      var stream := Response.GetResponseStream;
      var Reader := new System.IO.BinaryReader(Stream);
      var res := Reader.ReadBytes(stream.Length);
      var chararr := Encoding.UTF8.GetChars(res);
      var output := System.string.Create(chararr);
      Writeln(output);
    end;
  end;
end;
end.

Has anyone worked with the api of this exchange? Have you had a similar problem?
Thanks in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

意中人 2025-01-22 16:15:26

我解决了这个问题。问题出在 Unix 时间,因为我从延迟很大的服务器获取它。

var unixTime := System.DateTimeOffset.UtcNow.ToUnixTimeMilliseconds;

这段代码工作正常,因为它使用本地时间并将其转换为 Unix 毫秒

Im solved this. Problem was in Unix time, because i get it from server with big latensy.

var unixTime := System.DateTimeOffset.UtcNow.ToUnixTimeMilliseconds;

This code work fine, because it uses local time and converts it to Unix milliseconds

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文