mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-18 14:34:23 +01:00
Add also money json converter
This commit is contained in:
25
BTCPayServer.Client/JsonConverters/MoneyJsonConverter.cs
Normal file
25
BTCPayServer.Client/JsonConverters/MoneyJsonConverter.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using NBitcoin;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace BTCPayServer.Client.JsonConverters
|
||||
{
|
||||
public class MoneyJsonConverter : NBitcoin.JsonConverters.MoneyJsonConverter
|
||||
{
|
||||
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
|
||||
{
|
||||
if (reader.TokenType == JsonToken.String)
|
||||
{
|
||||
return new Money( long.Parse((string) reader.Value));
|
||||
}
|
||||
return base.ReadJson(reader, objectType, existingValue, serializer);
|
||||
}
|
||||
|
||||
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
|
||||
{
|
||||
if (value != null)
|
||||
writer.WriteValue(((Money)value).Satoshi.ToString(CultureInfo.InvariantCulture));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
using NBitcoin;
|
||||
using NBitcoin.JsonConverters;
|
||||
using Newtonsoft.Json;
|
||||
using MoneyJsonConverter = BTCPayServer.Client.JsonConverters.MoneyJsonConverter;
|
||||
|
||||
namespace BTCPayServer.Client.Models
|
||||
{
|
||||
|
||||
@@ -61,7 +61,7 @@
|
||||
"LightMoney": {
|
||||
"type": "string",
|
||||
"format": "int64",
|
||||
"description": "The id of the store",
|
||||
"description": "a number amount wrapped in a string, represented in millistatoshi (00000000001BTC = 1 mSAT)",
|
||||
"additionalProperties": false
|
||||
},
|
||||
"LightningChannelData": {
|
||||
@@ -214,8 +214,9 @@
|
||||
}
|
||||
},
|
||||
"Money": {
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
"type": "string",
|
||||
"format": "int64",
|
||||
"description": "a number amount wrapped in a string, represented in satoshi (00000001BTC = 1 sat)"
|
||||
},
|
||||
"FeeRate": {
|
||||
"oneOf": [
|
||||
|
||||
Reference in New Issue
Block a user