Switch 'FeeRateJsonConverter' from 'JsonConverter' to 'JsonConverter<T>'
MODIFY
WalletWasabi/JsonConverters/Bitcoin/FeeRateJsonConverter.cs
WalletWasabi/JsonConverters/Bitcoin/FeeRateJsonConverter.cs
@@ -4,23 +4,24 @@ using System;
namespace WalletWasabi.JsonConverters.Bitcoin
{
- public class FeeRateJsonConverter : JsonConverter
+ public class FeeRateJsonConverter : JsonConverter<FeeRate>
{
- public override bool CanConvert(Type objectType)
+ public override FeeRate? ReadJson(JsonReader reader, Type objectType, FeeRate? existingValue, bool hasExistingValue, JsonSerializer serializer)
{
- return objectType == typeof(FeeRate);
+ var serialized = (long?)reader.Value;
+ return serialized is null ? null : new FeeRate(Money.Satoshis(serialized.Value));
}
- public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
+ public override void WriteJson(JsonWriter writer, FeeRate? value, JsonSerializer serializer)
{
- return new FeeRate(Money.Satoshis((long)reader.Value));
+ if (value is null)
+ {
+ writer.WriteNull();
}
-
- public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
+ else
{
- var feerate = (FeeRate)value;
-
- writer.WriteValue(feerate.FeePerK.Satoshi);
+ writer.WriteValue(value.FeePerK.Satoshi);
+ }
}
}
}

Switch 'FeeRateJsonConverter' from 'JsonConverter' to 'JsonConverter<T>'