コード例 #1
0
ファイル: InvoiceEntity.cs プロジェクト: zy0n/btcpayserver
        public void SetCryptoData(CryptoData cryptoData)
        {
            var dict = GetCryptoData(null);

            dict.AddOrReplace(cryptoData.CryptoCode, cryptoData);
            SetCryptoData(dict);
        }
コード例 #2
0
        public Dictionary <string, CryptoData> GetCryptoData()
        {
            Dictionary <string, CryptoData> rates = new Dictionary <string, CryptoData>();
            var serializer = new Serializer(Dummy);

#pragma warning disable CS0618
            // Legacy
            if (Rate != 0.0m)
            {
                rates.TryAdd("BTC", new CryptoData()
                {
                    ParentEntity = this, Rate = Rate, CryptoCode = "BTC", TxFee = TxFee, FeeRate = new FeeRate(TxFee, 100), DepositAddress = DepositAddress
                });
            }
            if (CryptoData != null)
            {
                foreach (var prop in CryptoData.Properties())
                {
                    var r = serializer.ToObject <CryptoData>(prop.Value.ToString());
                    r.CryptoCode   = prop.Name;
                    r.ParentEntity = this;
                    rates.TryAdd(r.CryptoCode, r);
                }
            }
#pragma warning restore CS0618
            return(rates);
        }
コード例 #3
0
ファイル: InvoiceEntity.cs プロジェクト: zy0n/btcpayserver
        public Dictionary <string, CryptoData> GetCryptoData(BTCPayNetworkProvider networkProvider, bool alwaysIncludeBTC = false)
        {
            Dictionary <string, CryptoData> rates = new Dictionary <string, CryptoData>();
            var        serializer = new Serializer(Dummy);
            CryptoData phantom    = null;

#pragma warning disable CS0618
            // Legacy
            if (alwaysIncludeBTC)
            {
                var btcNetwork = networkProvider?.GetNetwork("BTC");
                phantom = new CryptoData()
                {
                    ParentEntity = this, IsPhantomBTC = true, Rate = Rate, CryptoCode = "BTC", TxFee = TxFee, FeeRate = new FeeRate(TxFee, 100), DepositAddress = DepositAddress, Network = btcNetwork
                };
                rates.Add("BTC", phantom);
            }
            if (CryptoData != null)
            {
                foreach (var prop in CryptoData.Properties())
                {
                    if (prop.Name == "BTC" && phantom != null)
                    {
                        rates.Remove("BTC");
                    }
                    var r = serializer.ToObject <CryptoData>(prop.Value.ToString());
                    r.CryptoCode   = prop.Name;
                    r.ParentEntity = this;
                    r.Network      = networkProvider?.GetNetwork(r.CryptoCode);
                    rates.Add(r.CryptoCode, r);
                }
            }
#pragma warning restore CS0618
            return(rates);
        }