btcpayserver/BTCPayServer/Models/StoreViewModels/StoreViewModel.cs

124 lines
3.6 KiB
C#
Raw Normal View History

2018-03-23 17:27:48 +09:00
using BTCPayServer.Services;
using BTCPayServer.Services.Invoices;
2017-09-13 23:50:36 +09:00
using BTCPayServer.Validations;
2017-12-06 18:08:21 +09:00
using Microsoft.AspNetCore.Mvc.Rendering;
2017-09-13 23:50:36 +09:00
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Threading.Tasks;
namespace BTCPayServer.Models.StoreViewModels
{
public class StoreViewModel
{
class Format
{
public string Name { get; set; }
public string Value { get; set; }
}
public class DerivationScheme
2017-12-06 18:08:21 +09:00
{
public string Crypto { get; set; }
2017-12-06 18:08:21 +09:00
public string Value { get; set; }
}
2017-12-06 18:08:21 +09:00
public StoreViewModel()
{
2018-01-09 11:41:07 +09:00
2017-12-06 18:08:21 +09:00
}
public string Id { get; set; }
[Display(Name = "Store Name")]
[Required]
[MaxLength(50)]
[MinLength(1)]
public string StoreName
{
get; set;
}
2017-09-13 23:50:36 +09:00
[Url]
[Display(Name = "Store Website")]
[MaxLength(500)]
public string StoreWebsite
{
get;
set;
}
2017-09-13 23:50:36 +09:00
public List<StoreViewModel.DerivationScheme> DerivationSchemes { get; set; } = new List<StoreViewModel.DerivationScheme>();
2017-12-06 18:08:21 +09:00
public void SetExchangeRates((String DisplayName, String Name)[] supportedList, string preferredExchange)
{
var defaultStore = preferredExchange ?? "coinaverage";
var choices = supportedList.Select(o => new Format() { Name = o.DisplayName, Value = o.Name }).ToArray();
var chosen = choices.FirstOrDefault(f => f.Value == defaultStore) ?? choices.FirstOrDefault();
Exchanges = new SelectList(choices, nameof(chosen.Value), nameof(chosen.Name), chosen);
PreferredExchange = chosen.Value;
}
public SelectList Exchanges { get; set; }
[Display(Name = "Preferred price source (eg. bitfinex, bitstamp...)")]
2018-01-19 16:00:20 +09:00
public string PreferredExchange { get; set; }
public string RateSource
{
get
{
return PreferredExchange.IsCoinAverage() ? "https://apiv2.bitcoinaverage.com/indices/global/ticker/short" : $"https://apiv2.bitcoinaverage.com/exchanges/{PreferredExchange}";
2018-01-19 16:00:20 +09:00
}
}
2018-01-17 15:59:31 +09:00
[Display(Name = "Multiply the original rate by ...")]
[Range(0.01, 10.0)]
public double RateMultiplier
{
get;
set;
}
2018-01-17 15:11:05 +09:00
[Display(Name = "Invoice expires if the full amount has not been paid after ... minutes")]
[Range(1, 60 * 24 * 24)]
2018-01-17 15:11:05 +09:00
public int InvoiceExpiration
{
get;
set;
}
[Display(Name = "Payment invalid if transactions fails to confirm ... minutes after invoice expiration")]
[Range(10, 60 * 24 * 24)]
public int MonitoringExpiration
{
get;
set;
}
[Display(Name = "Consider the invoice confirmed when the payment transaction...")]
public SpeedPolicy SpeedPolicy
{
get; set;
}
2017-09-13 23:50:36 +09:00
[Display(Name = "Add network fee to invoice (vary with mining fees)")]
public bool NetworkFee
{
get; set;
}
[Display(Name = "Description template of the lightning invoice")]
public string LightningDescriptionTemplate { get; set; }
public class LightningNode
{
public string CryptoCode { get; set; }
public string Address { get; set; }
}
public List<LightningNode> LightningNodes
{
get; set;
} = new List<LightningNode>();
}
2017-09-13 23:50:36 +09:00
}