-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b118d90
commit c04018a
Showing
85 changed files
with
2,560 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
Namespace Bitnuvem | ||
''' <summary> | ||
''' *** MADE FOR GITHUB *** | ||
''' WRITTEN BY ROMULO MEIRELLES. | ||
''' UPWORK: https://www.upwork.com/freelancers/~01fcbc5039ac5766b4 | ||
''' CONTACT WHATSAPP: https://wa.me/message/KWIS3BYO6K24N1 | ||
''' CONTACT TELEGRAM: https://t.me/Romulo_Meirelles | ||
''' GITHUB: https://github.com/Romulo-Meirelles | ||
''' DISCORD: đąяķňέs§¢øďε#2786 | ||
''' </summary> | ||
''' <remarks></remarks> | ||
''' | ||
Public Class ApiConfig | ||
Public Property ApiKey As String | ||
Public Property SecretKey As String | ||
Public Property BaseUrlTRADEAPI As String = "https://bitnuvem.com/tapi/" | ||
Public Property BaseUrlAPI As String = "https://bitnuvem.com/api/BTC/" | ||
Public Property BaseUrlWS As String = "https://bitnuvem.com/ws/" | ||
Public Property SendInterceptors As IEnumerable(Of IBalanceInterceptor) = Array.Empty(Of IBalanceInterceptor)() | ||
Public Sub Check() | ||
If String.IsNullOrEmpty(ApiKey) Then Throw New ArgumentException("The API key is missing.", NameOf(ApiConfig.ApiKey)) | ||
End Sub | ||
End Class | ||
End Namespace |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Library</OutputType> | ||
<RootNamespace>BitnuvemAPI</RootNamespace> | ||
<TargetFramework>netcoreapp3.1</TargetFramework> | ||
<ApplicationIcon>Resources\Bitnuvem.ico</ApplicationIcon> | ||
<ApplicationManifest>My Project\app.manifest</ApplicationManifest> | ||
<StartupObject /> | ||
<AssemblyName>BitnuvemAPI</AssemblyName> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Compile Update="My Project\Resources.Designer.vb"> | ||
<DesignTime>True</DesignTime> | ||
<AutoGen>True</AutoGen> | ||
<DependentUpon>Resources.resx</DependentUpon> | ||
</Compile> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<EmbeddedResource Update="My Project\Resources.resx"> | ||
<CustomToolNamespace>My.Resources</CustomToolNamespace> | ||
<Generator>VbMyResourcesResXFileCodeGenerator</Generator> | ||
<LastGenOutput>Resources.Designer.vb</LastGenOutput> | ||
</EmbeddedResource> | ||
</ItemGroup> | ||
|
||
</Project> |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
Imports System.Runtime.Serialization | ||
|
||
Namespace Bitnuvem | ||
|
||
''' <summary> | ||
''' *** MADE FOR GITHUB *** | ||
''' WRITTEN BY ROMULO MEIRELLES. | ||
''' UPWORK: https://www.upwork.com/freelancers/~01fcbc5039ac5766b4 | ||
''' CONTACT WHATSAPP: https://wa.me/message/KWIS3BYO6K24N1 | ||
''' CONTACT TELEGRAM: https://t.me/Romulo_Meirelles | ||
''' GITHUB: https://github.com/Romulo-Meirelles | ||
''' DISCORD: đąяķňέs§¢øďε#2786 | ||
''' </summary> | ||
''' <remarks></remarks> | ||
''' | ||
Public Class BitnuvemException | ||
Inherits Exception | ||
Public ReadOnly Property StatusCode As Integer | ||
Public Sub New() | ||
End Sub | ||
Public Sub New(ByVal statusCode As Integer) | ||
Me.StatusCode = statusCode | ||
End Sub | ||
Public Sub New(ByVal message As String) | ||
MyBase.New(message) | ||
End Sub | ||
Public Sub New(ByVal message As String, ByVal statusCode As Integer) | ||
MyBase.New(message) | ||
Me.StatusCode = statusCode | ||
End Sub | ||
Public Sub New(ByVal message As String, ByVal innerException As Exception) | ||
MyBase.New(message, innerException) | ||
Me.StatusCode = StatusCode | ||
End Sub | ||
Public Sub New(ByVal message As String, ByVal statusCode As Integer, ByVal innerException As Exception) | ||
MyBase.New(message, innerException) | ||
Me.StatusCode = statusCode | ||
End Sub | ||
Protected Sub New(ByVal info As SerializationInfo, ByVal context As StreamingContext) | ||
MyBase.New(info, context) | ||
End Sub | ||
|
||
Public Function HasError(ByVal [error] As BitnuvemError) As Boolean | ||
Return StatusCode = [error] | ||
End Function | ||
Public Function HasError(ByVal [error] As BitnuvemError, ParamArray errors As BitnuvemError()) As Boolean | ||
Return errors.Concat({[error]}).Any(Function(e) StatusCode = e) | ||
End Function | ||
End Class | ||
|
||
Public Enum BitnuvemError | ||
|
||
Algo_inesperado_aconteceu = 106 | ||
Chave_privada_invalida = 130 | ||
E_necessario_ativar_a_Autenticação_em_2_passos = 131 | ||
Essa_chave_privada_ainda_nao_foi_confirmada_por_e_mail = 132 | ||
Time_Stamp_incorreto = 133 | ||
Requisicao_invalida = 134 | ||
E_necessario_ter_cadastro_completo_para_usar_a_API_de_Negociacao = 135 | ||
Saldo_em_Bitcoin_insuficiente = 254 | ||
Voce_precisa_transferir_no_minimo_0_00001000_BTC = 255 | ||
O_endereco_da_carteira_destino_e_invalido = 256 | ||
Você_nao_possui_saldo_Bitcoin_suficiente = 259 | ||
Você_nao_possui_saldo_em_reais_suficiente = 260 | ||
Conta_bancaria_nao_encontrada = 261 | ||
Você_precisa_sacar_no_minimo_RS_10_00 = 264 | ||
Os_valores_precisam_ser_maiores_que_0 = 267 | ||
Saldo_em_Bitcoin_insuficiente_0 = 268 | ||
Saldo_em_reais_insuficiente = 270 | ||
Ordem_cancelada = 271 | ||
Ordem_stop_preco_adicionada = 290 | ||
O_valor_stop_de_venda_no_modo_OCO_deve_ser_menor_que_o_valor_de_venda_padrao = 291 | ||
O_valor_stop_de_compra_no_modo_OCO_deve_ser_maior_que_o_valor_de_compra_padrao = 292 | ||
Nao_e_possivel_lancar_ordens_com_valor_total_abaixo_de_RS_10_00__Tente_novamente_com_valores_maiores = 303 | ||
Nao_e_possivel_lancar_ordens_com_valor_total_acima_de_RS_50_000_00__Tente_novamente_com_valores_menores = 305 | ||
Nao_e_possivel_lancar_ordens_STOP_com_valor_de_compra_abaixo_da_melhor_oferta_de_compra_atual_e_ou_ultimo_valor_negociado = 306 | ||
Nao_e_possivel_lancar_ordens_STOP_com_valor_de_venda_acima_da_melhor_oferta_de_venda_atual_e_ou_ultimo_valor_negociado = 307 | ||
Aguarde_seu_depósito_de_bitcoin_ter_3_confirmacoes_para_prosseguir_com_esta_acao_Acompanhe_aqui = 313 | ||
O_preco_unitario_minimo_deve_ser_acima_que_a_melhor_oferta_de_compra = 315 | ||
O_preco_unitario_maximo_deve_ser_abaixo_que_a_melhor_oferta_de_venda = 316 | ||
O_preco_unitario_maximo_deve_ser_maior_que_o_preco_unitario_minimo = 317 | ||
Sao_permitidos_criar_numeros_de_ordem_entre_2_e_30 = 318 | ||
Sua_chave_privada_nao_tem_acesso_à_essa_funcao = 331 | ||
Esse_valor_excede_o_limite_de_RS_2_000_00_permitidos_para_usuario_sem_cadastro_completo__Conclua_seu_cadastro_clicando_aqui = 339 | ||
Esse_valor_excede_o_limite_de_0_04000000_BTC_permitidos_para_usuario_sem_cadastro_completo__Conclua_seu_cadastro_clicando_aqui = 340 | ||
É_possivel_realizar_somente_1_requisicao_por_segundo = 382 | ||
Você_realizou_mais_de_60_requisicoes_por_minuto__Aguarde_alguns_instante_para_voltar_usar_a_API_de_Negociacao = 383 | ||
Este_endereco_nao_e_o_mesmo_configurado_da_chave_da_API_de_Negociacoes = 440 | ||
End Enum | ||
End Namespace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Imports System.Security.Cryptography | ||
Namespace Bitnuvem | ||
Public Class HMAC256 | ||
Public Function Create_HMACSHA256_Sign(ByVal Message As String, ByVal SecretKey As String) As String | ||
Try | ||
Dim Encoding = New Text.ASCIIEncoding() | ||
Dim KeyByte As Byte() = Encoding.GetBytes(SecretKey) | ||
Dim MessageBytes As Byte() = Encoding.GetBytes(Message) | ||
Using Hmacsha256 = New HMACSHA256(KeyByte) | ||
Dim HashBytes As Byte() = Hmacsha256.ComputeHash(MessageBytes) | ||
Return BitConverter.ToString(HashBytes).Replace("-", "").ToLower() | ||
End Using | ||
Catch ex As Exception | ||
Console.WriteLine(ex.Message) | ||
Return Nothing | ||
End Try | ||
End Function | ||
End Class | ||
End Namespace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
Imports System.Net.Http | ||
|
||
Namespace Bitnuvem | ||
''' <summary> | ||
''' *** MADE FOR GITHUB *** | ||
''' WRITTEN BY ROMULO MEIRELLES. | ||
''' UPWORK: https://www.upwork.com/freelancers/~01fcbc5039ac5766b4 | ||
''' CONTACT WHATSAPP: https://wa.me/message/KWIS3BYO6K24N1 | ||
''' CONTACT TELEGRAM: https://t.me/Romulo_Meirelles | ||
''' GITHUB: https://github.com/Romulo-Meirelles | ||
''' DISCORD: đąяķňέs§¢øďε#2786 | ||
''' </summary> | ||
''' <remarks></remarks> | ||
|
||
Public Class HttpClientRequester | ||
Inherits RequesterBase | ||
Implements IDisposable | ||
|
||
Private ReadOnly _Client As HttpClient | ||
Private _DisposeClient As Boolean | ||
Public Sub New(ByVal Configuration As ApiConfig, ByVal Client As HttpClient) | ||
MyBase.New(Configuration) | ||
_Client = Client | ||
End Sub | ||
Public Overrides Async Function Post(Of T As BitnuvemResponse)(Resource As String, Optional Parameters As Dictionary(Of String, String) = Nothing, Optional noThrow As Boolean = False) As Task(Of T) | ||
Dim Result = Nothing | ||
Dim Response As String = String.Empty | ||
Dim Deserialized As BitnuvemResponse | ||
|
||
If Resource = "balance" Or Resource = "account_bank_list" Or Resource = "withdraw" Or Resource = "send" Or Resource = "order_get" Or Resource = "order_list" Or Resource = "order_new" Or Resource = "order_cancel" Or Resource = "order_cancel/all" Then | ||
_Client.BaseAddress = New Uri(Configuration.BaseUrlTRADEAPI) | ||
End If | ||
|
||
If Resource = "cotacao" Or Resource = "trade/advance" Then | ||
_Client.BaseAddress = New Uri(Configuration.BaseUrlWS) | ||
End If | ||
|
||
Result = Await CreateRequestAsync(Resource, HttpMethod.Post, Parameters).ConfigureAwait(True) | ||
Response = Await Result.Content.ReadAsStringAsync().ConfigureAwait(False) | ||
|
||
If IsNumeric(Response) Then | ||
Response = "{""status"":" & Response & ", ""message"": ""Error Here""}" | ||
GoTo G | ||
End If | ||
|
||
If Resource.Contains("trades?from=") OrElse Resource.Contains("account_bank_list") OrElse Resource.Contains("order_get") OrElse Resource.Contains("order_list") OrElse Resource.Contains("order_new") Then | ||
Response = "{""root"":" & Response & "}".Replace(vbCrLf, "").Replace(vbTab, "") | ||
End If | ||
|
||
G: | ||
|
||
Deserialized = Deserialize(Of T)(Response) | ||
HandleError(Deserialized.Status, Deserialized.Message, noThrow:=noThrow) | ||
Return Deserialized | ||
End Function | ||
Public Shared Sub ConfigureClient(Client As HttpClient, ByVal Configuration As ApiConfig) | ||
Client.BaseAddress = New Uri(Configuration.BaseUrlAPI) | ||
End Sub | ||
Protected Friend Overridable Function CreateRequestAsync(ByVal Resource As String, ByVal Method As HttpMethod, ByVal Parameters As Dictionary(Of String, String)) As Task(Of HttpResponseMessage) | ||
Dim content = New FormUrlEncodedContent(CreateParameterPairs(Parameters)) | ||
Return _Client.SendAsync(New HttpRequestMessage(Method, New Uri(Resource, UriKind.Relative)) With {.Content = content}) | ||
End Function | ||
Public Shared Function Create(ByVal Config As ApiConfig, ByVal Optional Client As HttpClient = Nothing, ByVal Optional DisposeClient As Boolean = False) As HttpClientRequester | ||
If Client Is Nothing Then DisposeClient = True | ||
Client = If(Client, New HttpClient()) | ||
HttpClientRequester.ConfigureClient(Client, Config) | ||
Return New HttpClientRequester(Config, Client) With {._DisposeClient = DisposeClient} | ||
End Function | ||
Public Sub Dispose() Implements IDisposable.Dispose | ||
If _DisposeClient Then _Client.Dispose() | ||
End Sub | ||
End Class | ||
End Namespace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
|
||
Namespace Bitnuvem | ||
''' <summary> | ||
''' *** MADE FOR GITHUB *** | ||
''' WRITTEN BY ROMULO MEIRELLES. | ||
''' UPWORK: https://www.upwork.com/freelancers/~01fcbc5039ac5766b4 | ||
''' CONTACT WHATSAPP: https://wa.me/message/KWIS3BYO6K24N1 | ||
''' CONTACT TELEGRAM: https://t.me/Romulo_Meirelles | ||
''' GITHUB: https://github.com/Romulo-Meirelles | ||
''' DISCORD: đąяķňέs§¢øďε#2786 | ||
''' </summary> | ||
''' <remarks></remarks> | ||
Public Interface IRequester | ||
ReadOnly Property Configuration As ApiConfig | ||
Function Post(Of T As BitnuvemResponse)(ByVal resource As String, ByVal Optional parameters As Dictionary(Of String, String) = Nothing, ByVal Optional noThrow As Boolean = False) As Task(Of T) | ||
End Interface | ||
End Namespace |
Oops, something went wrong.