示例#1
0
        public static InvoiceEntity GetBlob(this Data.InvoiceData invoiceData, BTCPayNetworkProvider networks)
        {
            var entity = NBitcoin.JsonConverters.Serializer.ToObject <InvoiceEntity>(ZipUtils.Unzip(invoiceData.Blob), null);

            entity.Networks = networks;
            return(entity);
        }
示例#2
0
        public static UserBlob GetBlob(this ApplicationUser user)
        {
            var result = user.Blob == null
                ? new UserBlob()
                : JObject.Parse(ZipUtils.Unzip(user.Blob)).ToObject <UserBlob>();

            return(result);
        }
示例#3
0
        public static PaymentEntity GetBlob(this Data.PaymentData paymentData, BTCPayNetworkProvider networks)
        {
            var unziped    = ZipUtils.Unzip(paymentData.Blob);
            var cryptoCode = "BTC";

            if (JObject.Parse(unziped).TryGetValue("cryptoCode", out var v) && v.Type == JTokenType.String)
            {
                cryptoCode = v.Value <string>();
            }
            var           network       = networks.GetNetwork <BTCPayNetworkBase>(cryptoCode);
            PaymentEntity paymentEntity = null;

            if (network == null)
            {
                paymentEntity = NBitcoin.JsonConverters.Serializer.ToObject <PaymentEntity>(unziped, null);
            }
            else
            {
                paymentEntity = network.ToObject <PaymentEntity>(unziped);
            }
            paymentEntity.Network   = network;
            paymentEntity.Accounted = paymentData.Accounted;
            return(paymentEntity);
        }