Commit 762533d5 authored by Jeremy Bokobza's avatar Jeremy Bokobza

Moved the wallet interfaces out of the API.

The idea is to now have the web API and the wallet as features (FullNodeFeature) of the Full node, and to have a deamon that gets started by the GUI and that starts the FullNode that will in turn start the API so that the GUI and the FUllNode can communicate.
parent 114342e1
...@@ -9,3 +9,8 @@ ...@@ -9,3 +9,8 @@
/Breeze.Api/src/Breeze.Api/obj /Breeze.Api/src/Breeze.Api/obj
*.user *.user
/Breeze.Api/src/Breeze.Api/Wallets /Breeze.Api/src/Breeze.Api/Wallets
/Breeze.Api/src/Breeze.Wallet/bin
/Breeze.Api/src/Breeze.Wallet/obj
# DNX
project.lock.json
...@@ -15,6 +15,8 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Breeze.Api", "src\Breeze.Ap ...@@ -15,6 +15,8 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Breeze.Api", "src\Breeze.Ap
EndProject EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Breeze.Api.Tests", "src\Breeze.Api.Tests\Breeze.Api.Tests.xproj", "{BD5174B4-DCE8-4594-9A16-B83E56767770}" Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Breeze.Api.Tests", "src\Breeze.Api.Tests\Breeze.Api.Tests.xproj", "{BD5174B4-DCE8-4594-9A16-B83E56767770}"
EndProject EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Breeze.Wallet", "src\Breeze.Wallet\Breeze.Wallet.xproj", "{D16CD478-9D1E-4C69-91AD-43539E94A215}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
...@@ -29,6 +31,10 @@ Global ...@@ -29,6 +31,10 @@ Global
{BD5174B4-DCE8-4594-9A16-B83E56767770}.Debug|Any CPU.Build.0 = Debug|Any CPU {BD5174B4-DCE8-4594-9A16-B83E56767770}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BD5174B4-DCE8-4594-9A16-B83E56767770}.Release|Any CPU.ActiveCfg = Release|Any CPU {BD5174B4-DCE8-4594-9A16-B83E56767770}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BD5174B4-DCE8-4594-9A16-B83E56767770}.Release|Any CPU.Build.0 = Release|Any CPU {BD5174B4-DCE8-4594-9A16-B83E56767770}.Release|Any CPU.Build.0 = Release|Any CPU
{D16CD478-9D1E-4C69-91AD-43539E94A215}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D16CD478-9D1E-4C69-91AD-43539E94A215}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D16CD478-9D1E-4C69-91AD-43539E94A215}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D16CD478-9D1E-4C69-91AD-43539E94A215}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
...@@ -36,5 +42,6 @@ Global ...@@ -36,5 +42,6 @@ Global
GlobalSection(NestedProjects) = preSolution GlobalSection(NestedProjects) = preSolution
{E7B3E9EB-34E8-4B10-B296-4D5270E314A4} = {807563C4-7259-434D-B604-A14C3DCF8E30} {E7B3E9EB-34E8-4B10-B296-4D5270E314A4} = {807563C4-7259-434D-B604-A14C3DCF8E30}
{BD5174B4-DCE8-4594-9A16-B83E56767770} = {807563C4-7259-434D-B604-A14C3DCF8E30} {BD5174B4-DCE8-4594-9A16-B83E56767770} = {807563C4-7259-434D-B604-A14C3DCF8E30}
{D16CD478-9D1E-4C69-91AD-43539E94A215} = {807563C4-7259-434D-B604-A14C3DCF8E30}
EndGlobalSection EndGlobalSection
EndGlobal EndGlobal
...@@ -5,7 +5,8 @@ using Xunit; ...@@ -5,7 +5,8 @@ using Xunit;
using Moq; using Moq;
using Breeze.Api.Controllers; using Breeze.Api.Controllers;
using Breeze.Api.Models; using Breeze.Api.Models;
using Breeze.Api.Wrappers; using Breeze.Wallet.Wrappers;
using Breeze.Wallet;
namespace Breeze.Api.Tests namespace Breeze.Api.Tests
{ {
......
This source diff could not be displayed because it is too large. You can view the blob instead.
using Microsoft.AspNetCore.Mvc;
namespace Breeze.Api.Controllers
{
[Route("api/[controller]")]
public class NodeController : Controller
{
[Route("connect")]
public IActionResult Connect(string[] args)
{
return NotFound();
}
[Route("status")]
public IActionResult Status()
{
return this.NotFound();
}
}
}
...@@ -5,7 +5,7 @@ using System.Net; ...@@ -5,7 +5,7 @@ using System.Net;
using System.Security; using System.Security;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Breeze.Api.Models; using Breeze.Api.Models;
using Breeze.Api.Wrappers; using Breeze.Wallet.Wrappers;
namespace Breeze.Api.Controllers namespace Breeze.Api.Controllers
......
...@@ -49,13 +49,4 @@ namespace Breeze.Api.Models ...@@ -49,13 +49,4 @@ namespace Breeze.Api.Models
public string Network { get; set; } public string Network { get; set; }
} }
public class SafeModel
{
public string Network { get; set; }
public string FileName { get; set; }
public IEnumerable<string> Addresses { get; set; }
}
} }
...@@ -3,7 +3,7 @@ using Microsoft.AspNetCore.Hosting; ...@@ -3,7 +3,7 @@ using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Breeze.Api.Wrappers; using Breeze.Wallet.Wrappers;
namespace Breeze.Api namespace Breeze.Api
{ {
...@@ -32,8 +32,6 @@ namespace Breeze.Api ...@@ -32,8 +32,6 @@ namespace Breeze.Api
// add DI classes for controllers. // add DI classes for controllers.
services.AddTransient<ISafeWrapper, SafeWrapper>(); services.AddTransient<ISafeWrapper, SafeWrapper>();
services.AddTransient<ITrackerWrapper, TrackerWrapper>(); services.AddTransient<ITrackerWrapper, TrackerWrapper>();
} }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
......
{ {
"dependencies": { "dependencies": {
"HBitcoin": "0.1.4", "Breeze.Wallet": "1.0.0-*",
"Microsoft.AspNetCore.Mvc": "1.1.2", "Microsoft.AspNetCore.Mvc": "1.1.2",
"Microsoft.AspNetCore.Routing": "1.1.1", "Microsoft.AspNetCore.Routing": "1.1.1",
"Microsoft.AspNetCore.Server.IISIntegration": "1.1.1", "Microsoft.AspNetCore.Server.IISIntegration": "1.1.1",
...@@ -12,7 +12,9 @@ ...@@ -12,7 +12,9 @@
"Microsoft.Extensions.Logging.Console": "1.1.1", "Microsoft.Extensions.Logging.Console": "1.1.1",
"Microsoft.Extensions.Logging.Debug": "1.1.1", "Microsoft.Extensions.Logging.Debug": "1.1.1",
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.1.1", "Microsoft.Extensions.Options.ConfigurationExtensions": "1.1.1",
"Microsoft.NETCore.App": "1.1.1" "Microsoft.NETCore.App": "1.1.1",
"NBitcoin": "3.0.2.10",
"System.Reactive": "3.1.1"
}, },
"tools": { "tools": {
......
This source diff could not be displayed because it is too large. You can view the blob instead.
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>d16cd478-9d1e-4c69-91ad-43539e94a215</ProjectGuid>
<RootNamespace>Breeze.Wallet</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Breeze.Wallet")]
[assembly: AssemblyTrademark("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("d16cd478-9d1e-4c69-91ad-43539e94a215")]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Breeze.Wallet
{
public class SafeModel
{
public string Network { get; set; }
public string FileName { get; set; }
public IEnumerable<string> Addresses { get; set; }
}
}
using Breeze.Api.Models; 
namespace Breeze.Wallet.Wrappers
namespace Breeze.Api.Wrappers
{ {
/// <summary> /// <summary>
/// An interface enabling wallet operations. /// An interface enabling wallet operations.
......
using NBitcoin; using NBitcoin;
namespace Breeze.Api.Wrappers namespace Breeze.Wallet.Wrappers
{ {
public interface ITrackerWrapper public interface ITrackerWrapper
{ {
void NotifyAboutBlock(int height, Block block); void NotifyAboutBlock(int height, Block block);
uint256 GetLastProcessedBlock();
} }
} }
...@@ -2,9 +2,8 @@ ...@@ -2,9 +2,8 @@
using System.Linq; using System.Linq;
using HBitcoin.KeyManagement; using HBitcoin.KeyManagement;
using NBitcoin; using NBitcoin;
using Breeze.Api.Models;
namespace Breeze.Api.Wrappers namespace Breeze.Wallet.Wrappers
{ {
/// <summary> /// <summary>
/// An implementation of the <see cref="ISafeWrapper"/> interface. /// An implementation of the <see cref="ISafeWrapper"/> interface.
......
using NBitcoin; using NBitcoin;
using HBitcoin.FullBlockSpv; using HBitcoin.FullBlockSpv;
using HBitcoin.Models; using HBitcoin.Models;
using System;
namespace Breeze.Api.Wrappers namespace Breeze.Wallet.Wrappers
{ {
public class TrackerWrapper : ITrackerWrapper public class TrackerWrapper : ITrackerWrapper
{ {
private readonly Tracker tracker; private readonly Tracker tracker;
public TrackerWrapper(Network network) public TrackerWrapper()
{ {
this.tracker = new Tracker(network); this.tracker = new Tracker();
}
/// <summary>
/// Get the hash of the last block that has been succesfully processed.
/// </summary>
/// <returns>The hash of the block</returns>
public uint256 GetLastProcessedBlock()
{
// TODO use Tracker.BestHeight. Genesis hash for now.
return uint256.Parse("000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f");
} }
public void NotifyAboutBlock(int height, Block block) public void NotifyAboutBlock(int height, Block block)
{ {
this.tracker.AddOrReplaceBlock(new Height(height), block); this.tracker.AddOrReplaceBlock(new Height(height), block);
Console.WriteLine($"height: {height}, block hash: {block.Header.GetHash()}");
} }
} }
} }
{
"version": "1.0.0-*",
"dependencies": {
"HBitcoin": "0.1.4",
"NBitcoin": "3.0.2.10",
"NETStandard.Library": "1.6.0"
},
"frameworks": {
"netstandard1.6": {
"imports": "dnxcore50"
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment