Extract away inputs weight calculation
MODIFY
WalletWasabi.Tests/UnitTests/WabiSabi/Client/ArenaClientTests.cs
WalletWasabi.Tests/UnitTests/WabiSabi/Client/ArenaClientTests.cs
@@ -41,8 +41,9 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Client
var rnd = new InsecureRandom();
var protocolCredentialNumber = 2;
- var amountClient = new WabiSabiClient(round.AmountCredentialIssuerParameters, protocolCredentialNumber, rnd, 4_300_000_000_000ul); // TODO: remove hardcoded max value
- var weightClient = new WabiSabiClient(round.WeightCredentialIssuerParameters, protocolCredentialNumber, rnd, 1_000ul); // TODO: remove hardcoded max value
+ var protocolMaxWeightPerAlice = 1_000L;
+ var amountClient = new WabiSabiClient(round.AmountCredentialIssuerParameters, protocolCredentialNumber, rnd, 4_300_000_000_000ul);
+ var weightClient = new WabiSabiClient(round.WeightCredentialIssuerParameters, protocolCredentialNumber, rnd, (ulong)protocolMaxWeightPerAlice);
var apiClient = new ArenaClient(amountClient, weightClient, coordinator);
@@ -57,10 +58,14 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Client
Money.Coins(.25m)
};
+ var inputWeight = 4 * Constants.P2wpkhInputVirtualSize;
+ var inputRemainingWeights = new[] { protocolMaxWeightPerAlice - inputWeight };
+
// Phase: Input Registration
await apiClient.ConfirmConnectionAsync(
round.Id,
aliceId,
+ inputRemainingWeights,
apiClient.AmountCredentialClient.Credentials.ZeroValue.Take(protocolCredentialNumber),
reissuanceAmounts);
@@ -71,6 +76,7 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Client
await apiClient.ConfirmConnectionAsync(
round.Id,
aliceId,
+ inputRemainingWeights,
apiClient.AmountCredentialClient.Credentials.ZeroValue.Take(protocolCredentialNumber),
reissuanceAmounts);

MODIFY
WalletWasabi/WabiSabi/Client/ArenaClient.cs
WalletWasabi/WabiSabi/Client/ArenaClient.cs
@@ -64,15 +64,14 @@ namespace WalletWasabi.WabiSabi.Client
return inputRegistrationResponse.AliceId;
}
- public async Task ConfirmConnectionAsync(Guid roundId, Guid aliceId, IEnumerable<Credential> credentialsToPresent, IEnumerable<Money> newAmount)
+ public async Task ConfirmConnectionAsync(Guid roundId, Guid aliceId, IEnumerable<long> inputsRegistrationWeight, IEnumerable<Credential> credentialsToPresent, IEnumerable<Money> newAmount)
{
var (realAmountCredentialRequest, realAmountCredentialResponseValidation) = AmountCredentialClient.CreateRequest(
newAmount.Select(x => x.Satoshi),
credentialsToPresent);
- var inputsCount = 1; // ?
var (realWeightCredentialRequest, realWeightCredentialResponseValidation) = WeightCredentialClient.CreateRequest(
- new[] { 1_000L - (inputsCount) * 4 * Constants.P2wpkhInputVirtualSize },
+ inputsRegistrationWeight,
WeightCredentialClient.Credentials.ZeroValue.Take(2));
var (zeroAmountCredentialRequest, zeroAmountCredentialResponseValidation) = AmountCredentialClient.CreateRequestForZeroAmount();

Extract away inputs weight calculation