Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
B
Breeze
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
3
Issues
3
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DeStream-public
Breeze
Commits
136bc94a
Commit
136bc94a
authored
Mar 28, 2017
by
Jeremy Bokobza
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added Api and Wallet features
Moved Wallet Controller and types out of the Api
parent
fc9814a6
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
157 additions
and
71 deletions
+157
-71
ControllersTests.cs
Breeze/src/Breeze.Api.Tests/ControllersTests.cs
+2
-2
project.json
Breeze/src/Breeze.Api.Tests/project.json
+2
-1
ApiFeature.cs
Breeze/src/Breeze.Api/ApiFeature.cs
+15
-6
MvcBuilderExtensions.cs
Breeze/src/Breeze.Api/MvcBuilderExtensions.cs
+28
-0
Program.cs
Breeze/src/Breeze.Api/Program.cs
+25
-11
Startup.cs
Breeze/src/Breeze.Api/Startup.cs
+29
-33
project.json
Breeze/src/Breeze.Api/project.json
+3
-3
Program.cs
Breeze/src/Breeze.Deamon/Program.cs
+5
-4
SafeController.cs
Breeze/src/Breeze.Wallet/Controllers/SafeController.cs
+10
-9
SafeCreation.cs
Breeze/src/Breeze.Wallet/Models/SafeCreation.cs
+1
-1
WalletFeature.cs
Breeze/src/Breeze.Wallet/WalletFeature.cs
+35
-0
project.json
Breeze/src/Breeze.Wallet/project.json
+2
-1
No files found.
Breeze/src/Breeze.Api.Tests/ControllersTests.cs
View file @
136bc94a
...
...
@@ -3,10 +3,10 @@ using System.IO;
using
Microsoft.AspNetCore.Mvc
;
using
Xunit
;
using
Moq
;
using
Breeze.Api.Controllers
;
using
Breeze.Api.Models
;
using
Breeze.Wallet.Wrappers
;
using
Breeze.Wallet
;
using
Breeze.Wallet.Controllers
;
using
Breeze.Wallet.Models
;
namespace
Breeze.Api.Tests
{
...
...
Breeze/src/Breeze.Api.Tests/project.json
View file @
136bc94a
...
...
@@ -7,7 +7,8 @@
"dotnet-test-xunit"
:
"1.0.0-rc2-build10025"
,
"Breeze.Api"
:
"1.0.0-*"
,
"Microsoft.DotNet.InternalAbstractions"
:
"1.0.0"
,
"Moq"
:
"4.7.1"
"Moq"
:
"4.7.1"
,
"Breeze.Wallet"
:
"1.0.0-*"
},
"testRunner"
:
"xunit"
,
"frameworks"
:
{
...
...
Breeze/src/Breeze.Api/ApiFeature.cs
View file @
136bc94a
using
Stratis.Bitcoin.Builder
;
using
Microsoft.Extensions.DependencyInjection
;
using
Stratis.Bitcoin.Builder
;
using
Stratis.Bitcoin.Builder.Feature
;
namespace
Breeze.Api
{
public
class
ApiFeature
:
FullNodeFeature
{
{
private
readonly
IFullNodeBuilder
fullNodeBuilder
;
public
ApiFeature
(
IFullNodeBuilder
fullNodeBuilder
)
{
this
.
fullNodeBuilder
=
fullNodeBuilder
;
}
public
override
void
Start
()
{
Program
.
Main
(
null
);
Program
.
Initialize
(
this
.
fullNodeBuilder
.
Services
);
}
}
...
...
@@ -20,11 +28,12 @@ namespace Breeze.Api
features
.
AddFeature
<
ApiFeature
>()
.
FeatureServices
(
services
=>
{
});
{
services
.
AddSingleton
(
fullNodeBuilder
);
});
});
return
fullNodeBuilder
;
}
}
}
}
Breeze/src/Breeze.Api/MvcBuilderExtensions.cs
0 → 100644
View file @
136bc94a
using
System.Linq
;
using
System.Reflection
;
using
Microsoft.AspNetCore.Mvc
;
using
Microsoft.Extensions.DependencyInjection
;
namespace
Breeze.Api
{
public
static
class
MvcBuilderExtensions
{
/// <summary>
/// Finds all the types that are <see cref="Controller"/> and add them to the Api as services.
/// </summary>
/// <param name="builder">The builder</param>
/// <param name="services">The services to look into</param>
/// <returns>The Mvc builder</returns>
public
static
IMvcBuilder
AddControllers
(
this
IMvcBuilder
builder
,
IServiceCollection
services
)
{
var
controllerTypes
=
services
.
Where
(
s
=>
s
.
ServiceType
.
GetTypeInfo
().
BaseType
==
typeof
(
Controller
));
foreach
(
var
controllerType
in
controllerTypes
)
{
builder
.
AddApplicationPart
(
controllerType
.
ServiceType
.
GetTypeInfo
().
Assembly
);
}
builder
.
AddControllersAsServices
();
return
builder
;
}
}
}
Breeze/src/Breeze.Api/Program.cs
View file @
136bc94a
using
System
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
System.IO
;
using
System.Linq
;
using
System.Threading.Tasks
;
using
Microsoft.AspNetCore.Hosting
;
using
Microsoft.
AspNetCore.Builder
;
using
Microsoft.
Extensions.DependencyInjection
;
namespace
Breeze.Api
{
public
class
Program
{
public
static
void
Main
(
string
[]
args
)
{
public
class
Program
{
public
static
void
Main
(
string
[]
args
)
{
Initialize
();
}
public
static
void
Initialize
(
IEnumerable
<
ServiceDescriptor
>
services
=
null
)
{
var
host
=
new
WebHostBuilder
()
.
UseKestrel
()
.
UseContentRoot
(
Directory
.
GetCurrentDirectory
())
.
UseIISIntegration
()
.
ConfigureServices
(
collection
=>
{
if
(
services
==
null
)
{
return
;
}
foreach
(
var
service
in
services
)
{
collection
.
Add
(
service
);
}
})
.
UseStartup
<
Startup
>()
.
Build
();
host
.
Run
();
}
}
}
}
}
Breeze/src/Breeze.Api/Startup.cs
View file @
136bc94a
...
...
@@ -3,44 +3,40 @@ using Microsoft.AspNetCore.Hosting;
using
Microsoft.Extensions.Configuration
;
using
Microsoft.Extensions.DependencyInjection
;
using
Microsoft.Extensions.Logging
;
using
Breeze.Wallet.Wrappers
;
namespace
Breeze.Api
{
public
class
Startup
{
public
Startup
(
IHostingEnvironment
env
)
{
var
builder
=
new
ConfigurationBuilder
()
.
SetBasePath
(
env
.
ContentRootPath
)
.
AddJsonFile
(
"appsettings.json"
,
optional
:
true
,
reloadOnChange
:
true
)
.
AddJsonFile
(
$"appsettings.
{
env
.
EnvironmentName
}
.json"
,
optional
:
true
)
.
AddEnvironmentVariables
();
Configuration
=
builder
.
Build
();
}
public
class
Startup
{
public
Startup
(
IHostingEnvironment
env
)
{
var
builder
=
new
ConfigurationBuilder
()
.
SetBasePath
(
env
.
ContentRootPath
)
.
AddJsonFile
(
"appsettings.json"
,
optional
:
true
,
reloadOnChange
:
true
)
.
AddJsonFile
(
$"appsettings.
{
env
.
EnvironmentName
}
.json"
,
optional
:
true
)
.
AddEnvironmentVariables
();
Configuration
=
builder
.
Build
();
}
public
IConfigurationRoot
Configuration
{
get
;
}
public
IConfigurationRoot
Configuration
{
get
;
}
// This method gets called by the runtime. Use this method to add services to the container.
public
void
ConfigureServices
(
IServiceCollection
services
)
{
// Add framework services.
services
.
AddMvc
()
// add serializers for NBitcoin objects
.
AddJsonOptions
(
options
=>
NBitcoin
.
JsonConverters
.
Serializer
.
RegisterFrontConverters
(
options
.
SerializerSettings
));
// This method gets called by the runtime. Use this method to add services to the container.
public
void
ConfigureServices
(
IServiceCollection
services
)
{
// Add framework services.
services
.
AddMvc
()
// add serializers for NBitcoin objects
.
AddJsonOptions
(
options
=>
NBitcoin
.
JsonConverters
.
Serializer
.
RegisterFrontConverters
(
options
.
SerializerSettings
))
.
AddControllers
(
services
);
}
// add DI classes for controllers.
services
.
AddTransient
<
ISafeWrapper
,
SafeWrapper
>();
services
.
AddTransient
<
ITrackerWrapper
,
TrackerWrapper
>();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public
void
Configure
(
IApplicationBuilder
app
,
IHostingEnvironment
env
,
ILoggerFactory
loggerFactory
)
{
loggerFactory
.
AddConsole
(
this
.
Configuration
.
GetSection
(
"Logging"
));
loggerFactory
.
AddDebug
();
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public
void
Configure
(
IApplicationBuilder
app
,
IHostingEnvironment
env
,
ILoggerFactory
loggerFactory
)
{
loggerFactory
.
AddConsole
(
this
.
Configuration
.
GetSection
(
"Logging"
));
loggerFactory
.
AddDebug
();
app
.
UseMvc
();
}
}
app
.
UseMvc
();
}
}
}
Breeze/src/Breeze.Api/project.json
View file @
136bc94a
{
"dependencies"
:
{
"Breeze.Wallet"
:
"1.0.0-*"
,
"Microsoft.AspNetCore.Mvc"
:
"1.1.2"
,
"Microsoft.AspNetCore.Routing"
:
"1.1.1"
,
"Microsoft.AspNetCore.Server.IISIntegration"
:
"1.1.1"
,
...
...
@@ -8,6 +7,7 @@
"Microsoft.Extensions.Configuration.EnvironmentVariables"
:
"1.1.1"
,
"Microsoft.Extensions.Configuration.FileExtensions"
:
"1.1.1"
,
"Microsoft.Extensions.Configuration.Json"
:
"1.1.1"
,
"Microsoft.Extensions.DependencyModel"
:
"1.1.1"
,
"Microsoft.Extensions.Logging"
:
"1.1.1"
,
"Microsoft.Extensions.Logging.Console"
:
"1.1.1"
,
"Microsoft.Extensions.Logging.Debug"
:
"1.1.1"
,
...
...
@@ -15,7 +15,8 @@
"Microsoft.NETCore.App"
:
"1.1.0"
,
"NBitcoin"
:
"3.0.2.10"
,
"Stratis.Bitcoin"
:
"1.0.1.2-alpha"
,
"System.Reactive"
:
"3.1.1"
"System.Reactive"
:
"3.1.1"
,
"System.Runtime.Loader"
:
"4.3.0"
},
"tools"
:
{
...
...
@@ -34,7 +35,6 @@
"buildOptions"
:
{
"emitEntryPoint"
:
true
,
"preserveCompilationContext"
:
true
},
"runtimeOptions"
:
{
...
...
Breeze/src/Breeze.Deamon/Program.cs
View file @
136bc94a
...
...
@@ -5,6 +5,7 @@ using Stratis.Bitcoin;
using
Stratis.Bitcoin.Builder
;
using
Stratis.Bitcoin.Configuration
;
using
Stratis.Bitcoin.Logging
;
using
Breeze.Wallet
;
namespace
Breeze.Deamon
{
...
...
@@ -16,11 +17,11 @@ namespace Breeze.Deamon
Logs
.
Configure
(
new
LoggerFactory
().
AddConsole
(
LogLevel
.
Trace
,
false
));
NodeSettings
nodeSettings
=
NodeSettings
.
FromArguments
(
args
);
var
node
=
(
FullNode
)
new
FullNodeBuilder
()
.
UseNodeSettings
(
nodeSettings
)
//
.UseWallet()
var
node
=
(
FullNode
)
new
FullNodeBuilder
()
.
UseNodeSettings
(
nodeSettings
)
.
UseWallet
()
.
UseApi
()
//.UseBlockNotification()
//.UseBlockNotification()
.
Build
();
System
.
Console
.
WriteLine
();
...
...
Breeze/src/Breeze.
Api
/Controllers/SafeController.cs
→
Breeze/src/Breeze.
Wallet
/Controllers/SafeController.cs
View file @
136bc94a
...
...
@@ -4,11 +4,12 @@ using System.Linq;
using
System.Net
;
using
System.Security
;
using
Microsoft.AspNetCore.Mvc
;
using
Breeze.
Api
.Models
;
using
Breeze.
Wallet
.Models
;
using
Breeze.Wallet.Wrappers
;
using
Stratis.Bitcoin
;
namespace
Breeze.
Api
.Controllers
namespace
Breeze.
Wallet
.Controllers
{
[
Route
(
"api/[controller]"
)]
public
class
SafeController
:
Controller
...
...
@@ -19,13 +20,13 @@ namespace Breeze.Api.Controllers
{
this
.
safeWrapper
=
safeWrapper
;
}
/// <summary>
/// Creates a new safe on the local machine.
/// </summary>
/// <param name="safeCreation">The object containing the parameters used to create the wallet.</param>
/// <returns>A JSON object contaibibg the mnemonic created for the new wallet.</returns>
[
HttpPost
]
/// <summary>
/// Creates a new safe on the local machine.
/// </summary>
/// <param name="safeCreation">The object containing the parameters used to create the wallet.</param>
/// <returns>A JSON object contaibibg the mnemonic created for the new wallet.</returns>
[
HttpPost
]
public
IActionResult
Create
([
FromBody
]
SafeCreationModel
safeCreation
)
{
// checks the request is valid
...
...
Breeze/src/Breeze.
Api
/Models/SafeCreation.cs
→
Breeze/src/Breeze.
Wallet
/Models/SafeCreation.cs
View file @
136bc94a
...
...
@@ -2,7 +2,7 @@
using
System.Collections.Generic
;
using
System.ComponentModel.DataAnnotations
;
namespace
Breeze.
Api
.Models
namespace
Breeze.
Wallet
.Models
{
/// <summary>
/// Object used to create a new wallet
...
...
Breeze/src/Breeze.Wallet/WalletFeature.cs
0 → 100644
View file @
136bc94a
using
Stratis.Bitcoin.Builder.Feature
;
using
Breeze.Wallet.Controllers
;
using
Breeze.Wallet.Wrappers
;
using
Microsoft.Extensions.DependencyInjection
;
using
Stratis.Bitcoin.Builder
;
namespace
Breeze.Wallet
{
public
class
WalletFeature
:
FullNodeFeature
{
public
override
void
Start
()
{
}
}
public
static
class
WalletFeatureExtension
{
public
static
IFullNodeBuilder
UseWallet
(
this
IFullNodeBuilder
fullNodeBuilder
)
{
fullNodeBuilder
.
ConfigureFeature
(
features
=>
{
features
.
AddFeature
<
WalletFeature
>()
.
FeatureServices
(
services
=>
{
services
.
AddTransient
<
ISafeWrapper
,
SafeWrapper
>();
services
.
AddTransient
<
ITrackerWrapper
,
TrackerWrapper
>();
services
.
AddSingleton
<
SafeController
>();
});
});
return
fullNodeBuilder
;
}
}
}
Breeze/src/Breeze.Wallet/project.json
View file @
136bc94a
...
...
@@ -4,7 +4,8 @@
"dependencies"
:
{
"HBitcoin"
:
"0.1.5"
,
"NBitcoin"
:
"3.0.2.10"
,
"NETStandard.Library"
:
"1.6.1"
"NETStandard.Library"
:
"1.6.1"
,
"Stratis.Bitcoin"
:
"1.0.1.2-alpha"
},
"frameworks"
:
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment