Skip to content

Commit

Permalink
Quick patch for Coordinator string (WalletWasabi#13236)
Browse files Browse the repository at this point in the history
* fix ToString()

* do not allow negative feerate
  • Loading branch information
RolandUI authored Jul 9, 2024
1 parent cd0a1ef commit b628b15
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions WalletWasabi/Discoverability/CoordinatorConnectionString.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,15 @@ public record CoordinatorConnectionString(
{
public override string ToString()
{
var builder = new UriBuilder
{
Query = new NameValueCollection
{
["name"] = Uri.EscapeDataString(Name),
["network"] = Network.Name,
["coordinatorUri"] = Uri.EscapeDataString(CoordinatorUri.ToString()),
["coordinationFeeRate"] = CoordinationFeeRate.ToString(CultureInfo.InvariantCulture),
["absoluteMinInputCount"] = AbsoluteMinInputCount.ToString(),
["readMore"] = Uri.EscapeDataString(ReadMore.ToString())
}.ToString()
};
return builder.ToString();
return string.Join("&",
[
$"name={Uri.EscapeDataString(Name)}",
$"network={Network.Name}",
$"coordinatorUri={Uri.EscapeDataString(CoordinatorUri.ToString())}",
$"coordinationFeeRate={CoordinationFeeRate.ToString(CultureInfo.InvariantCulture)}",
$"readMore={Uri.EscapeDataString(ReadMore.ToString())}",
$"absoluteMinInputCount={AbsoluteMinInputCount.ToString()}",
]);
}

public static bool TryParse(string s, [NotNullWhen(true)] out CoordinatorConnectionString? coordinatorConnectionString)
Expand Down Expand Up @@ -57,7 +53,7 @@ public static bool TryParse(string s, [NotNullWhen(true)] out CoordinatorConnect
return false;
}

if (!decimal.TryParse(queryString["coordinationFeeRate"], NumberStyles.Any, CultureInfo.InvariantCulture, out var coordinationFeeRate))
if (!decimal.TryParse(queryString["coordinationFeeRate"], NumberStyles.Any, CultureInfo.InvariantCulture, out var coordinationFeeRate) || coordinationFeeRate < 0)
{
return false;
}
Expand Down

0 comments on commit b628b15

Please sign in to comment.