Add failing test SignTransactionAsync and fix the bug
MODIFY
WalletWasabi.Tests/Helpers/WabiSabiFactory.cs
WalletWasabi.Tests/Helpers/WabiSabiFactory.cs
@@ -262,7 +262,7 @@ public static class WabiSabiFactory
public static (IKeyChain, SmartCoin, SmartCoin) CreateCoinKeyPairs()
{
var km = ServiceFactory.CreateKeyManager("");
- var keyChain = new KeyChain(km);
+ var keyChain = new KeyChain(km, new Kitchen(""));
var smartCoin1 = BitcoinFactory.CreateSmartCoin(BitcoinFactory.CreateHdPubKey(km), Money.Coins(1m));
var smartCoin2 = BitcoinFactory.CreateSmartCoin(BitcoinFactory.CreateHdPubKey(km), Money.Coins(2m));

MODIFY
WalletWasabi.Tests/UnitTests/WabiSabi/Backend/AliceTimeoutTests.cs
WalletWasabi.Tests/UnitTests/WabiSabi/Backend/AliceTimeoutTests.cs
@@ -32,7 +32,7 @@ public class AliceTimeoutTests
await roundStateUpdater.StartAsync(CancellationToken.None);
// Register Alices.
- var keyChain = new KeyChain(km);
+ var keyChain = new KeyChain(km, new Kitchen(""));
using CancellationTokenSource cancellationTokenSource = new();
var task = AliceClient.CreateRegisterAndConfirmInputAsync(RoundState.FromRound(round), arenaClient, smartCoin, keyChain, roundStateUpdater, cancellationTokenSource.Token);

MODIFY
WalletWasabi.Tests/UnitTests/WabiSabi/Client/ArenaClientTests.cs
WalletWasabi.Tests/UnitTests/WabiSabi/Client/ArenaClientTests.cs
@@ -198,9 +198,10 @@ public class ArenaClientTests
{
WabiSabiConfig config = new();
Round round = WabiSabiFactory.CreateRound(config);
+ var password = "satoshi";
- var km = ServiceFactory.CreateKeyManager("");
- var keyChain = new KeyChain(km);
+ var km = ServiceFactory.CreateKeyManager(password);
+ var keyChain = new KeyChain(km, new Kitchen(password));
var destinationProvider = new InternalDestinationProvider(km);
var coins = destinationProvider.GetNextDestinations(2)

MODIFY
WalletWasabi.Tests/UnitTests/WabiSabi/Client/BobClientTests.cs
WalletWasabi.Tests/UnitTests/WabiSabi/Client/BobClientTests.cs
@@ -52,7 +52,7 @@ public class BobClientTests
using RoundStateUpdater roundStateUpdater = new(TimeSpan.FromSeconds(2), wabiSabiApi);
await roundStateUpdater.StartAsync(CancellationToken.None);
- var keyChain = new KeyChain(km);
+ var keyChain = new KeyChain(km, new Kitchen(""));
var task = AliceClient.CreateRegisterAndConfirmInputAsync(RoundState.FromRound(round), aliceArenaClient, coin1, keyChain, roundStateUpdater, CancellationToken.None);
do

MODIFY
WalletWasabi.Tests/UnitTests/WabiSabi/Client/KeyChainTests.cs
WalletWasabi.Tests/UnitTests/WabiSabi/Client/KeyChainTests.cs
@@ -4,6 +4,7 @@ using WalletWasabi.Blockchain.Keys;
using WalletWasabi.Crypto;
using WalletWasabi.Tests.Helpers;
using WalletWasabi.WabiSabi.Client;
+using WalletWasabi.Wallets;
using Xunit;
namespace WalletWasabi.Tests.UnitTests.WabiSabi.Client;
@@ -15,7 +16,7 @@ public class KeyChainTests
{
var keyManager = KeyManager.CreateNew(out _, "", Network.Main);
var destinationProvider = new InternalDestinationProvider(keyManager);
- var keyChain = new KeyChain(keyManager);
+ var keyChain = new KeyChain(keyManager, new Kitchen(""));
var coinDestination = destinationProvider.GetNextDestinations(1).First();
var coin = new Coin(BitcoinFactory.CreateOutPoint(), new TxOut(Money.Coins(1.0m), coinDestination));

MODIFY
WalletWasabi.Tests/UnitTests/WabiSabi/Integration/WabiSabiHttpApiIntegrationTests.cs
WalletWasabi.Tests/UnitTests/WabiSabi/Integration/WabiSabiHttpApiIntegrationTests.cs
@@ -20,6 +20,7 @@ using WalletWasabi.WabiSabi.Backend.Rounds.CoinJoinStorage;
using WalletWasabi.WabiSabi.Client;
using WalletWasabi.WabiSabi.Models;
using WalletWasabi.WabiSabi.Models.MultipartyTransaction;
+using WalletWasabi.Wallets;
using WalletWasabi.WebClients.Wasabi;
using Xunit;
@@ -147,7 +148,7 @@ public class WabiSabiHttpApiIntegrationTests : IClassFixture<WabiSabiApiApplicat
await roundStateUpdater.StartAsync(CancellationToken.None);
var coinJoinClient = new CoinJoinClient(mockHttpClientFactory.Object,
- new KeyChain(keyManager),
+ new KeyChain(keyManager, new Kitchen("")),
new InternalDestinationProvider(keyManager),
roundStateUpdater,
consolidationMode: true);
@@ -253,7 +254,7 @@ public class WabiSabiHttpApiIntegrationTests : IClassFixture<WabiSabiApiApplicat
var roundState = await roundStateUpdater.CreateRoundAwaiter(roundState => roundState.Phase == Phase.InputRegistration, cts.Token);
var coinJoinClient = new CoinJoinClient(mockHttpClientFactory.Object,
- new KeyChain(keyManager1),
+ new KeyChain(keyManager1, new Kitchen("")),
new InternalDestinationProvider(keyManager1),
roundStateUpdater,
consolidationMode: true);
@@ -285,7 +286,7 @@ public class WabiSabiHttpApiIntegrationTests : IClassFixture<WabiSabiApiApplicat
.Returns(nonSigningHttpClient);
var badCoinJoinClient = new CoinJoinClient(mockNonSigningHttpClientFactory.Object,
- new KeyChain(keyManager2),
+ new KeyChain(keyManager2, new Kitchen("")),
new InternalDestinationProvider(keyManager2),
roundStateUpdater,
consolidationMode: true);
@@ -401,7 +402,6 @@ public class WabiSabiHttpApiIntegrationTests : IClassFixture<WabiSabiApiApplicat
}
}
-
[Fact]
public async Task RegisterCoinIdempotencyAsync()
{

MODIFY
WalletWasabi/WabiSabi/Client/CoinJoinTrackerFactory.cs
WalletWasabi/WabiSabi/Client/CoinJoinTrackerFactory.cs
@@ -26,7 +26,7 @@ public class CoinJoinTrackerFactory
{
var coinJoinClient = new CoinJoinClient(
HttpClientFactory,
- new KeyChain(wallet.KeyManager),
+ new KeyChain(wallet.KeyManager, wallet.Kitchen),
new InternalDestinationProvider(wallet.KeyManager),
RoundStatusUpdater,
wallet.ServiceConfiguration.MinAnonScoreTarget);

MODIFY
WalletWasabi/WabiSabi/Client/KeyChain.cs
WalletWasabi/WabiSabi/Client/KeyChain.cs
@@ -2,29 +2,30 @@ using NBitcoin;
using System.Linq;
using WalletWasabi.Blockchain.Keys;
using WalletWasabi.Crypto;
+using WalletWasabi.Wallets;
namespace WalletWasabi.WabiSabi.Client;
public class KeyChain : IKeyChain
{
- public KeyChain(KeyManager keyManager, string passPhrase = "")
+ public KeyChain(KeyManager keyManager, Kitchen kitchen)
{
if (keyManager.IsWatchOnly)
{
throw new ArgumentException("A watch-only keymanager cannot be used to initialize a keychain.");
}
KeyManager = keyManager;
- PassPhrase = passPhrase;
+ Kitchen = kitchen;
}
private KeyManager KeyManager { get; }
- public string PassPhrase { get; }
+ private Kitchen Kitchen { get; }
public OwnershipProof GetOwnershipProof(IDestination destination, CoinJoinInputCommitmentData commitmentData)
{
var secret = GetBitcoinSecret(destination.ScriptPubKey);
- var masterKey = KeyManager.GetMasterExtKey(PassPhrase).PrivateKey;
+ var masterKey = KeyManager.GetMasterExtKey(Kitchen.SaltSoup()).PrivateKey;
var identificationMasterKey = Slip21Node.FromSeed(masterKey.ToBytes());
var identificationKey = identificationMasterKey.DeriveChild("SLIP-0019").DeriveChild("Ownership identification key").Key;
@@ -59,7 +60,7 @@ public class KeyChain : IKeyChain
private BitcoinSecret GetBitcoinSecret(Script scriptPubKey)
{
- var hdKey = KeyManager.GetSecrets(PassPhrase, scriptPubKey).Single();
+ var hdKey = KeyManager.GetSecrets(Kitchen.SaltSoup(), scriptPubKey).Single();
if (hdKey is null)
{
throw new InvalidOperationException($"The signing key for '{scriptPubKey}' was not found.");

MODIFY
WalletWasabi/Wallets/Kitchen.cs
WalletWasabi/Wallets/Kitchen.cs
@@ -6,6 +6,14 @@ namespace WalletWasabi.Wallets;
public class Kitchen
{
+ public Kitchen(string? ingredients = null)
+ {
+ if (ingredients is { })
+ {
+ Cook(ingredients);
+ }
+ }
+
private string? Salt { get; set; } = null;
private string? Soup { get; set; } = null;
private object RefrigeratorLock { get; } = new object();

Add failing test SignTransactionAsync and fix the bug