Skip to content

Commit

Permalink
Merge pull request #14 from HuobiRDCenter/branch_20241023
Browse files Browse the repository at this point in the history
删除私钥
  • Loading branch information
huobiapi authored Oct 25, 2024
2 parents 4dd083f + 7a464ad commit 1fd1258
Show file tree
Hide file tree
Showing 73 changed files with 1,030 additions and 424 deletions.
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[*.cs]

# IDE0005: Using 指令是不需要的。
dotnet_diagnostic.IDE0005.severity = none
28 changes: 28 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
// {
// "name": ".NET Core Launch (console)",
// "type": "coreclr",
// "request": "launch",
// "preLaunchTask": "build",
// "program": "${workspaceFolder}/bin/Debug/net6.0/MyCSharpApp.dll", // 修改为你的项目输出路径
// "args": [],
// "cwd": "${workspaceFolder}",
// "stopAtEntry": false,
// "serverReadyAction": {
// "action": "openExternally",
// "pattern": "\\bNow listening on:\\s+(https?://\\S+)"
// },
// "env": {
// "ASPNETCORE_ENVIRONMENT": "Development"
// },
// "sourceFileMap": {
// "/Views": "${workspaceFolder}/Views"
// }
// }
]
}
16 changes: 16 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"command": "dotnet",
"type": "process",
"args": [
"build",
"${workspaceFolder}/Huobi.SDK.Example/Huobi.SDK.Example.csproj"
// 替换为你的项目文件
],
"problemMatcher": "$msCompile"
}
]
}
2 changes: 1 addition & 1 deletion Huobi.SDK.Core.Test/GZipDecompresserTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Huobi.SDK.Core.Client.WebSocketClientBase;
using Huobi.SDK.Core.Client.WebSocketClientBase;
using Xunit;

namespace Huobi.SDK.Core.Test
Expand Down
48 changes: 24 additions & 24 deletions Huobi.SDK.Core.Test/Huobi.SDK.Core.Test.csproj
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>

<IsPackable>false</IsPackable>
<ReleaseVersion>2.2.0</ReleaseVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
<PackageReference Include="xunit" Version="2.4.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
<PackageReference Include="coverlet.collector" Version="1.0.1" />
</ItemGroup>

<ItemGroup>
<Folder Include="RequestBuilder\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Huobi.SDK.Core\Huobi.SDK.Core.csproj" />
<ProjectReference Include="..\Huobi.SDK.Model\Huobi.SDK.Model.csproj" />
</ItemGroup>
</Project>
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>

<IsPackable>false</IsPackable>
<ReleaseVersion>2.2.0</ReleaseVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
<PackageReference Include="xunit" Version="2.4.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
<PackageReference Include="coverlet.collector" Version="1.0.1" />
</ItemGroup>

<ItemGroup>
<Folder Include="RequestBuilder\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Huobi.SDK.Core\Huobi.SDK.Core.csproj" />
<ProjectReference Include="..\Huobi.SDK.Model\Huobi.SDK.Model.csproj" />
</ItemGroup>
</Project>
8 changes: 4 additions & 4 deletions Huobi.SDK.Core.Test/RequestBuilder/PrivateUrlBuilderTest.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System;
using Huobi.SDK.Core.RequestBuilder;
using System;
using Huobi.SDK.Core.RequestBuilder;
using Xunit;

