Skip to content

Commit 6dac1ff

Browse files
turcolchecho1989
andauthored
Adding Rutanio Network (RUTA) (#161)
* Add access to hashkey to use a dynamic string * Add Rutanio networks * Add Rutanio.Node * Add Rutanio to NetworkSelector node and use a custom agent (Blockcore-Ruta) * Use ContenType as a configuration parameter to allow connections with differents daemons (i.e: ElectrumX) * Add node agent instead of Swagger title * Update favicon to use with Rutanio * Update Rutanio nodeBuilder to use same order then Blockcore.Node * RUTA will fall through last case option (XDS) * Introduce network-specific standard script * Framework props were removed; they are global prop * MaxTxFee added. Use the new rules for coindb * favicon feature was removed (for later release) * BIP9 Deployment on place * API title use now Blockcore + coin ticker * ApiTitle more readable * Indentation line to solve PR conflicts Co-authored-by: checho1989 <cheverdolaga@hotmail.com>
1 parent 29194d6 commit 6dac1ff

30 files changed

Lines changed: 1229 additions & 8 deletions

README.md

100755100644
File mode changed.

src/Blockcore.sln

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Node", "Node", "{8820C3A5-7
118118
EndProject
119119
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Blockcore.Node", "Node\Blockcore.Node\Blockcore.Node.csproj", "{D0A183FE-C913-4F8F-92EC-BD4502745140}"
120120
EndProject
121+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Rutanio", "Rutanio", "{50759380-AF62-11EA-BC6D-7563ABA8C5CA}"
122+
EndProject
123+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rutanio.Node", "Networks\Rutanio\Rutanio.Node\Rutanio.Node.csproj", "{EECEF785-EC8C-4037-9BF9-1DACABDE0E3D}"
124+
EndProject
125+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rutanio", "Networks\Rutanio\Rutanio\Rutanio.csproj", "{271E03B3-5DD6-4A16-A54A-1E72AF9B4902}"
126+
EndProject
121127
Global
122128
GlobalSection(SolutionConfigurationPlatforms) = preSolution
123129
Debug|Any CPU = Debug|Any CPU
@@ -296,11 +302,20 @@ Global
296302
{D0A183FE-C913-4F8F-92EC-BD4502745140}.Debug|Any CPU.Build.0 = Debug|Any CPU
297303
{D0A183FE-C913-4F8F-92EC-BD4502745140}.Release|Any CPU.ActiveCfg = Release|Any CPU
298304
{D0A183FE-C913-4F8F-92EC-BD4502745140}.Release|Any CPU.Build.0 = Release|Any CPU
305+
{EECEF785-EC8C-4037-9BF9-1DACABDE0E3D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
306+
{EECEF785-EC8C-4037-9BF9-1DACABDE0E3D}.Debug|Any CPU.Build.0 = Debug|Any CPU
307+
{EECEF785-EC8C-4037-9BF9-1DACABDE0E3D}.Release|Any CPU.ActiveCfg = Release|Any CPU
308+
{EECEF785-EC8C-4037-9BF9-1DACABDE0E3D}.Release|Any CPU.Build.0 = Release|Any CPU
309+
{271E03B3-5DD6-4A16-A54A-1E72AF9B4902}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
310+
{271E03B3-5DD6-4A16-A54A-1E72AF9B4902}.Debug|Any CPU.Build.0 = Debug|Any CPU
311+
{271E03B3-5DD6-4A16-A54A-1E72AF9B4902}.Release|Any CPU.ActiveCfg = Release|Any CPU
312+
{271E03B3-5DD6-4A16-A54A-1E72AF9B4902}.Release|Any CPU.Build.0 = Release|Any CPU
299313
EndGlobalSection
300314
GlobalSection(SolutionProperties) = preSolution
301315
HideSolutionNode = FALSE
302316
EndGlobalSection
303317
GlobalSection(NestedProjects) = preSolution
318+
{50759380-AF62-11EA-BC6D-7563ABA8C5CA} = {3B56C02B-4468-4268-B797-851562789FCC}
304319
{800A5906-C050-4E75-9D7C-0CB1C404A0F8} = {EAE139C2-B19C-4905-9117-8A4068ABD3D2}
305320
{94FEB14E-D123-486D-A24D-D2BE725D96E3} = {EAE139C2-B19C-4905-9117-8A4068ABD3D2}
306321
{E538B76A-513F-46D5-9F14-E35E79B484CA} = {EAE139C2-B19C-4905-9117-8A4068ABD3D2}
@@ -348,6 +363,8 @@ Global
348363
{36CE71D7-812A-40D7-96B7-8220E8E86643} = {88A9A633-DA22-412B-A04C-2A3405D3E2C8}
349364
{8E17F166-F15A-42F7-9407-06CE2A4AA0AF} = {88A9A633-DA22-412B-A04C-2A3405D3E2C8}
350365
{D0A183FE-C913-4F8F-92EC-BD4502745140} = {8820C3A5-74B4-45AB-B80C-2495DFBA4A2B}
366+
{EECEF785-EC8C-4037-9BF9-1DACABDE0E3D} = {50759380-AF62-11EA-BC6D-7563ABA8C5CA}
367+
{271E03B3-5DD6-4A16-A54A-1E72AF9B4902} = {50759380-AF62-11EA-BC6D-7563ABA8C5CA}
351368
EndGlobalSection
352369
GlobalSection(ExtensibilityGlobals) = postSolution
353370
SolutionGuid = {6C780ABA-5872-4B83-AD3F-A5BD423AD907}

src/External/NBitcoin/BIP32/ExtKey.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,12 @@ public static ExtKey Parse(string wif, Network expectedNetwork = null)
2929
private byte nDepth;
3030
private byte[] vchFingerprint = new byte[FingerprintLength];
3131

32-
private static readonly byte[] hashkey = Encoders.ASCII.DecodeData("Bitcoin seed");
32+
private static byte[] hashkey = Encoders.ASCII.DecodeData("Bitcoin seed");
33+
34+
public static void OverrideHashKey(byte[] newHashkey)
35+
{
36+
hashkey = newHashkey;
37+
}
3338

3439
/// <summary>
3540
/// Gets the depth of this extended key from the root key.

src/Features/Blockcore.Features.NodeHost/NodeHostSettings.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ public class NodeHostSettings
5252
/// <summary>Use HTTPS or not.</summary>
5353
public bool UseHttps { get; set; }
5454

55+
/// <summary>Use title from agent</summary>
56+
public string ApiTitle { get; set; }
57+
5558
/// <summary>
5659
/// Initializes an instance of the object from the node configuration.
5760
/// </summary>
@@ -62,6 +65,8 @@ public NodeHostSettings(NodeSettings nodeSettings)
6265

6366
this.logger = nodeSettings.LoggerFactory.CreateLogger(typeof(NodeHostSettings).FullName);
6467

68+
this.ApiTitle = "Blockcore-" + nodeSettings.Network.CoinTicker;
69+
6570
TextFileConfiguration config = nodeSettings.ConfigReader;
6671

6772
this.UseHttps = config.GetOrDefault("usehttps", false);

src/Features/Blockcore.Features.NodeHost/Startup.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public void ConfigureServices(IServiceCollection services)
127127
options.SwaggerDoc("node",
128128
new OpenApiInfo
129129
{
130-
Title = "Blockcore Node API",
130+
Title = hostSettings.ApiTitle + " Node API",
131131
Version = assemblyVersion,
132132
Description = "Access to the Blockcore Node features.",
133133
Contact = new OpenApiContact

src/Features/Blockcore.Features.NodeHost/UI/Pages/_Host.cshtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
@page "/"
2+
@inject NBitcoin.Network Network
23
@namespace Blockcore.Features.NodeHost.UI.Pages
34
@inject NBitcoin.Network Network
45
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@@ -44,7 +45,6 @@
4445
alert(error);
4546
});
4647
}
47-
};
48-
</script>
48+
};</script>
4949
</body>
5050
</html>
Binary file not shown.

