Commit 2616cb0a authored by Sergei Zubov's avatar Sergei Zubov

Modify light wallet feature

Light wallet feature mostly depends on wallet's source code, which is
already modified.
parent 570e09df
using Microsoft.Extensions.DependencyInjection;
using Stratis.Bitcoin.Builder;
using Stratis.Bitcoin.Features.Consensus;
using Stratis.Bitcoin.Features.LightWallet.Broadcasting;
using Stratis.Bitcoin.Features.Notifications;
using Stratis.Bitcoin.Features.Wallet;
using Stratis.Bitcoin.Features.Wallet.Broadcasting;
using Stratis.Bitcoin.Features.Wallet.Controllers;
using Stratis.Bitcoin.Features.Wallet.Interfaces;
using Stratis.Bitcoin.Interfaces;
using Stratis.Bitcoin.Utilities;
namespace Stratis.Bitcoin.Features.LightWallet
{
public static class DeStreamFullNodeBuilderLightWalletExtension
{
public static IFullNodeBuilder UseDeStreamLightWallet(this IFullNodeBuilder fullNodeBuilder)
{
fullNodeBuilder.ConfigureFeature(features =>
{
// Required to GetStakeMinConfirmations
fullNodeBuilder.Network.Consensus.Options = new DeStreamPosConsensusOptions();
features
.AddFeature<LightWalletFeature>()
.DependOn<BlockNotificationFeature>()
.DependOn<TransactionNotificationFeature>()
.FeatureServices(services =>
{
services.AddSingleton<IWalletSyncManager, DeStreamLightWalletSyncManager>();
services.AddSingleton<IWalletTransactionHandler, DeStreamWalletTransactionHandler>();
services.AddSingleton<IDeStreamWalletManager, DeStreamWalletManager>();
services.AddSingleton<IWalletManager>(p => p.GetService<IDeStreamWalletManager>());
if (fullNodeBuilder.Network.IsBitcoin())
services.AddSingleton<IWalletFeePolicy, LightWalletBitcoinExternalFeePolicy>();
else
services.AddSingleton<IWalletFeePolicy, LightWalletFixedFeePolicy>();
services.AddSingleton<WalletController>();
services.AddSingleton<DeStreamWalletController>();
services.AddSingleton<IBroadcasterManager, LightWalletBroadcasterManager>();
services.AddSingleton<BroadcasterBehavior>();
services.AddSingleton<IInitialBlockDownloadState, LightWalletInitialBlockDownloadState>();
services.AddSingleton<WalletSettings>();
});
});
return fullNodeBuilder;
}
}
}
\ No newline at end of file
using Microsoft.Extensions.Logging;
using NBitcoin;
using Stratis.Bitcoin.Features.Notifications.Interfaces;
using Stratis.Bitcoin.Features.Wallet.Interfaces;
using Stratis.Bitcoin.Signals;
using Stratis.Bitcoin.Utilities;
namespace Stratis.Bitcoin.Features.LightWallet
{
public class DeStreamLightWalletSyncManager : LightWalletSyncManager
{
private readonly IDeStreamWalletManager _deStreamWalletManager;
public DeStreamLightWalletSyncManager(ILoggerFactory loggerFactory, ConcurrentChain chain, Network network,
IBlockNotification blockNotification, ISignals signals, INodeLifetime nodeLifetime,
IAsyncLoopFactory asyncLoopFactory, IDeStreamWalletManager deStreamWalletManager) : base(loggerFactory,
deStreamWalletManager, chain, network, blockNotification, signals, nodeLifetime, asyncLoopFactory)
{
this._deStreamWalletManager = deStreamWalletManager;
}
public override void SyncFromHeight(int height)
{
base.SyncFromHeight(height);
// Wallet's initial state - height 0 and no blocks processed,
// but there may be transactions at height 0.
// This function is called with next unprocessed block height,
// so, processing of genesis block is required on height = 1.
if (height > 1) return;
this._deStreamWalletManager.ProcessGenesisBlock();
this.logger.LogTrace("Genesis block processed");
}
}
}
\ No newline at end of file
......@@ -26,7 +26,7 @@ namespace Stratis.Bitcoin.Features.LightWallet
private readonly IBlockNotification blockNotification;
private readonly ILogger logger;
protected readonly ILogger logger;
private readonly ISignals signals;
......@@ -278,7 +278,7 @@ namespace Stratis.Bitcoin.Features.LightWallet
}
/// <inheritdoc />
public void SyncFromHeight(int height)
public virtual void SyncFromHeight(int height)
{
this.logger.LogTrace("({0}:'{1}')", nameof(height), height);
......
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<AssemblyName>Stratis.Bitcoin.Features.LightWallet</AssemblyName>
......@@ -10,21 +9,18 @@
<Version>1.1.12-beta</Version>
<GeneratePackageOnBuild>False</GeneratePackageOnBuild>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DocumentationFile></DocumentationFile>
<DocumentationFile>
</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="2.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\NBitcoin\NBitcoin.csproj" />
<ProjectReference Include="..\Stratis.Bitcoin.Features.Notifications\Stratis.Bitcoin.Features.Notifications.csproj" />
<ProjectReference Include="..\Stratis.Bitcoin.Features.Wallet\Stratis.Bitcoin.Features.Wallet.csproj" />
<ProjectReference Include="..\Stratis.Bitcoin\Stratis.Bitcoin.csproj" />
</ItemGroup>
</Project>
</Project>
\ No newline at end of file
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