Improve aliceclientcreation
MODIFY
WalletWasabi.Tests/RegTests.cs
WalletWasabi.Tests/RegTests.cs
@@ -2264,11 +2264,13 @@ namespace WalletWasabi.Tests
// Save alice client and the outputs, requesters, etc
var changeOutput = new Key().PubKey.GetAddress(network);
var inputProof = inputs.Select(x => new InputProofModel { Input = x.input, Proof = x.proof });
- var aliceClient = await AliceClient.CreateNewAsync(network, changeOutput, blindedOutputScriptList, inputProof, baseUri);
+ var aliceClient = await AliceClient.CreateNewAsync(
+ outputs.Select(x => x.outputAddress),
+
+ network, changeOutput, blindedOutputScriptList, inputProof, baseUri);
// We check the coordinator signed all the alice blinded outputs
aliceClient.Requesters = outputs.Select(x => x.requester).ToArray();
- aliceClient.RegisteredAddresses = outputs.Select(x => x.outputAddress).ToArray();
participants.Add((aliceClient, outputs, inputs));
}
@@ -2502,7 +2504,6 @@ namespace WalletWasabi.Tests
var request = aliceClients[i];
var aliceClient = await request;
- aliceClient.Requesters = new[] { user.requester };
if (roundId == 0)
{

MODIFY
WalletWasabi/Services/CcjClient.cs
WalletWasabi/Services/CcjClient.cs
@@ -498,7 +498,7 @@ namespace WalletWasabi.Services
AliceClient aliceClient = null;
try
{
- aliceClient = await AliceClient.CreateNewAsync(Network, outputAddresses.change.GetP2wpkhAddress(Network), blindedOutputScriptHashes, inputProofs, CcjHostUri, TorSocks5EndPoint);
+ aliceClient = await AliceClient.CreateNewAsync(registeredAddresses, schnorrPubKeys, requesters, outputScriptHashes, Network, outputAddresses.change.GetP2wpkhAddress(Network), blindedOutputScriptHashes, inputProofs, CcjHostUri, TorSocks5EndPoint);
}
catch (HttpRequestException ex) when (ex.Message.Contains("Input is banned", StringComparison.InvariantCultureIgnoreCase))
{
@@ -533,11 +533,6 @@ namespace WalletWasabi.Services
return;
}
- aliceClient.RegisteredAddresses = registeredAddresses.ToArray();
- aliceClient.SchnorrPubKeys = schnorrPubKeys;
- aliceClient.Requesters = requesters.ToArray();
- aliceClient.OutputScriptHashes = outputScriptHashes.ToArray();
-
var coinsRegistered = new List<SmartCoin>();
foreach (TxoRef coinReference in registrableCoins)
{

MODIFY
WalletWasabi/WebClients/Wasabi/ChaumianCoinJoin/AliceClient.cs
WalletWasabi/WebClients/Wasabi/ChaumianCoinJoin/AliceClient.cs
@@ -27,20 +27,39 @@ namespace WalletWasabi.WebClients.Wasabi.ChaumianCoinJoin
public Guid UniqueId { get; private set; }
public Network Network { get; }
- public BitcoinAddress[] RegisteredAddresses { get; set; }
- public SchnorrPubKey[] SchnorrPubKeys { get; set; }
- public Requester[] Requesters { get; set; }
- public uint256[] OutputScriptHashes { get; set; }
+ public BitcoinAddress[] RegisteredAddresses { get; }
+ public SchnorrPubKey[] SchnorrPubKeys { get; }
+ public Requester[] Requesters { get; }
+ public uint256[] OutputScriptHashes { get; }
/// <inheritdoc/>
- private AliceClient(Network network, Uri baseUri, IPEndPoint torSocks5EndPoint = null) : base(baseUri, torSocks5EndPoint)
- {
+ private AliceClient(
+ IEnumerable<BitcoinAddress> registeredAddresses,
+ IEnumerable<SchnorrPubKey> schnorrPubKeys,
+ IEnumerable<Requester> requesters,
+ IEnumerable<uint256> outputScriptHashes,
+ Network network,
+ Uri baseUri,
+ IPEndPoint torSocks5EndPoint = null) : base(baseUri, torSocks5EndPoint)
+ {
+ RegisteredAddresses = registeredAddresses.ToArray();
+ SchnorrPubKeys = schnorrPubKeys.ToArray();
+ Requesters = requesters.ToArray();
+ OutputScriptHashes = outputScriptHashes.ToArray();
Network = network;
}
- public static async Task<AliceClient> CreateNewAsync(Network network, InputsRequest request, Uri baseUri, IPEndPoint torSocks5EndPoint = null)
+ public static async Task<AliceClient> CreateNewAsync(
+ IEnumerable<BitcoinAddress> registeredAddresses,
+ IEnumerable<SchnorrPubKey> schnorrPubKeys,
+ IEnumerable<Requester> requesters,
+ IEnumerable<uint256> outputScriptHashes,
+ Network network,
+ InputsRequest request,
+ Uri baseUri,
+ IPEndPoint torSocks5EndPoint = null)
{
- AliceClient client = new AliceClient(network, baseUri, torSocks5EndPoint);
+ AliceClient client = new AliceClient(registeredAddresses, schnorrPubKeys, requesters, outputScriptHashes, network, baseUri, torSocks5EndPoint);
try
{
using (HttpResponseMessage response = await client.TorClient.SendAsync(HttpMethod.Post, $"/api/v{Helpers.Constants.BackendMajorVersion}/btc/chaumiancoinjoin/inputs/", request.ToHttpStringContent()))
@@ -66,7 +85,17 @@ namespace WalletWasabi.WebClients.Wasabi.ChaumianCoinJoin
}
}
- public static async Task<AliceClient> CreateNewAsync(Network network, BitcoinAddress changeOutput, IEnumerable<uint256> blindedOutputScriptHashes, IEnumerable<InputProofModel> inputs, Uri baseUri, IPEndPoint torSocks5EndPoint = null)
+ public static async Task<AliceClient> CreateNewAsync(
+ IEnumerable<BitcoinAddress> registeredAddresses,
+ IEnumerable<SchnorrPubKey> schnorrPubKeys,
+ IEnumerable<Requester> requesters,
+ IEnumerable<uint256> outputScriptHashes,
+ Network network,
+ BitcoinAddress changeOutput,
+ IEnumerable<uint256> blindedOutputScriptHashes,
+ IEnumerable<InputProofModel> inputs,
+ Uri baseUri,
+ IPEndPoint torSocks5EndPoint = null)
{
var request = new InputsRequest
{
@@ -74,7 +103,7 @@ namespace WalletWasabi.WebClients.Wasabi.ChaumianCoinJoin
ChangeOutputAddress = changeOutput,
Inputs = inputs
};
- return await CreateNewAsync(network, request, baseUri, torSocks5EndPoint);
+ return await CreateNewAsync(registeredAddresses, schnorrPubKeys, requesters, outputScriptHashes, network, request, baseUri, torSocks5EndPoint);
}
public async Task<(CcjRoundPhase currentPhase, IEnumerable<(BitcoinAddress output, UnblindedSignature signature, int level)> activeOutputs)> PostConfirmationAsync()

Improve aliceclientcreation