Block download through RPC if available
MODIFY
WalletWasabi.Gui/Global.cs
WalletWasabi.Gui/Global.cs
@@ -463,7 +463,7 @@ namespace WalletWasabi.Gui
Logger.LogWarning(ex);
}
- WalletService = new WalletService(BitcoinStore, keyManager, Synchronizer, ChaumianClient, Nodes, DataDir, Config.ServiceConfiguration, FeeProviders);
+ WalletService = new WalletService(BitcoinStore, keyManager, Synchronizer, ChaumianClient, Nodes, DataDir, Config.ServiceConfiguration, FeeProviders, BitcoinCoreNode?.RpcClient);
ChaumianClient.Start();
Logger.LogInfo("Start Chaumian CoinJoin service...");

MODIFY
WalletWasabi.Gui/Tabs/SettingsView.xaml
WalletWasabi.Gui/Tabs/SettingsView.xaml
</StackPanel>
</StackPanel>
</controls:GroupBox>
- <controls:GroupBox Title="{Binding Network, StringFormat=Alternative Block Source for \{0\}, Converter={StaticResource NetworkStringConverter}}" TextBlock.FontSize="16" Padding="10" Margin="0 5 10 5">
+ <controls:GroupBox IsVisible="{Binding !StartLocalBitcoinCoreOnStartup}" Title="{Binding Network, StringFormat=Alternative Block Source for \{0\}, Converter={StaticResource NetworkStringConverter}}" TextBlock.FontSize="16" Padding="10" Margin="0 5 10 5">
<StackPanel Orientation="Vertical" Spacing="5">
<TextBlock>Set Wasabi to download blocks from a full node you control.</TextBlock>
<StackPanel Margin="0 10" Spacing="5">

MODIFY
WalletWasabi/Services/WalletService.cs
WalletWasabi/Services/WalletService.cs
@@ -2,6 +2,7 @@ using NBitcoin;
using NBitcoin.DataEncoders;
using NBitcoin.Protocol;
using NBitcoin.Protocol.Behaviors;
+using NBitcoin.RPC;
using Nito.AsyncEx;
using System;
using System.Collections.Concurrent;
@@ -89,7 +90,8 @@ namespace WalletWasabi.Services
NodesGroup nodes,
string workFolderDir,
ServiceConfiguration serviceConfiguration,
- IFeeProvider feeProvider)
+ IFeeProvider feeProvider,
+ RPCClient rPCClient)
{
BitcoinStore = Guard.NotNull(nameof(bitcoinStore), bitcoinStore);
KeyManager = Guard.NotNull(nameof(keyManager), keyManager);
@@ -98,6 +100,7 @@ namespace WalletWasabi.Services
ChaumianClient = Guard.NotNull(nameof(chaumianClient), chaumianClient);
ServiceConfiguration = Guard.NotNull(nameof(serviceConfiguration), serviceConfiguration);
FeeProvider = Guard.NotNull(nameof(feeProvider), feeProvider);
+ RPCClient = rPCClient;
ProcessedBlocks = new ConcurrentDictionary<uint256, (Height height, DateTimeOffset dateTime)>();
HandleFiltersLock = new AsyncLock();
@@ -569,6 +572,8 @@ namespace WalletWasabi.Services
}
private async Task<Block> TryDownloadBlockFromLocalNodeAsync(uint256 hash, CancellationToken cancel)
+ {
+ if (RPCClient is null)
{
try
{
@@ -652,6 +657,20 @@ namespace WalletWasabi.Services
Logger.LogWarning(ex);
}
}
+ }
+ else
+ {
+ try
+ {
+ var block = await RPCClient.GetBlockAsync(hash);
+ Logger.LogInfo($"Block acquired from RPC connection: {hash}.");
+ return block;
+ }
+ catch (Exception ex)
+ {
+ Logger.LogWarning(ex);
+ }
+ }
return null;
}
@@ -824,6 +843,8 @@ namespace WalletWasabi.Services
public bool IsDisposed => _disposedValue;
+ public RPCClient RPCClient { get; }
+
protected virtual void Dispose(bool disposing)
{
if (!_disposedValue)

Block download through RPC if available