Use DateTimeOffset instead of long
MODIFY
WalletWasabi/Tor/Http/Extensions/HttpResponseMessageExtensions.cs
WalletWasabi/Tor/Http/Extensions/HttpResponseMessageExtensions.cs
@@ -72,7 +72,7 @@ public static class HttpResponseMessageExtensions
var innerException = error switch
{
{ Type: ProtocolConstants.ProtocolViolationType } => Enum.TryParse<WabiSabiProtocolErrorCode>(error.ErrorCode, out var code)
- ? new WabiSabiProtocolException(code, error.Description, exceptionData: JsonConvert.DeserializeObject<InputBannedExceptionData>(error.Data))
+ ? new WabiSabiProtocolException(code, error.Description, exceptionData: GetExceptionData(code, error.Data))
: new NotSupportedException($"Received WabiSabi protocol exception with unknown '{error.ErrorCode}' error code.\n\tDescription: '{error.Description}'."),
{ Type: "unknown" } => new Exception(error.Description),
_ => null
@@ -97,4 +97,14 @@ public static class HttpResponseMessageExtensions
throw new HttpRequestException($"{me.StatusCode.ToReasonString()}{errorMessage}");
}
+
+ private static ExceptionData? GetExceptionData(WabiSabiProtocolErrorCode errorCode, string data)
+ {
+ return errorCode switch
+ {
+ WabiSabiProtocolErrorCode.InputBanned or WabiSabiProtocolErrorCode.InputLongBanned => JsonConvert.DeserializeObject<InputBannedExceptionData>(data),
+ _ => null
+ };
+
+ }
}

MODIFY
WalletWasabi/WabiSabi/Backend/Models/InputBannedExceptionData.cs
WalletWasabi/WabiSabi/Backend/Models/InputBannedExceptionData.cs
@@ -2,4 +2,4 @@ using Newtonsoft.Json;
namespace WalletWasabi.WabiSabi.Backend.Models;
-public record InputBannedExceptionData([JsonProperty(PropertyName = "BannedUntil")] long BannedUntil) : ExceptionData;
+public record InputBannedExceptionData([JsonProperty(PropertyName = "BannedUntil")] DateTimeOffset BannedUntil) : ExceptionData;

MODIFY
WalletWasabi/WabiSabi/Backend/Rounds/Arena.Partial.cs
WalletWasabi/WabiSabi/Backend/Rounds/Arena.Partial.cs
@@ -362,12 +362,12 @@ public partial class Arena : IWabiSabiApiRequestHandler
if (inmate.Punishment == Punishment.LongBanned)
{
bannedUntil = inmate.Started + Config.ReleaseUtxoFromPrisonAfterLongBan;
- throw new WabiSabiProtocolException(WabiSabiProtocolErrorCode.InputLongBanned, exceptionData: new InputBannedExceptionData(bannedUntil.ToUnixTimeSeconds()));
+ throw new WabiSabiProtocolException(WabiSabiProtocolErrorCode.InputLongBanned, exceptionData: new InputBannedExceptionData(bannedUntil));
}
else if (!Config.AllowNotedInputRegistration || inmate.Punishment != Punishment.Noted)
{
bannedUntil = inmate.Started + Config.ReleaseUtxoFromPrisonAfter;
- throw new WabiSabiProtocolException(WabiSabiProtocolErrorCode.InputBanned, exceptionData: new InputBannedExceptionData(bannedUntil.ToUnixTimeSeconds()));
+ throw new WabiSabiProtocolException(WabiSabiProtocolErrorCode.InputBanned, exceptionData: new InputBannedExceptionData(bannedUntil));
}
}

MODIFY
WalletWasabi/WabiSabi/Client/AliceClient.cs
WalletWasabi/WabiSabi/Client/AliceClient.cs
@@ -110,7 +110,11 @@ public class AliceClient
case WabiSabiProtocolErrorCode.InputBanned or WabiSabiProtocolErrorCode.InputLongBanned:
var inputBannedExData = wpe.ExceptionData as InputBannedExceptionData;
- coin.BannedUntilUtc = DateTimeOffset.FromUnixTimeSeconds(inputBannedExData.BannedUntil);
+ if (inputBannedExData is null)
+ {
+ Logger.LogError($"{nameof(InputBannedExceptionData)} is missing.");
+ }
+ coin.BannedUntilUtc =inputBannedExData?.BannedUntil ?? DateTimeOffset.UtcNow + TimeSpan.FromDays(1);
Logger.LogInfo($"{coin.Coin.Outpoint} is banned until {coin.BannedUntilUtc}.");
break;

Use DateTimeOffset instead of long