Initial Commit
commit
f10a75c82c
|
@ -0,0 +1,40 @@
|
|||
# Autosave files
|
||||
*~
|
||||
|
||||
# build
|
||||
[Oo]bj/
|
||||
[Bb]in/
|
||||
packages/
|
||||
TestResults/
|
||||
|
||||
# globs
|
||||
Makefile.in
|
||||
*.DS_Store
|
||||
*.sln.cache
|
||||
*.suo
|
||||
*.cache
|
||||
*.pidb
|
||||
*.userprefs
|
||||
*.usertasks
|
||||
config.log
|
||||
config.make
|
||||
config.status
|
||||
aclocal.m4
|
||||
install-sh
|
||||
autom4te.cache/
|
||||
*.user
|
||||
*.tar.gz
|
||||
tarballs/
|
||||
test-results/
|
||||
Thumbs.db
|
||||
|
||||
# Mac bundle stuff
|
||||
*.dmg
|
||||
*.app
|
||||
|
||||
# resharper
|
||||
*_Resharper.*
|
||||
*.Resharper
|
||||
|
||||
# dotCover
|
||||
*.dotCover
|
|
@ -0,0 +1,28 @@
|
|||
using System;
|
||||
namespace cryptonote
|
||||
{
|
||||
public class BlockTemplate
|
||||
{
|
||||
public BlockTemplate(byte[] blob, Int64 difficulty, Int64 height, string prev_hash, Int64 reserved_offset, Int64 reserve_size)
|
||||
{
|
||||
this.Blob = blob;
|
||||
this.Height = height;
|
||||
this.Difficulty = difficulty;
|
||||
this.PreviousHash = prev_hash;
|
||||
this.ReservedOffset = reserved_offset;
|
||||
this.ReserveSize = reserve_size;
|
||||
|
||||
}
|
||||
|
||||
public byte[] Blob { get; private set; }
|
||||
public Int64 Difficulty { get; private set; }
|
||||
public Int64 Height { get; private set; }
|
||||
public Int64 ReservedOffset { get; private set; }
|
||||
public Int64 ReserveSize { get; private set; }
|
||||
public string PreviousHash { get; private set; }
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
// Information about this assembly is defined by the following attributes.
|
||||
// Change them to the values specific to your project.
|
||||
|
||||
[assembly: AssemblyTitle("cryptonote")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("")]
|
||||
[assembly: AssemblyCopyright("")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
|
||||
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
|
||||
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
|
||||
|
||||
[assembly: AssemblyVersion("1.0.*")]
|
||||
|
||||
// The following attributes are used to specify the signing key for the assembly,
|
||||
// if desired. See the Mono documentation for more information about signing.
|
||||
|
||||
//[assembly: AssemblyDelaySign(false)]
|
||||
//[assembly: AssemblyKeyFile("")]
|
|
@ -0,0 +1,65 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{52C68C13-2DC2-438A-9EC1-E8C4953B07DF}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<RootNamespace>cryptonote</RootNamespace>
|
||||
<AssemblyName>cryptonote</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug</OutputPath>
|
||||
<DefineConstants>DEBUG;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="Newtonsoft.Json">
|
||||
<HintPath>..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="BlockTemplate.cs" />
|
||||
<Compile Include="rpc\Daemon.cs" />
|
||||
<Compile Include="tools\HexString.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\JSONRPC\JSONRPC.csproj">
|
||||
<Project>{DCE6066E-9709-4D12-8994-F7879C3557D6}</Project>
|
||||
<Name>JSONRPC</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="rpc\" />
|
||||
<Folder Include="tools\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<ProjectExtensions>
|
||||
<MonoDevelop>
|
||||
<Properties>
|
||||
<Policies>
|
||||
<DotNetNamingPolicy DirectoryNamespaceAssociation="PrefixedHierarchical" ResourceNamePolicy="FileFormatDefault" />
|
||||
</Policies>
|
||||
</Properties>
|
||||
</MonoDevelop>
|
||||
</ProjectExtensions>
|
||||
</Project>
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Newtonsoft.Json" version="10.0.3" targetFramework="net45" />
|
||||
</packages>
|
|
@ -0,0 +1,68 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using JSONRPC;
|
||||
using cryptonote.tools;
|
||||
|
||||
namespace cryptonote.rpc
|
||||
{
|
||||
public class Daemon
|
||||
{
|
||||
RPCConnector rpc;
|
||||
|
||||
public Daemon(string host,int port)
|
||||
{
|
||||
this.rpc = new RPCConnector(host, port);
|
||||
}
|
||||
|
||||
|
||||
public int GetBlockCount(){
|
||||
Response response = rpc.Call("getblockcount");
|
||||
if (response.Success()){
|
||||
return Convert.ToInt32(response.result["count"].ToObject<int>());
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public BlockTemplate getBlockTemplate(string wallet,uint reserve_size){
|
||||
BlockTemplate bt = null;
|
||||
Response response = this.rpc.Call()
|
||||
.method("getblocktemplate")
|
||||
.parameter("wallet_address", wallet)
|
||||
.parameter("reserve_size", 60)
|
||||
.execute();
|
||||
|
||||
if (response.Success()){
|
||||
byte[] blob = HexString.toBytes(response.result["blocktemplate_blob"].ToString());
|
||||
bt = new BlockTemplate(
|
||||
blob,
|
||||
response.result["difficulty"].ToObject<Int64>(),
|
||||
response.result["height"].ToObject<Int64>(),
|
||||
response.result["prev_hash"].ToObject<string>(),
|
||||
response.result["reserved_offset"].ToObject<Int64>(),
|
||||
reserve_size
|
||||
);
|
||||
}
|
||||
return bt;
|
||||
}
|
||||
|
||||
public bool check(){
|
||||
return this.rpc.Call("get_info").Success();
|
||||
|
||||
}
|
||||
|
||||
public Int64 getTargetHeight(){
|
||||
Response response = rpc.Call("get_info");
|
||||
if (response.Success()){
|
||||
return response.result["target_height"].ToObject<int>();
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
using System;
|
||||
namespace cryptonote.tools
|
||||
{
|
||||
public class HexString
|
||||
{
|
||||
public static byte[] toBytes(string hexstring)
|
||||
{
|
||||
byte[] bytes = new byte[hexstring.Length >> 1];
|
||||
for (int n = 0; n < hexstring.Length >> 1;n++){
|
||||
bytes[n] = Convert.ToByte(hexstring.Substring(n << 1, 2), 16);
|
||||
}
|
||||
return bytes;
|
||||
}
|
||||
|
||||
public static String toString(byte[] bytes){
|
||||
return BitConverter.ToString(bytes).Replace("-", String.Empty);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue