Fix confirmation bug.
Add roundId requirement for PostConfirmation
MODIFY
WalletWasabi.Backend/Controllers/ChaumianCoinJoinController.cs
WalletWasabi.Backend/Controllers/ChaumianCoinJoinController.cs
@@ -273,18 +273,24 @@ namespace WalletWasabi.Backend.Controllers
/// Alice must confirm her participation periodically in InputRegistration phase and confirm once in ConnectionConfirmation phase.
/// </summary>
/// <param name="uniqueId">Unique identifier, obtained previously.</param>
+ /// <param name="roundId">Round identifier, obtained previously.</param>
/// <returns>RoundHash if the phase is already ConnectionConfirmation.</returns>
/// <response code="200">RoundHash if the phase is already ConnectionConfirmation.</response>
/// <response code="204">If the phase is InputRegistration and Alice is found.</response>
/// <response code="400">The provided uniqueId was malformed.</response>
/// <response code="404">If Alice is not found.</response>
- [HttpPost("confirmation/{uniqueId}")]
+ [HttpPost("confirmation")]
[ProducesResponseType(200)]
[ProducesResponseType(204)]
[ProducesResponseType(400)]
[ProducesResponseType(404)]
- public async Task<IActionResult> PostConfirmationAsync(string uniqueId)
+ public async Task<IActionResult> PostConfirmationAsync([FromQuery]string uniqueId, [FromQuery]long roundId)
{
+ if (roundId <= 0 || !ModelState.IsValid)
+ {
+ return BadRequest();
+ }
+
CheckUniqueId(uniqueId, out IActionResult returnFailureResponse);
if (returnFailureResponse != null)
{
@@ -292,6 +298,7 @@ namespace WalletWasabi.Backend.Controllers
}
var uniqueIdGuid = Guid.Parse(uniqueId);
+
var roundAlice = Coordinator.TryGetRoundAndAliceBy(uniqueIdGuid);
if (roundAlice.alice == null)
{

MODIFY
WalletWasabi.Tests/RegTests.cs
WalletWasabi.Tests/RegTests.cs
@@ -1636,7 +1636,13 @@ namespace WalletWasabi.Tests
var inputsResp = await response.Content.ReadAsJsonAsync<InputsResponse>();
Assert.NotNull(inputsResp.BlindedOutputSignature);
Assert.NotEqual(Guid.Empty, inputsResp.UniqueId);
- Assert.Equal(9, inputsResp.RoundId);
+ Assert.Equal(10, inputsResp.RoundId);
+
+ string queryString = $"/api/v1/btc/chaumiancoinjoin/confirmation?uniqueId={inputsResp.UniqueId}&roundId={inputsResp.RoundId}";
+ using (var response2 = await client.SendAsync(HttpMethod.Post, queryString))
+ {
+ Assert.Equal(HttpStatusCode.NoContent, response2.StatusCode);
+ }
}
using (var response = await client.SendAsync(HttpMethod.Get, "/api/v1/btc/chaumiancoinjoin/status/"))
@@ -1696,7 +1702,7 @@ namespace WalletWasabi.Tests
var inputsResp = await response.Content.ReadAsJsonAsync<InputsResponse>();
Assert.NotNull(inputsResp.BlindedOutputSignature);
Assert.NotEqual(Guid.Empty, inputsResp.UniqueId);
- Assert.Equal(9, inputsResp.RoundId);
+ Assert.Equal(10, inputsResp.RoundId);
}
using (var response = await client.SendAsync(HttpMethod.Get, "/api/v1/btc/chaumiancoinjoin/status/"))
@@ -1757,7 +1763,7 @@ namespace WalletWasabi.Tests
var inputsResp = await response.Content.ReadAsJsonAsync<InputsResponse>();
Assert.NotNull(inputsResp.BlindedOutputSignature);
Assert.NotEqual(Guid.Empty, inputsResp.UniqueId);
- Assert.NotEqual(9, inputsResp.RoundId);
+ Assert.Equal(10, inputsResp.RoundId);
}
using (var response = await client.SendAsync(HttpMethod.Get, "/api/v1/btc/chaumiancoinjoin/status/"))

MODIFY
WalletWasabi/ChaumianCoinJoin/CcjRound.cs
WalletWasabi/ChaumianCoinJoin/CcjRound.cs
@@ -15,7 +15,7 @@ namespace WalletWasabi.ChaumianCoinJoin
{
public class CcjRound
{
- private static long RoundCount;
+ private static long RoundCount = 1; // First time initializes. Let's start from 1.
public long RoundId { get; }
public RPCClient RpcClient { get; }

MODIFY
WalletWasabi/Services/CcjCoordinator.cs
WalletWasabi/Services/CcjCoordinator.cs
@@ -288,7 +288,7 @@ namespace WalletWasabi.Services
CcjRound round = null;
foreach (var r in Rounds.Where(x => x.Status == CcjRoundStatus.Running))
{
- var a = round.TryGetAliceBy(uniqueId);
+ var a = r.TryGetAliceBy(uniqueId);
if (a != null)
{
alice = a;

- Fix confirmation bug.
- Add roundId requirement for PostConfirmation