MoneySatoshiJsonConverter: Fix warnings
MODIFY
WalletWasabi/JsonConverters/Bitcoin/MoneySatoshiJsonConverter.cs
WalletWasabi/JsonConverters/Bitcoin/MoneySatoshiJsonConverter.cs
@@ -7,17 +7,31 @@ namespace WalletWasabi.JsonConverters.Bitcoin
public class MoneySatoshiJsonConverter : JsonConverter<Money>
{
/// <inheritdoc />
- public override Money ReadJson(JsonReader reader, Type objectType, Money existingValue, bool hasExistingValue, JsonSerializer serializer)
+ public override Money? ReadJson(JsonReader reader, Type objectType, Money? existingValue, bool hasExistingValue, JsonSerializer serializer)
{
- var serialized = (long)reader.Value;
+ var serialized = (long?)reader.Value;
- return new Money(serialized);
+ if (serialized is null)
+ {
+ return null;
+ }
+ else
+ {
+ return new Money(serialized.Value);
+ }
}
/// <inheritdoc />
- public override void WriteJson(JsonWriter writer, Money value, JsonSerializer serializer)
+ public override void WriteJson(JsonWriter writer, Money? value, JsonSerializer serializer)
+ {
+ if (value is null)
+ {
+ writer.WriteNull();
+ }
+ else
{
writer.WriteValue(value.Satoshi);
}
}
}
+}

MoneySatoshiJsonConverter: Fix warnings

Co-authored-by: Kiminuo <kiminuo@protonmail.com>