Reverse moving runtimeparams
MODIFY
WalletWasabi.Fluent.Desktop/Program.cs
WalletWasabi.Fluent.Desktop/Program.cs
@@ -133,8 +133,7 @@ namespace WalletWasabi.Fluent.Desktop
private static Global CreateGlobal(string dataDir, UiConfig uiConfig, Config config)
{
string torLogsFile = Path.Combine(dataDir, "TorLogs.txt");
- RuntimeParams.SetDataDir(dataDir);
- var walletManager = new WalletManager(config.Network, new WalletDirectories(config.Network, dataDir));
+ var walletManager = new WalletManager(config.Network, dataDir, new WalletDirectories(config.Network, dataDir));
return new Global(dataDir, torLogsFile, config, uiConfig, walletManager);
}

MODIFY
WalletWasabi.Gui/Program.cs
WalletWasabi.Gui/Program.cs
@@ -73,8 +73,7 @@ namespace WalletWasabi.Gui
var config = new Config(Path.Combine(dataDir, "Config.json"));
config.LoadOrCreateDefaultFile();
config.CorrectMixUntilAnonymitySet();
- RuntimeParams.SetDataDir(dataDir);
- var walletManager = new WalletManager(config.Network, new WalletDirectories(config.Network, dataDir));
+ var walletManager = new WalletManager(config.Network, dataDir, new WalletDirectories(config.Network, dataDir));
return new Global(dataDir, torLogsFile, config, uiConfig, walletManager);
}

MODIFY
WalletWasabi.Tests/IntegrationTests/P2pTests.cs
WalletWasabi.Tests/IntegrationTests/P2pTests.cs
@@ -107,6 +107,7 @@ namespace WalletWasabi.Tests.IntegrationTests
keyManager,
syncer,
nodes,
+ dataDir,
new ServiceConfiguration(MixUntilAnonymitySet.PrivacyLevelStrong.ToString(), 2, 21, 50, new IPEndPoint(IPAddress.Loopback, network.DefaultPort), Money.Coins(Constants.DefaultDustThreshold)),
syncer,
blockProvider);

MODIFY
WalletWasabi.Tests/RegressionTests/BuildTests.cs
WalletWasabi.Tests/RegressionTests/BuildTests.cs
@@ -58,11 +58,13 @@ namespace WalletWasabi.Tests.RegressionTests
// 4. Create key manager service.
var keyManager = KeyManager.CreateNew(out _, password);
+ // 5. Create wallet service.
+ var workDir = Helpers.Common.GetWorkDir();
CachedBlockProvider blockProvider = new CachedBlockProvider(
new P2pBlockProvider(nodes, null, synchronizer, serviceConfiguration, network),
bitcoinStore.BlockRepository);
- using var wallet = Wallet.CreateAndRegisterServices(network, bitcoinStore, keyManager, synchronizer, nodes, serviceConfiguration, synchronizer, blockProvider);
+ using var wallet = Wallet.CreateAndRegisterServices(network, bitcoinStore, keyManager, synchronizer, nodes, workDir, serviceConfiguration, synchronizer, blockProvider);
wallet.NewFilterProcessed += Common.Wallet_NewFilterProcessed;
var scp = new Key().ScriptPubKey;
@@ -225,7 +227,7 @@ namespace WalletWasabi.Tests.RegressionTests
CachedBlockProvider blockProvider = new CachedBlockProvider(
new P2pBlockProvider(nodes, null, synchronizer, serviceConfiguration, network),
bitcoinStore.BlockRepository);
- var walletManager = new WalletManager(network, new WalletDirectories(network, workDir));
+ var walletManager = new WalletManager(network, workDir, new WalletDirectories(network, workDir));
walletManager.RegisterServices(bitcoinStore, synchronizer, nodes, serviceConfiguration, synchronizer, blockProvider);
var baseTip = await rpc.GetBestBlockHashAsync();

