Use credential amount to output value
MODIFY
WalletWasabi.Tests/Helpers/WabiSabiFactory.cs
WalletWasabi.Tests/Helpers/WabiSabiFactory.cs
@@ -224,7 +224,7 @@ namespace WalletWasabi.Tests.Helpers
new[] { alice.CalculateRemainingAmountCredentials(round.FeeRate).Satoshi },
amZeroCredentials, // FIXME doesn't make much sense
CancellationToken.None);
- long startingVsizeCredentialAmount = alice.CalculateRemainingVsizeCredentials(round.MaxVsizeAllocationPerAlice);
+ long startingVsizeCredentialAmount = vsize ?? alice.CalculateRemainingVsizeCredentials(round.MaxVsizeAllocationPerAlice);
var (vsCredentialRequest, weValid) = vsClient.CreateRequest(
new[] { startingVsizeCredentialAmount },
vsZeroCredentials, // FIXME doesn't make much sense
@@ -236,22 +236,11 @@ namespace WalletWasabi.Tests.Helpers
var vsizeCredentials = vsClient.HandleResponse(weResp, weValid);
script ??= BitcoinFactory.CreateScript();
- var (realAmountCredentialRequest, _) = amClient.CreateRequest(
- Array.Empty<long>(),
+ var (realAmountCredentialRequest, _) = amClient.CreatePresentationRequest(
amountCredentials,
CancellationToken.None);
- try
- {
- vsize ??= script.EstimateOutputVsize();
- }
- catch (NotImplementedException)
- {
- vsize = 25;
- }
-
- var (realVsizeCredentialRequest, _) = vsClient.CreateRequest(
- new[] { startingVsizeCredentialAmount - (long)vsize },
+ var (realVsizeCredentialRequest, _) = vsClient.CreatePresentationRequest(
vsizeCredentials,
CancellationToken.None);

MODIFY
WalletWasabi.Tests/UnitTests/WabiSabi/Backend/PhaseStepping/StepOutputRegistrationTests.cs
WalletWasabi.Tests/UnitTests/WabiSabi/Backend/PhaseStepping/StepOutputRegistrationTests.cs
@@ -39,7 +39,6 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend.PhaseStepping
var bobClient = new BobClient(round.Id, arenaClient);
using var destKey1 = new Key();
await bobClient.RegisterOutputAsync(
- coin1.Amount - round.FeeRate.GetFee(coin1.ScriptPubKey.EstimateInputVsize()),
destKey1.PubKey.WitHash.ScriptPubKey,
amountCredentials1.Take(ProtocolConstants.CredentialNumber),
vsizeCredentials1.Take(ProtocolConstants.CredentialNumber),
@@ -47,7 +46,6 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend.PhaseStepping
using var destKey2 = new Key();
await bobClient.RegisterOutputAsync(
- coin2.Amount - round.FeeRate.GetFee(coin2.ScriptPubKey.EstimateInputVsize()),
destKey2.PubKey.WitHash.ScriptPubKey,
amountCredentials2.Take(ProtocolConstants.CredentialNumber),
vsizeCredentials2.Take(ProtocolConstants.CredentialNumber),
@@ -91,7 +89,6 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend.PhaseStepping
var bobClient = new BobClient(round.Id, arenaClient);
using var destKey = new Key();
await bobClient.RegisterOutputAsync(
- coin1.Amount - round.FeeRate.GetFee(coin1.ScriptPubKey.EstimateInputVsize()),
destKey.PubKey.WitHash.ScriptPubKey,
amountCredentials1.Take(ProtocolConstants.CredentialNumber),
vsizeCredentials1.Take(ProtocolConstants.CredentialNumber),
@@ -132,14 +129,12 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend.PhaseStepping
using var destKey1 = new Key();
using var destKey2 = new Key();
await bobClient.RegisterOutputAsync(
- coin1.Amount - round.FeeRate.GetFee(coin1.ScriptPubKey.EstimateInputVsize()),
destKey1.PubKey.WitHash.ScriptPubKey,
amountCredentials1.Take(ProtocolConstants.CredentialNumber),
vsizeCredentials1.Take(ProtocolConstants.CredentialNumber),
CancellationToken.None);
await bobClient.RegisterOutputAsync(
- coin2.Amount - round.FeeRate.GetFee(coin2.ScriptPubKey.EstimateInputVsize()),
destKey2.PubKey.WitHash.ScriptPubKey,
amountCredentials2.Take(ProtocolConstants.CredentialNumber),
vsizeCredentials2.Take(ProtocolConstants.CredentialNumber),
@@ -186,7 +181,6 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend.PhaseStepping
var bobClient = new BobClient(round.Id, arenaClient);
using var destKey = new Key();
await bobClient.RegisterOutputAsync(
- coin1.Amount - round.FeeRate.GetFee(coin1.ScriptPubKey.EstimateInputVsize()),
destKey.PubKey.WitHash.ScriptPubKey,
amountCredentials1.Take(ProtocolConstants.CredentialNumber),
vsizeCredentials1.Take(ProtocolConstants.CredentialNumber),

MODIFY
WalletWasabi.Tests/UnitTests/WabiSabi/Backend/PhaseStepping/StepTransactionSigningTests.cs
WalletWasabi.Tests/UnitTests/WabiSabi/Backend/PhaseStepping/StepTransactionSigningTests.cs
@@ -267,14 +267,12 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Backend.PhaseStepping
using var destKey1 = new Key();
using var destKey2 = new Key();
await bobClient.RegisterOutputAsync(
- coin1.Amount - round.FeeRate.GetFee(coin1.ScriptPubKey.EstimateInputVsize()),
destKey1.PubKey.WitHash.ScriptPubKey,
aliceClient1.IssuedAmountCredentials.Take(ProtocolConstants.CredentialNumber),
aliceClient1.IssuedVsizeCredentials.Take(ProtocolConstants.CredentialNumber),
CancellationToken.None).ConfigureAwait(false);
await bobClient.RegisterOutputAsync(
- coin2.Amount - round.FeeRate.GetFee(coin2.ScriptPubKey.EstimateInputVsize()),
destKey1.PubKey.WitHash.ScriptPubKey,
aliceClient2.IssuedAmountCredentials.Take(ProtocolConstants.CredentialNumber),
aliceClient2.IssuedVsizeCredentials.Take(ProtocolConstants.CredentialNumber),

MODIFY
WalletWasabi.Tests/UnitTests/WabiSabi/Client/ArenaClientTests.cs
WalletWasabi.Tests/UnitTests/WabiSabi/Client/ArenaClientTests.cs
@@ -138,7 +138,6 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Client
await bobArenaClient.RegisterOutputAsync(
round.Id,
- amountsToRequest[0],
destinationKey1.PubKey.WitHash.ScriptPubKey,
new[] { amountCred1, zeroAmountCred1 },
new[] { vsizeCred1, zeroVsizeCred1 },
@@ -146,7 +145,6 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Client
await bobArenaClient.RegisterOutputAsync(
round.Id,
- amountsToRequest[1],
destinationKey2.PubKey.WitHash.ScriptPubKey,
new[] { amountCred2, zeroAmountCred2 },
new[] { vsizeCred2, zeroVsizeCred2 },

MODIFY
WalletWasabi.Tests/UnitTests/WabiSabi/Client/BobClientTests.cs
WalletWasabi.Tests/UnitTests/WabiSabi/Client/BobClientTests.cs
@@ -71,7 +71,6 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Client
var bobClient = new BobClient(round.Id, bobArenaClient);
await bobClient.RegisterOutputAsync(
- Money.Coins(0.25m),
destination,
aliceClient.IssuedAmountCredentials.Take(ProtocolConstants.CredentialNumber),
aliceClient.IssuedVsizeCredentials.Take(ProtocolConstants.CredentialNumber),
@@ -79,7 +78,9 @@ namespace WalletWasabi.Tests.UnitTests.WabiSabi.Client
var bob = Assert.Single(round.Bobs);
Assert.Equal(destination, bob.Script);
- Assert.Equal(25_000_000, bob.CredentialAmount);
+
+ var credentialAmountSum = aliceClient.IssuedAmountCredentials.Take(ProtocolConstants.CredentialNumber).Sum(x => x.Value);
+ Assert.Equal(credentialAmountSum, bob.CredentialAmount);
}
}
}

MODIFY
WalletWasabi/WabiSabi/Client/ArenaClient.cs
WalletWasabi/WabiSabi/Client/ArenaClient.cs
@@ -65,7 +65,6 @@ namespace WalletWasabi.WabiSabi.Client
public async Task RegisterOutputAsync(
uint256 roundId,
- long amount,
Script scriptPubKey,
IEnumerable<Credential> amountCredentialsToPresent,
IEnumerable<Credential> vsizeCredentialsToPresent,
@@ -75,14 +74,12 @@ namespace WalletWasabi.WabiSabi.Client
Guard.InRange(nameof(vsizeCredentialsToPresent), vsizeCredentialsToPresent, 0, VsizeCredentialClient.NumberOfCredentials);
var presentedAmount = amountCredentialsToPresent.Sum(x => x.Value);
- var (realAmountCredentialRequest, realAmountCredentialResponseValidation) = AmountCredentialClient.CreateRequest(
- new[] { 0L },
+ var (realAmountCredentialRequest, realAmountCredentialResponseValidation) = AmountCredentialClient.CreatePresentationRequest(
amountCredentialsToPresent,
cancellationToken);
var presentedVsize = vsizeCredentialsToPresent.Sum(x => x.Value);
- var (realVsizeCredentialRequest, realVsizeCredentialResponseValidation) = VsizeCredentialClient.CreateRequest(
- new[] { 0L },
+ var (realVsizeCredentialRequest, realVsizeCredentialResponseValidation) = VsizeCredentialClient.CreatePresentationRequest(
vsizeCredentialsToPresent,
cancellationToken);

MODIFY
WalletWasabi/WabiSabi/Client/BobClient.cs
WalletWasabi/WabiSabi/Client/BobClient.cs
@@ -18,11 +18,10 @@ namespace WalletWasabi.WabiSabi.Client
public uint256 RoundId { get; }
private ArenaClient ArenaClient { get; }
- public async Task RegisterOutputAsync(Money amount, Script scriptPubKey, IEnumerable<Credential> amountCredentials, IEnumerable<Credential> vsizeCredentials, CancellationToken cancellationToken)
+ public async Task RegisterOutputAsync(Script scriptPubKey, IEnumerable<Credential> amountCredentials, IEnumerable<Credential> vsizeCredentials, CancellationToken cancellationToken)
{
await ArenaClient.RegisterOutputAsync(
RoundId,
- amount.Satoshi,
scriptPubKey,
amountCredentials,
vsizeCredentials,

MODIFY
WalletWasabi/WabiSabi/Client/DependencyGraphTaskScheduler.cs
WalletWasabi/WabiSabi/Client/DependencyGraphTaskScheduler.cs
@@ -155,7 +155,7 @@ namespace WalletWasabi.WabiSabi.Client
Array.Empty<TaskCompletionSource<Credential>>());
var task = smartRequestNode
- .StartOutputRegistrationAsync(bobClient, node.EffectiveCost, txOut.ScriptPubKey, cancellationToken)
+ .StartOutputRegistrationAsync(bobClient, txOut.ScriptPubKey, cancellationToken)
.ContinueWith((t) =>
{
if (t.IsFaulted && t.Exception is { } exception)

MODIFY
WalletWasabi/WabiSabi/Client/SmartRequestNode.cs
WalletWasabi/WabiSabi/Client/SmartRequestNode.cs
@@ -87,7 +87,6 @@ namespace WalletWasabi.WabiSabi.Client
public async Task StartOutputRegistrationAsync(
BobClient bobClient,
- Money effectiveCost,
Script scriptPubKey,
CancellationToken cancellationToken)
{
@@ -96,7 +95,6 @@ namespace WalletWasabi.WabiSabi.Client
IEnumerable<Credential> inputVsizeCredentials = VsizeCredentialToPresentTasks.Select(x => x.Result);
await bobClient.RegisterOutputAsync(
- effectiveCost,
scriptPubKey,
inputAmountCredentials,
inputVsizeCredentials,

MODIFY
WalletWasabi/WabiSabi/Crypto/WabiSabiClient.cs
WalletWasabi/WabiSabi/Crypto/WabiSabiClient.cs
@@ -76,6 +76,14 @@ namespace WalletWasabi.WabiSabi.Crypto
validationData));
}
+ public RealCredentialsRequestData CreatePresentationRequest(
+ IEnumerable<Credential> credentialsToPresent,
+ CancellationToken cancellationToken)
+ {
+ return CreateRequest(Array.Empty<long>(), credentialsToPresent, cancellationToken);
+ }
+
+
/// <summary>
/// Creates a <see cref="RealCredentialsRequest">credential registration request messages</see>
/// for requesting `k` non-zero-value credentials.

Use credential amount to output value