Skip to content

Commit

Permalink
Merge pull request GingerPrivacy#5 from drkgry/incorrectrequest_fix
Browse files Browse the repository at this point in the history
Incorrect requested amount fix
  • Loading branch information
luzius1089 authored Aug 9, 2024
2 parents e29f87a + df814f5 commit 2630fe7
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 9 deletions.
6 changes: 5 additions & 1 deletion WalletWasabi/Legal/Assets/LegalDocumentsGingerWallet.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Last Updated: May 28, 2024
Last Updated: Aug 09, 2024


Version Number: 5
Expand Down Expand Up @@ -160,6 +160,10 @@ Ginger Wallet does not store, send, or receive Bitcoins. Bitcoins exist only by

The CoinJoin fee, charged by the Service Provider is 0.3% per new UTXO, except if:

-The used client for the CoinJoin is a Wasabi Wallet with version 2.0.8.1 or lower OR a Ginger Wallet

AND ANY FROM BELOW:

-The UTXO comes directly from a Ginger Wallet CoinJoin transaction used InvisibleBit LLC’s coordinator.

-The UTXO comes directly from a Wasabi Wallet 2.x CoinJoin transaction used zkSNACKs’ coordinator till Jun 1, 2024.
Expand Down
10 changes: 5 additions & 5 deletions WalletWasabi/Nostr/NostrExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Linq;
using System.Linq;
using System.Net;
using System.Net.WebSockets;
using System.Threading;
Expand All @@ -14,7 +14,7 @@ namespace WalletWasabi.Nostr;
public record NostrCoordinator(string Description, string Name, Uri Uri, Network Network)
{
private static NostrCoordinator Ginger = new(
Description: "Official Coordinator | FREE Remix, FREE under 0.01 BTC, FREE for Wasabi mixed coins | Secure Coinjoin - Illicit actors are not allowed to participate! | gingerwallet.io",
Description: "Official Coordinator | FREE Remix, FREE under 0.01 BTC till Wasabi Wallet v2.0.8.1 and for Ginger Wallet | Secure Coinjoin - Illicit actors are not allowed to participate! | gingerwallet.io",
Name: "Ginger Coordinator",
Uri: new Uri(Constants.BackendUri),
Network: Network.Main);
Expand All @@ -28,12 +28,12 @@ public static NostrCoordinator GetCoordinator(Network network)

if (network == Network.TestNet)
{
return Ginger with {Uri = new Uri(Constants.TestnetBackendUri), Network = Network.TestNet};
return Ginger with { Uri = new Uri(Constants.TestnetBackendUri), Network = Network.TestNet };
}

if (network == Network.RegTest)
{
return Ginger with {Uri = new Uri("http://localhost:37127/"), Network = Network.RegTest};
return Ginger with { Uri = new Uri("http://localhost:37127/"), Network = Network.RegTest };
}

throw new NotSupportedNetworkException(network);
Expand All @@ -56,7 +56,6 @@ public static INostrClient Create(Uri[] relays, EndPoint? torEndpoint = null)
? new WebProxy($"socks5://{endpoint2.Host}:{endpoint2.Port}")
: null;
return Create(relays, webProxy);

}

public static INostrClient Create(Uri[] relays, WebProxy? proxy = null)
Expand Down Expand Up @@ -89,6 +88,7 @@ public static async Task PublishAsync(

await client.ConnectAndWaitUntilConnected(cancellationToken).ConfigureAwait(false);
await client.SendEventsAndWaitUntilReceived(evts, cancellationToken).ConfigureAwait(false);
await client.Disconnect().ConfigureAwait(false);
}

public static async Task<NostrEvent> CreateCoordinatorDiscoveryEventAsync(
Expand Down
23 changes: 20 additions & 3 deletions WalletWasabi/WabiSabi/Backend/Rounds/Arena.Partial.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,15 +191,32 @@ private async Task<ConnectionConfirmationResponse> ConfirmConnectionCoreAsync(Co
throw new WabiSabiProtocolException(WabiSabiProtocolErrorCode.AliceAlreadyConfirmedConnection, $"Round ({request.RoundId}): Alice ({request.AliceId}) already confirmed connection.");
}

if (realVsizeCredentialRequests.Delta != alice.CalculateRemainingVsizeCredentials(round.Parameters.MaxVsizeAllocationPerAlice))
var vsizeAllowance = alice.CalculateRemainingVsizeCredentials(round.Parameters.MaxVsizeAllocationPerAlice);
if (realVsizeCredentialRequests.Delta != vsizeAllowance)
{
throw new WabiSabiProtocolException(WabiSabiProtocolErrorCode.IncorrectRequestedVsizeCredentials, $"Round ({request.RoundId}): Incorrect requested vsize credentials.");
if (realVsizeCredentialRequests.Delta < vsizeAllowance)
{
round.LogInfo($"Alice {alice.Id} asked for less vsize than allowed ({vsizeAllowance}): {realVsizeCredentialRequests.Delta}");
}
else
{
round.LogInfo($"Alice {alice.Id} asked for more vsize than allowed ({vsizeAllowance}): {realVsizeCredentialRequests.Delta}");
throw new WabiSabiProtocolException(WabiSabiProtocolErrorCode.IncorrectRequestedVsizeCredentials, $"Round ({request.RoundId}): Incorrect requested vsize credentials.");
}
}

var remaining = alice.CalculateRemainingAmountCredentials(round.Parameters.MiningFeeRate, round.Parameters.CoordinationFeeRate);
if (realAmountCredentialRequests.Delta != remaining)
{
throw new WabiSabiProtocolException(WabiSabiProtocolErrorCode.IncorrectRequestedAmountCredentials, $"Round ({request.RoundId}): Incorrect requested amount credentials.");
if (realAmountCredentialRequests.Delta < remaining)
{
round.LogInfo($"Alice {alice.Id} asked for less amount than allowed ({remaining.Satoshi}): {realAmountCredentialRequests.Delta}, diff {remaining.Satoshi - realAmountCredentialRequests.Delta}");
}
else
{
round.LogInfo($"Alice {alice.Id} asked for more amount than allowed ({remaining.Satoshi}): {realAmountCredentialRequests.Delta}");
throw new WabiSabiProtocolException(WabiSabiProtocolErrorCode.IncorrectRequestedAmountCredentials, $"Round ({request.RoundId}): Incorrect requested amount credentials.");
}
}
}

Expand Down

0 comments on commit 2630fe7

Please sign in to comment.