MODIFY
WalletWasabi.Tests/RegressionTests/CoinJoinTests.cs
WalletWasabi.Tests/RegressionTests/CoinJoinTests.cs
@@ -1386,6 +1386,9 @@ namespace WalletWasabi.Tests.RegressionTests
// 4. Create key manager service.
var keyManager = KeyManager.CreateNew(out _, password);
+ // 5. Create wallet service.
+ var workDir = Helpers.Common.GetWorkDir();
+
var keyManager2 = KeyManager.CreateNew(out _, password);
CachedBlockProvider blockProvider = new CachedBlockProvider(
@@ -1396,10 +1399,11 @@ namespace WalletWasabi.Tests.RegressionTests
new P2pBlockProvider(nodes2, null, synchronizer, serviceConfiguration, network),
bitcoinStore.BlockRepository);
- using var wallet = Wallet.CreateAndRegisterServices(network, bitcoinStore, keyManager, synchronizer, nodes, serviceConfiguration, synchronizer, blockProvider);
+ using var wallet = Wallet.CreateAndRegisterServices(network, bitcoinStore, keyManager, synchronizer, nodes, workDir, serviceConfiguration, synchronizer, blockProvider);
wallet.NewFilterProcessed += Common.Wallet_NewFilterProcessed;
- using var wallet2 = Wallet.CreateAndRegisterServices(network, bitcoinStore, keyManager2, synchronizer2, nodes2, serviceConfiguration, synchronizer2, blockProvider2);
+ var workDir2 = Path.Combine(Helpers.Common.GetWorkDir(), "2");
+ using var wallet2 = Wallet.CreateAndRegisterServices(network, bitcoinStore, keyManager2, synchronizer2, nodes2, workDir2, serviceConfiguration, synchronizer2, blockProvider2);
// Get some money, make it confirm.
var key = keyManager.GetNextReceiveKey("fundZeroLink", out _);

MODIFY
WalletWasabi.Tests/RegressionTests/SendTests.cs
WalletWasabi.Tests/RegressionTests/SendTests.cs
@@ -62,7 +62,7 @@ namespace WalletWasabi.Tests.RegressionTests
new P2pBlockProvider(nodes, null, synchronizer, serviceConfiguration, network),
bitcoinStore.BlockRepository);
- var walletManager = new WalletManager(network, new WalletDirectories(network, workDir));
+ var walletManager = new WalletManager(network, workDir, new WalletDirectories(network, workDir));
walletManager.RegisterServices(bitcoinStore, synchronizer, nodes, serviceConfiguration, synchronizer, blockProvider);
// Get some money, make it confirm.
@@ -542,7 +542,7 @@ namespace WalletWasabi.Tests.RegressionTests
new P2pBlockProvider(nodes, null, synchronizer, serviceConfiguration, network),
bitcoinStore.BlockRepository);
- var walletManager = new WalletManager(network, new WalletDirectories(network, workDir));
+ var walletManager = new WalletManager(network, workDir, new WalletDirectories(network, workDir));
walletManager.RegisterServices(bitcoinStore, synchronizer, nodes, serviceConfiguration, synchronizer, blockProvider);
// Get some money, make it confirm.
@@ -709,11 +709,14 @@ namespace WalletWasabi.Tests.RegressionTests
// 4. Create key manager service.
var keyManager = KeyManager.CreateNew(out _, password);
+ // 5. Create wallet service.
+ var workDir = Helpers.Common.GetWorkDir();
+
CachedBlockProvider blockProvider = new CachedBlockProvider(
new P2pBlockProvider(nodes, null, synchronizer, serviceConfiguration, network),
bitcoinStore.BlockRepository);
- using var wallet = Wallet.CreateAndRegisterServices(network, bitcoinStore, keyManager, synchronizer, nodes, serviceConfiguration, synchronizer, blockProvider);
+ using var wallet = Wallet.CreateAndRegisterServices(network, bitcoinStore, keyManager, synchronizer, nodes, workDir, serviceConfiguration, synchronizer, blockProvider);
wallet.NewFilterProcessed += Common.Wallet_NewFilterProcessed;
Assert.Empty(wallet.Coins);

MODIFY
WalletWasabi.Tests/RegressionTests/WalletTests.cs
WalletWasabi.Tests/RegressionTests/WalletTests.cs
@@ -249,11 +249,14 @@ namespace WalletWasabi.Tests.RegressionTests
// 3. Create key manager service.
var keyManager = KeyManager.CreateNew(out _, password);
+ // 4. Create wallet service.
+ var workDir = Helpers.Common.GetWorkDir();
+
CachedBlockProvider blockProvider = new CachedBlockProvider(
new P2pBlockProvider(nodes, null, synchronizer, serviceConfiguration, network),
bitcoinStore.BlockRepository);
- using var wallet = Wallet.CreateAndRegisterServices(network, bitcoinStore, keyManager, synchronizer, nodes, serviceConfiguration, synchronizer, blockProvider);
+ using var wallet = Wallet.CreateAndRegisterServices(network, bitcoinStore, keyManager, synchronizer, nodes, workDir, serviceConfiguration, synchronizer, blockProvider);
wallet.NewFilterProcessed += Common.Wallet_NewFilterProcessed;
// Get some money, make it confirm.

