Skip to content
This repository has been archived by the owner on Aug 16, 2021. It is now read-only.

Fix for crash on RPC Start when no wallet in node. #291

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions Stratis.Bitcoin/Features/RPC/RPCFeature.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using System;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Stratis.Bitcoin.Builder;
using Stratis.Bitcoin.Builder.Feature;
using Stratis.Bitcoin.Configuration;
using Stratis.Bitcoin.Features.RPC.Controllers;
using Stratis.Bitcoin.Utilities;
using System;

namespace Stratis.Bitcoin.Features.RPC
{
Expand Down Expand Up @@ -45,7 +45,18 @@ public override void Start()
// also copies over singleton instances already defined
foreach (var service in this.fullNodeBuilder.Services)
{
var obj = this.fullNode.Services.ServiceProvider.GetService(service.ServiceType);
object obj = null;

try
{
obj = this.fullNode.Services.ServiceProvider.GetService(service.ServiceType);
}
catch (InvalidOperationException)
{
this.logger.LogWarning("Unable to copy service {service} from Full Node to RPC. Service injection skipped.", service.ServiceType.ToString());
obj = null;
}

if (obj != null && service.Lifetime == ServiceLifetime.Singleton && service.ImplementationInstance == null)
{
collection.AddSingleton(service.ServiceType, obj);
Expand Down