src/Features/Blockcore.Features.RPC/RPCFeature.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ public static void BuildDefaultConfigurationFile(StringBuilder builder, Network
5757
builder.AppendLine("#rpcbind=127.0.0.1");
5858
builder.AppendLine("#Ip address allowed to connect to RPC (default all: 0.0.0.0 and ::)");
5959
builder.AppendLine("#rpcallowip=127.0.0.1");
60+
builder.AppendLine("#Can load the RPCContentType with or without charset. (default: application/json; chartset=utf-8)");
61+
builder.AppendLine("#rpccontenttype=application/json");
62+
6063
}
6164

6265
public override Task InitializeAsync()

src/Features/Blockcore.Features.RPC/RPCMiddleware.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,15 @@ public class RPCMiddleware
2828
private readonly IHttpContextFactory httpContextFactory;
2929
private readonly DataFolder dataFolder;
3030

31-
public const string ContentType = "application/json; charset=utf-8";
32-
33-
public RPCMiddleware(RequestDelegate next, IRPCAuthorization authorization, ILoggerFactory loggerFactory, IHttpContextFactory httpContextFactory, DataFolder dataFolder)
31+
public readonly string ContentType;
32+
33+
public RPCMiddleware(
34+
RequestDelegate next,
35+
IRPCAuthorization authorization,
36+
ILoggerFactory loggerFactory,
37+
IHttpContextFactory httpContextFactory,
38+
DataFolder dataFolder,
39+
string contentType = "application/json; charset=utf-8")
3440
{
3541
Guard.NotNull(next, nameof(next));
3642
Guard.NotNull(authorization, nameof(authorization));
@@ -40,6 +46,7 @@ public RPCMiddleware(RequestDelegate next, IRPCAuthorization authorization, ILog
4046
this.logger = loggerFactory.CreateLogger(this.GetType().FullName);
4147
this.httpContextFactory = httpContextFactory;
4248
this.dataFolder = dataFolder;
49+
this.ContentType = contentType;
4350
}
4451

4552
public async Task InvokeAsync(HttpContext httpContext)

src/Features/Blockcore.Features.RPC/RpcSettings.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ public class RpcSettings
4040
/// <summary>List of IP addresses that are allowed to connect to RPC interfaces.</summary>
4141
public List<IPAddressBlock> AllowIp { get; set; }
4242

43+
/// <summary>Can load the RPCContentType with or without charset.</summary>
44+
public string RPCContentType { get; set; }
45+
4346
/// <summary>
4447
/// Initializes an instance of the object from the node configuration.
4548
/// </summary>
@@ -71,6 +74,7 @@ private void LoadSettingsFromConfig(NodeSettings nodeSettings)
7174

7275
this.Server = config.GetOrDefault<bool>("server", false, this.logger);
7376
this.RPCPort = config.GetOrDefault<int>("rpcport", nodeSettings.Network.DefaultRPCPort, this.logger);
77+
this.RPCContentType = config.GetOrDefault("rpccontenttype", "application/json; charset=utf-8", this.logger);
7478

7579
if (this.Server)
7680
{
@@ -157,6 +161,7 @@ public static void PrintHelp(Network network)
157161
builder.AppendLine($"-rpcport=<0-65535> Listen for JSON-RPC connections on <port>. Default: {network.DefaultRPCPort}");
158162
builder.AppendLine($"-rpcbind=<ip:port> Bind to given address to listen for JSON-RPC connections. This option can be specified multiple times. Default: bind to all interfaces");
159163
builder.AppendLine($"-rpcallowip=<ip> Allow JSON-RPC connections from specified source. This option can be specified multiple times.");
164+
builder.AppendLine($"-rpccontentype=<string> Use application/json to connect with other daemons like ElectrumX");
160165

161166
defaults.Logger.LogInformation(builder.ToString());
162167
}

0 commit comments

Comments
 (0)