Пример #1
0
        public bool SetStoreBlob(StoreBlob storeBlob)
        {
            var original = new Serializer(Dummy).ToString(GetStoreBlob());
            var newBlob  = new Serializer(Dummy).ToString(storeBlob);

            if (original == newBlob)
            {
                return(false);
            }
            StoreBlob = Encoding.UTF8.GetBytes(newBlob);
            return(true);
        }
        public static bool SetStoreBlob(this StoreData storeData, StoreBlob storeBlob)
        {
            var original = new Serializer(null).ToString(storeData.GetStoreBlob());
            var newBlob  = new Serializer(null).ToString(storeBlob);

            if (original == newBlob)
            {
                return(false);
            }
            storeData.StoreBlob = Encoding.UTF8.GetBytes(newBlob);
            return(true);
        }
Пример #3
0
 public void SetStoreBlob(StoreBlob storeBlob, Network network)
 {
     StoreBlob = Encoding.UTF8.GetBytes(new Serializer(network).ToString(storeBlob));
 }
        public static List <PaymentMethodCriteria> GetPaymentMethodCriteria(this StoreData storeData, BTCPayNetworkProvider networkProvider, StoreBlob storeBlob = null)
        {
#pragma warning disable 612
            storeBlob ??= storeData.GetStoreBlob();

            return(storeData.GetEnabledPaymentIds(networkProvider).Select(paymentMethodId =>
            {
                var matchedFromBlob =
#pragma warning disable CS0618 // Type or member is obsolete
                    storeBlob.PaymentMethodCriteria?.SingleOrDefault(criteria => criteria.PaymentMethod == paymentMethodId && criteria.Value != null);
#pragma warning restore CS0618 // Type or member is obsolete
                if (matchedFromBlob is null && paymentMethodId.PaymentType == LightningPaymentType.Instance && storeBlob.LightningMaxValue != null)
                {
                    return new PaymentMethodCriteria()
                    {
                        Above = false,
                        PaymentMethod = paymentMethodId,
                        Value = storeBlob.LightningMaxValue
                    };
                }
                if (matchedFromBlob is null && paymentMethodId.PaymentType == BitcoinPaymentType.Instance && storeBlob.OnChainMinValue != null)
                {
                    return new PaymentMethodCriteria()
                    {
                        Above = true,
                        PaymentMethod = paymentMethodId,
                        Value = storeBlob.OnChainMinValue
                    };
                }

                return new PaymentMethodCriteria()
                {
                    PaymentMethod = paymentMethodId,
                    Above = matchedFromBlob?.Above ?? true,
                    Value = matchedFromBlob?.Value
                };
            }).ToList());

#pragma warning restore 612
        }