Ensure input uniqueness
MODIFY
WalletWasabi.Tests/UnitTests/WabiSabi/Backend/InputRegistrationTests.cs
WalletWasabi.Tests/UnitTests/WabiSabi/Backend/InputRegistrationTests.cs
@@ -57,6 +57,30 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend
}
}
}
+ [Fact]
+ public async Task NonUniqueInputsAsync()
+ {
+ MockArena arena = new();
+ Round round = new();
+ arena.OnTryGetRound = _ => round;
+ var inputSigPair = WabiSabiFactory.CreateInputRoundSignaturePair();
+
+ foreach (Phase phase in Enum.GetValues(typeof(Phase)))
+ {
+ if (phase != Phase.InputRegistration)
+ {
+ round.Phase = phase;
+ await using PostRequestHandler handler = new(new WabiSabiConfig(), new Prison(), arena, new MockRpcClient());
+ var req = new InputsRegistrationRequest(
+ round.Id,
+ new[] { inputSigPair, inputSigPair },
+ null!,
+ null!);
+ var ex = await Assert.ThrowsAnyAsync<WabiSabiProtocolException>(async () => await handler.RegisterInputAsync(req));
+ Assert.Equal(WabiSabiProtocolErrorCode.WrongPhase, ex.ErrorCode);
+ }
+ }
+ }
[Fact]
public async Task TooManyInputsAsync()

MODIFY
WalletWasabi/WabiSabi/Backend/Models/WabiSabiProtocolErrorCode.cs
WalletWasabi/WabiSabi/Backend/Models/WabiSabiProtocolErrorCode.cs
@@ -17,6 +17,7 @@ namespace WalletWasabi.WabiSabi.Backend.Models
WrongRoundSignature,
TooManyInputs,
NotEnoughFunds,
- TooMuchFunds
+ TooMuchFunds,
+ NonUniqueInputs
}
}

MODIFY
WalletWasabi/WabiSabi/Backend/PostRequests/PostRequestHandler.cs
WalletWasabi/WabiSabi/Backend/PostRequests/PostRequestHandler.cs
@@ -46,7 +46,13 @@ namespace WalletWasabi.WabiSabi.Backend.PostRequests
{
throw new WabiSabiProtocolException(WabiSabiProtocolErrorCode.WrongPhase);
}
- if (Config.MaxInputCountByAlice < request.InputRoundSignaturePairs.Count())
+
+ int inputCount = request.InputRoundSignaturePairs.Count();
+ if (inputCount != request.InputRoundSignaturePairs.Select(x => x.Input).Distinct().Count())
+ {
+ throw new WabiSabiProtocolException(WabiSabiProtocolErrorCode.NonUniqueInputs);
+ }
+ if (Config.MaxInputCountByAlice < inputCount)
{
throw new WabiSabiProtocolException(WabiSabiProtocolErrorCode.TooManyInputs);
}

Ensure input uniqueness