mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-28 00:52:52 +01:00
26 lines
792 B
C#
26 lines
792 B
C#
|
using System;
|
||
|
using NBXplorer;
|
||
|
using Newtonsoft.Json.Linq;
|
||
|
|
||
|
namespace BTCPayServer.Data;
|
||
|
|
||
|
public static class CustodianAccountDataExtensions
|
||
|
{
|
||
|
public static JObject GetBlob(this CustodianAccountData custodianAccountData)
|
||
|
{
|
||
|
var result = custodianAccountData.Blob == null
|
||
|
? new JObject()
|
||
|
: JObject.Parse(ZipUtils.Unzip(custodianAccountData.Blob));
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
public static bool SetBlob(this CustodianAccountData custodianAccountData, JObject blob)
|
||
|
{
|
||
|
var original = custodianAccountData.GetBlob();
|
||
|
if (JToken.DeepEquals(original, blob))
|
||
|
return false;
|
||
|
custodianAccountData.Blob = blob is null ? null : ZipUtils.Zip(blob.ToString(Newtonsoft.Json.Formatting.None));
|
||
|
return true;
|
||
|
}
|
||
|
}
|