Create AliceClient w/o backend
MODIFY
WalletWasabi.Tests/UnitTests/WabiSabi/Client/AliceClientTests.cs
WalletWasabi.Tests/UnitTests/WabiSabi/Client/AliceClientTests.cs
@@ -50,7 +50,9 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Client
Assert.Equal(Phase.InputRegistration, arena.Rounds.First().Value.Phase);
var bitcoinSecret = km.GetSecrets("", coin1.ScriptPubKey).Single().PrivateKey.GetBitcoinSecret(Network.Main);
- var aliceClient = await AliceClient.CreateNewAsync(arenaClient, coin1.Coin, bitcoinSecret, round.Id, round.FeeRate);
+
+ var aliceClient = new AliceClient(round.Id, arenaClient, coin1.Coin, round.FeeRate, bitcoinSecret);
+ await aliceClient.RegisterInputAsync();
Task confirmationTask = aliceClient.ConfirmConnectionAsync(TimeSpan.FromSeconds(3), CancellationToken.None);

MODIFY
WalletWasabi.Tests/UnitTests/WabiSabi/Client/BobClientTests.cs
WalletWasabi.Tests/UnitTests/WabiSabi/Client/BobClientTests.cs
@@ -51,7 +51,9 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Client
Assert.Equal(Phase.InputRegistration, round.Phase);
var bitcoinSecret = km.GetSecrets("", coin1.ScriptPubKey).Single().PrivateKey.GetBitcoinSecret(Network.Main);
- var aliceClient = await AliceClient.CreateNewAsync(aliceArenaClient, coin1.Coin, bitcoinSecret, round.Id, round.FeeRate);
+
+ var aliceClient = new AliceClient(round.Id, aliceArenaClient, coin1.Coin, round.FeeRate, bitcoinSecret);
+ await aliceClient.RegisterInputAsync();
Task confirmationTask = aliceClient.ConfirmConnectionAsync(TimeSpan.FromSeconds(3), CancellationToken.None);

MODIFY
WalletWasabi/WabiSabi/Backend/Models/Alice.cs
WalletWasabi/WabiSabi/Backend/Models/Alice.cs
@@ -40,5 +40,13 @@ namespace WalletWasabi.WabiSabi.Backend.Models
.Append(ProtocolConstants.AliceCoinOutpointStrobeLabel, Coin.Outpoint)
.Append(ProtocolConstants.AliceOwnershipProofStrobeLabel, OwnershipProof)
.GetHash();
+
+ public static uint256 CalculateHash(Coin coin, BitcoinSecret bitcoinSecret, uint256 roundId)
+ {
+ var ownershipProof = OwnershipProof.GenerateCoinJoinInputProof(
+ bitcoinSecret.PrivateKey,
+ new CoinJoinInputCommitmentData("CoinJoinCoordinatorIdentifier", roundId));
+ return new Alice(coin, ownershipProof).CalculateHash();
+ }
}
}

MODIFY
WalletWasabi/WabiSabi/Client/AliceClient.cs
WalletWasabi/WabiSabi/Client/AliceClient.cs
@@ -6,18 +6,20 @@ using System.Threading;
using System.Threading.Tasks;
using WalletWasabi.Helpers;
using WalletWasabi.Logging;
+using WalletWasabi.WabiSabi.Backend.Models;
namespace WalletWasabi.WabiSabi.Client
{
public class AliceClient
{
- public AliceClient(uint256 aliceId, uint256 roundId, ArenaClient arenaClient, Coin coin, FeeRate feeRate)
+ public AliceClient(uint256 roundId, ArenaClient arenaClient, Coin coin, FeeRate feeRate, BitcoinSecret bitcoinSecret)
{
- AliceId = aliceId;
+ AliceId = Alice.CalculateHash(coin, bitcoinSecret, roundId);
RoundId = roundId;
ArenaClient = arenaClient;
Coin = coin;
FeeRate = feeRate;
+ BitcoinSecret = bitcoinSecret;
}
public uint256 AliceId { get; }
@@ -25,6 +27,13 @@ namespace WalletWasabi.WabiSabi.Client
private ArenaClient ArenaClient { get; }
private Coin Coin { get; }
private FeeRate FeeRate { get; }
+ private BitcoinSecret BitcoinSecret { get; }
+
+ public async Task RegisterInputAsync()
+ {
+ uint256 aliceId = await ArenaClient.RegisterInputAsync(Coin.Amount, Coin.Outpoint, BitcoinSecret.PrivateKey, RoundId).ConfigureAwait(false);
+ Logger.LogInfo($"Round ({RoundId}), Alice ({aliceId}): Registered an input.");
+ }
public async Task ConfirmConnectionAsync(TimeSpan confirmInterval, CancellationToken token)
{
@@ -74,21 +83,5 @@ namespace WalletWasabi.WabiSabi.Client
Logger.LogInfo($"Round ({RoundId}), Alice ({AliceId}): Posted a signature.");
}
-
- public static async Task<AliceClient> CreateNewAsync(
- ArenaClient arenaClient,
- Coin coin,
- BitcoinSecret bitcoinSecret,
- uint256 roundId,
- FeeRate feeRate)
- {
- uint256 aliceId = await arenaClient.RegisterInputAsync(coin.Amount, coin.Outpoint, bitcoinSecret.PrivateKey, roundId).ConfigureAwait(false);
-
- AliceClient client = new(aliceId, roundId, arenaClient, coin, feeRate);
-
- Logger.LogInfo($"Round ({roundId}), Alice ({aliceId}): Registered an input.");
-
- return client;
- }
}
}

Create AliceClient w/o backend