Refine tofiling
MODIFY
WalletWasabi.Tests/KeyManagementTests.cs
WalletWasabi.Tests/KeyManagementTests.cs
@@ -112,7 +112,7 @@ namespace WalletWasabi.Tests
var isInternal = random.Next(2) == 0;
var label = RandomString.Generate(21);
var keyState = (KeyState)random.Next(3);
- manager.GenerateNewKey(label, keyState, isInternal);
+ manager.GenerateNewKey(label, keyState, isInternal, toFile: false);
}
manager.ToFile();

MODIFY
WalletWasabi/KeyManagement/KeyManager.cs
WalletWasabi/KeyManagement/KeyManager.cs
@@ -140,7 +140,7 @@ namespace WalletWasabi.KeyManagement
return km;
}
- public HdPubKey GenerateNewKey(string label, KeyState keyState, bool isInternal)
+ public HdPubKey GenerateNewKey(string label, KeyState keyState, bool isInternal, bool toFile = true)
{
// BIP44-ish derivation scheme
// m / purpose' / coin_type' / account' / change / address_index
@@ -174,7 +174,10 @@ namespace WalletWasabi.KeyManagement
var hdPubKey = new HdPubKey(pubKey, fullPath, label, keyState);
HdPubKeys.Add(hdPubKey);
+ if (toFile)
+ {
ToFile();
+ }
return hdPubKey;
}

MODIFY
WalletWasabi/Services/CcjClient.cs
WalletWasabi/Services/CcjClient.cs
@@ -201,8 +201,10 @@ namespace WalletWasabi.Services
CustomActiveAddresses.RemoveFirst();
}
}
- changeAddress = changeAddress ?? KeyManager.GenerateNewKey("ZeroLink Change", KeyState.Locked, isInternal: true).GetP2wpkhAddress(Network);
- activeAddress = activeAddress ?? KeyManager.GenerateNewKey("ZeroLink Mixed Coin", KeyState.Locked, isInternal: true).GetP2wpkhAddress(Network);
+ changeAddress = changeAddress ?? KeyManager.GenerateNewKey("ZeroLink Change", KeyState.Locked, isInternal: true, toFile: false).GetP2wpkhAddress(Network);
+ activeAddress = activeAddress ?? KeyManager.GenerateNewKey("ZeroLink Mixed Coin", KeyState.Locked, isInternal: true, toFile: false).GetP2wpkhAddress(Network);
+ KeyManager.ToFile();
+
var blind = CoordinatorPubKey.Blind(activeAddress.ScriptPubKey.ToBytes());
var inputProofs = new List<InputProofModel>();

MODIFY
WalletWasabi/Services/WalletService.cs
WalletWasabi/Services/WalletService.cs
@@ -220,12 +220,12 @@ namespace WalletWasabi.Services
{
while (KeyManager.GetKeys(KeyState.Clean, true).Count() < howMany)
{
- KeyManager.GenerateNewKey("", KeyState.Clean, true);
+ KeyManager.GenerateNewKey("", KeyState.Clean, true, toFile: false);
generated = true;
}
while (KeyManager.GetKeys(KeyState.Clean, false).Count() < howMany)
{
- KeyManager.GenerateNewKey("", KeyState.Clean, false);
+ KeyManager.GenerateNewKey("", KeyState.Clean, false, toFile: false);
generated = true;
}
}
@@ -233,10 +233,15 @@ namespace WalletWasabi.Services
{
while (KeyManager.GetKeys(KeyState.Clean, isInternal).Count() < howMany)
{
- KeyManager.GenerateNewKey("", KeyState.Clean, (bool)isInternal);
+ KeyManager.GenerateNewKey("", KeyState.Clean, (bool)isInternal, toFile: false);
generated = true;
}
}
+
+ if(generated)
+ {
+ KeyManager.ToFile();
+ }
return generated;
}

Refine tofiling