MODIFY
WalletWasabi/Wallets/Wallet.cs
WalletWasabi/Wallets/Wallet.cs
@@ -29,15 +29,17 @@ namespace WalletWasabi.Wallets
{
private WalletState _state;
- public Wallet(Network network, string filePath) : this(network, KeyManager.FromFile(filePath))
+ public Wallet(string dataDir, Network network, string filePath) : this(dataDir, network, KeyManager.FromFile(filePath))
{
}
- public Wallet(Network network, KeyManager keyManager)
+ public Wallet(string dataDir, Network network, KeyManager keyManager)
{
+ Guard.NotNullOrEmptyOrWhitespace(nameof(dataDir), dataDir);
Network = Guard.NotNull(nameof(network), network);
KeyManager = Guard.NotNull(nameof(keyManager), keyManager);
+ RuntimeParams.SetDataDir(dataDir);
HandleFiltersLock = new AsyncLock();
KeyManager.AssertCleanKeysIndexed();
@@ -486,9 +488,9 @@ namespace WalletWasabi.Wallets
State = WalletState.WaitingForInit;
}
- public static Wallet CreateAndRegisterServices(Network network, BitcoinStore bitcoinStore, KeyManager keyManager, WasabiSynchronizer synchronizer, NodesGroup nodes, ServiceConfiguration serviceConfiguration, IFeeProvider feeProvider, IBlockProvider blockProvider)
+ public static Wallet CreateAndRegisterServices(Network network, BitcoinStore bitcoinStore, KeyManager keyManager, WasabiSynchronizer synchronizer, NodesGroup nodes, string dataDir, ServiceConfiguration serviceConfiguration, IFeeProvider feeProvider, IBlockProvider blockProvider)
{
- var wallet = new Wallet(network, keyManager);
+ var wallet = new Wallet(dataDir, network, keyManager);
wallet.RegisterServices(bitcoinStore, synchronizer, nodes, serviceConfiguration, feeProvider, blockProvider);
return wallet;
}

MODIFY
WalletWasabi/Wallets/WalletManager.cs
WalletWasabi/Wallets/WalletManager.cs
@@ -23,11 +23,13 @@ namespace WalletWasabi.Wallets
{
public class WalletManager
{
- public WalletManager(Network network, WalletDirectories walletDirectories)
+ public WalletManager(Network network, string workDir, WalletDirectories walletDirectories)
{
using (BenchmarkLogger.Measure())
{
Network = Guard.NotNull(nameof(network), network);
+ WorkDir = Guard.NotNullOrEmptyOrWhitespace(nameof(workDir), workDir, true);
+ Directory.CreateDirectory(WorkDir);
WalletDirectories = Guard.NotNull(nameof(walletDirectories), walletDirectories);
Wallets = new Dictionary<Wallet, HashSet<uint256>>();
Lock = new object();
@@ -74,6 +76,7 @@ namespace WalletWasabi.Wallets
public Network Network { get; }
public WalletDirectories WalletDirectories { get; }
private IBlockProvider BlockProvider { get; set; }
+ public string WorkDir { get; }
private void RefreshWalletList()
{
@@ -198,7 +201,7 @@ namespace WalletWasabi.Wallets
public Wallet AddWallet(KeyManager keyManager)
{
- Wallet wallet = new Wallet(Network, keyManager);
+ Wallet wallet = new Wallet(WorkDir, Network, keyManager);
AddWallet(wallet);
return wallet;
}
@@ -209,7 +212,7 @@ namespace WalletWasabi.Wallets
Wallet wallet;
try
{
- wallet = new Wallet(Network, walletFullPath);
+ wallet = new Wallet(WorkDir, Network, walletFullPath);
}
catch (Exception ex)
{
@@ -236,7 +239,7 @@ namespace WalletWasabi.Wallets
}
File.Copy(walletBackupFullPath, walletFullPath);
- wallet = new Wallet(Network, walletFullPath);
+ wallet = new Wallet(WorkDir, Network, walletFullPath);
}
AddWallet(wallet);

Reverse moving runtimeparams