namespace Huobi.SDK.Core.Test.RequestBuilder
Expand All @@ -9,7 +9,7 @@ public class PrivateUrlBuilderTest
[Fact]
public void Build_NoRequestParameter_Success()
{
var builder = new PrivateUrlBuilder("abcdefg-hijklmn-opqrst-uvwxyz", "12345-67890-12345-67890", "api.huobi.pro");
var builder = new PrivateUrlBuilder("abcdefg-hijklmn-opqrst-uvwxyz", "12345-67890-12345-67890", "api.huobi.pro","256");
DateTime dateTime = new DateTime(2020, 04, 01, 12, 34, 56);

string result = builder.Build("GET", "/v1/account/accounts", dateTime);
Expand All @@ -21,7 +21,7 @@ public void Build_NoRequestParameter_Success()
[Fact]
public void Build_RequestParameter_Success()
{
var builder = new PrivateUrlBuilder("access", "secret", "api.huobi.pro");
var builder = new PrivateUrlBuilder("access", "secret", "api.huobi.pro","256");
DateTime dateTime = new DateTime(2019, 11, 21, 10, 0, 0);
var request = new GetRequest()
.AddParam("account-id", "123")
Expand Down
4 changes: 2 additions & 2 deletions Huobi.SDK.Core.Test/RequestBuilder/PublicUrlBuilderTest.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Huobi.SDK.Core;
using Huobi.SDK.Core.RequestBuilder;
using Huobi.SDK.Core;
using Huobi.SDK.Core.RequestBuilder;
using Xunit;

namespace Huobi.SDK.Core.Test.RequestBuilder
Expand Down
43 changes: 43 additions & 0 deletions Huobi.SDK.Core.Test/RequestBuilder/SignerED25519Test.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using Huobi.SDK.Core.RequestBuilder;
using Xunit;

namespace Huobi.SDK.Core.Test.RequestBuilder
{
public class Ed25519SignerTest
{
private const string PrivateKey = "MC4CAQAwBQYDK2VwBCIEILHeu7fAq16wUfz/w91bQVEQO+J1dJ6HE4YGdyfYMPqt"; // 替换为有效的私钥

[Fact]
public void Sign_FourString_Success()
{
var signer = new Ed25519Signer(PrivateKey);
string result = signer.Sign(
"GET",
"https://api.huobi.pro/v1/account/accounts?AccessKeyId=abcdefg-hijklmn-opqrst-uvwxyz&SignatureMethod=ED25519&SignatureVersion=2&Timestamp=2020-04-01T12%3A34%3A56"
);

Assert.Equal("expected_base64_encoded_signature", result); // 替换为您预期的签名
}

[Fact]
public void Sign_RunTwice_ReturnSameResult()
{
var signer = new Ed25519Signer(PrivateKey);

string result1 = signer.Sign("GET", "https://api.huobi.pro/v1/account/history?account-id=1&currency=btcusdt");
string result2 = signer.Sign("GET", "https://api.huobi.pro/v1/account/history?account-id=1&currency=btcusdt");

Assert.Equal(result1, result2);
}

[Fact]
public void Sign_OneNullStringThreeString_ReturnEmpty()
{
var signer = new Ed25519Signer(PrivateKey);

string result = signer.Sign("GET", "https://api.huobi.pro", "", "account-id=currency=btcusdt");

Assert.Equal("", result);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class WebSocketRequestBuilderTest
[Fact]
public void Build_NullParam_Success()
{
var builder = new WebSocketV1RequestBuilder("access", "secret", "api.huobi.pro", "/ws/v1");
var builder = new WebSocketV1RequestBuilder("access", "secret", "api.huobi.pro","256" ,"/ws/v1");

string auth = builder.Build();

Expand All @@ -26,7 +26,7 @@ public void Build_NullParam_Success()
[Fact]
public void Build_Time_Success()
{
var builder = new WebSocketV1RequestBuilder("access", "secret", "api.huobi.pro", "/ws/v1");
var builder = new WebSocketV1RequestBuilder("access", "secret", "api.huobi.pro", "256","/ws/v1");

var utcTime = new DateTime(2019, 11, 21, 10, 0, 0);
string auth = builder.Build(utcTime);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class WebSocketRequestBuilderV2Test
[Fact]
public void Build_NullParam_Success()
{
var builder = new WebSocketV2RequestBuilder("access", "secret", "api.huobi.pro", "/ws/v2");
var builder = new WebSocketV2RequestBuilder("access", "secret", "api.huobi.pro","256", "/ws/v2");

string auth = builder.Build();

Expand All @@ -28,7 +28,7 @@ public void Build_NullParam_Success()
[Fact]
public void Build_Time_Success()
{
var builder = new WebSocketV2RequestBuilder("access", "secret", "api.huobi.pro", "/ws/v2");
var builder = new WebSocketV2RequestBuilder("access", "secret", "api.huobi.pro","256", "/ws/v2");

DateTime utcTime = new DateTime(2019, 11, 21, 10, 0, 0);
string auth = builder.Build(utcTime);
Expand Down
6 changes: 3 additions & 3 deletions Huobi.SDK.Core/Client/AccountClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ public class AccountClient
/// <param name="accessKey">Access Key</param>
/// <param name="secretKey">Secret Key</param>
/// <param name="host">the host that the client connects to</param>
public AccountClient(string accessKey, string secretKey, string host = DEFAULT_HOST)
{
_urlBuilder = new PrivateUrlBuilder(accessKey, secretKey, host);
public AccountClient(string accessKey, string secretKey,string sign ,string host = DEFAULT_HOST){

_urlBuilder = new PrivateUrlBuilder(accessKey, secretKey, host,sign);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Huobi.SDK.Core.Client.WebSocketClientBase;
using Huobi.SDK.Core.Client.WebSocketClientBase;
using Huobi.SDK.Core.Log;
using Huobi.SDK.Model.Response.Account;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ public class SubscribeAccountWebSocketV1Client : WebSocketV1ClientBase<Subscribe
/// <param name="accessKey">API Access Key</param>
/// <param name="secretKey">API Secret Key</param>
/// <param name="host">API Host</param>
public SubscribeAccountWebSocketV1Client(string accessKey, string secretKey, string host = DEFAULT_HOST)
:base(accessKey, secretKey, host)
public SubscribeAccountWebSocketV1Client(string accessKey, string secretKey,string sign, string host = DEFAULT_HOST)
:base(accessKey, secretKey,sign, host)
{
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ public class SubscribeAccountWebSocketV2Client : WebSocketV2ClientBase<Subscribe
/// <param name="accessKey">API Access Key</param>
/// <param name="secretKey">API Secret Key</param>
/// <param name="host">API Host</param>
public SubscribeAccountWebSocketV2Client(string accessKey, string secretKey, string host = DEFAULT_HOST)
:base(accessKey, secretKey, host)
public SubscribeAccountWebSocketV2Client(string accessKey, string secretKey,string sign, string host = DEFAULT_HOST)
:base(accessKey, secretKey,sign, host)
{
}

Expand Down
6 changes: 3 additions & 3 deletions Huobi.SDK.Core/Client/AlgoOrderClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Huobi.SDK.Core.Client
/// Responsible to operate on order
/// </summary>
public class AlgoOrderClient
{
{
private const string GET_METHOD = "GET";
private const string POST_METHOD = "POST";

Expand All @@ -23,9 +23,9 @@ public class AlgoOrderClient
/// <param name="accessKey">Access Key</param>
/// <param name="secretKey">Secret Key</param>
/// <param name="host">the host that the client connects to</param>
public AlgoOrderClient(string accessKey, string secretKey, string host = DEFAULT_HOST)
public AlgoOrderClient(string accessKey, string secretKey,string sign, string host = DEFAULT_HOST)
{
_urlBuilder = new PrivateUrlBuilder(accessKey, secretKey, host);
_urlBuilder = new PrivateUrlBuilder(accessKey, secretKey, host,sign);
}

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions Huobi.SDK.Core/Client/CrossMarginClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ public class CrossMarginClient
/// <param name="accessKey">Access Key</param>
/// <param name="secretKey">Secret Key</param>
/// <param name="host">the host that the client connects to</param>
public CrossMarginClient(string accessKey, string secretKey, string host = DEFAULT_HOST)
public CrossMarginClient(string accessKey, string secretKey,string sign, string host = DEFAULT_HOST)
{
_urlBuilder = new PrivateUrlBuilder(accessKey, secretKey, host);
_urlBuilder = new PrivateUrlBuilder(accessKey, secretKey, host,sign);
}

/// <summary>
Expand Down
6 changes: 3 additions & 3 deletions Huobi.SDK.Core/Client/ETFClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Huobi.SDK.Core.Client
/// Responsible to operate ETF
/// </summary>
public class ETFClient
{
{
private const string GET_METHOD = "GET";
private const string POST_METHOD = "POST";

Expand All @@ -24,9 +24,9 @@ public class ETFClient
/// <param name="accessKey">Access Key</param>
/// <param name="secretKey">Secret Key</param>
/// <param name="host">the host that the client connects to</param>
public ETFClient(string accessKey, string secretKey, string host = DEFAULT_HOST)
public ETFClient(string accessKey, string secretKey,string sign, string host = DEFAULT_HOST)
{
_urlBuilder = new PrivateUrlBuilder(accessKey, secretKey, host);
_urlBuilder = new PrivateUrlBuilder(accessKey, secretKey, host,sign);
}

/// <summary>
Expand Down
6 changes: 3 additions & 3 deletions Huobi.SDK.Core/Client/IsolatedMarginClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Huobi.SDK.Core.Client
/// Responsible to operate isolated margin
/// </summary>
public class IsolatedMarginClient
{
{
private const string GET_METHOD = "GET";
private const string POST_METHOD = "POST";

Expand All @@ -23,9 +23,9 @@ public class IsolatedMarginClient
/// <param name="accessKey">Access Key</param>
/// <param name="secretKey">Secret Key</param>
/// <param name="host">the host that the client connects to</param>
public IsolatedMarginClient(string accessKey, string secretKey, string host = DEFAULT_HOST)
public IsolatedMarginClient(string accessKey, string secretKey,string sign, string host = DEFAULT_HOST)
{
_urlBuilder = new PrivateUrlBuilder(accessKey, secretKey, host);
_urlBuilder = new PrivateUrlBuilder(accessKey, secretKey, host,sign);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Huobi.SDK.Core.Client.WebSocketClientBase;
using Huobi.SDK.Core.Client.WebSocketClientBase;
using Huobi.SDK.Core.Log;
using Huobi.SDK.Model.Response.Market;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Huobi.SDK.Core.Client.WebSocketClientBase;
using Huobi.SDK.Core.Client.WebSocketClientBase;
using Huobi.SDK.Core.Log;
using Huobi.SDK.Model.Response.Market;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Huobi.SDK.Core.Client.WebSocketClientBase;
using Huobi.SDK.Core.Client.WebSocketClientBase;
using Huobi.SDK.Core.Log;
using Huobi.SDK.Model.Response.Market;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Huobi.SDK.Core.Client.WebSocketClientBase;
using Huobi.SDK.Core.Client.WebSocketClientBase;
using Huobi.SDK.Core.Log;
using Huobi.SDK.Model.Response.Market;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Huobi.SDK.Core.Client.WebSocketClientBase;
using Huobi.SDK.Core.Client.WebSocketClientBase;
using Huobi.SDK.Core.Log;
using Huobi.SDK.Model.Response.Market;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Huobi.SDK.Core.Client.WebSocketClientBase;
using Huobi.SDK.Core.Client.WebSocketClientBase;
using Huobi.SDK.Core.Log;
using Huobi.SDK.Model.Response.Market;

Expand Down
4 changes: 2 additions & 2 deletions Huobi.SDK.Core/Client/OrderClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ public class OrderClient
/// <param name="accessKey">Access Key</param>
/// <param name="secretKey">Secret Key</param>
/// <param name="host">the host that the client connects to</param>
public OrderClient(string accessKey, string secretKey, string host = DEFAULT_HOST)
public OrderClient(string accessKey, string secretKey,string sign, string host = DEFAULT_HOST)
{
_urlBuilder = new PrivateUrlBuilder(accessKey, secretKey, host);
_urlBuilder = new PrivateUrlBuilder(accessKey, secretKey, host,sign);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Huobi.SDK.Core.Client.WebSocketClientBase;
using Huobi.SDK.Core.Client.WebSocketClientBase;
using Huobi.SDK.Core.Log;
using Huobi.SDK.Model.Response.Order;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Huobi.SDK.Core.Client.WebSocketClientBase;
using Huobi.SDK.Core.Client.WebSocketClientBase;
using Huobi.SDK.Model.Response.Order;
using Huobi.SDK.Model.Request.Order;
using Huobi.SDK.Core.Log;
Expand Down
Loading

0 comments on commit 1fd1258

Please sign in to comment.