2017-12-21 07:52:04 +01:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2018-01-11 14:52:28 +01:00
|
|
|
|
using System.IO;
|
2017-12-21 07:52:04 +01:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Threading.Tasks;
|
2018-01-08 18:57:06 +01:00
|
|
|
|
using BTCPayServer.Services.Rates;
|
2017-12-21 07:52:04 +01:00
|
|
|
|
using NBitcoin;
|
2018-01-11 14:52:28 +01:00
|
|
|
|
using NBXplorer.Configuration;
|
2017-12-21 07:52:04 +01:00
|
|
|
|
|
|
|
|
|
namespace BTCPayServer
|
|
|
|
|
{
|
2018-01-11 14:52:28 +01:00
|
|
|
|
public enum ChainType
|
|
|
|
|
{
|
|
|
|
|
Regtest,
|
|
|
|
|
Main,
|
|
|
|
|
Test
|
|
|
|
|
}
|
|
|
|
|
public class BTCPayDefaultSettings
|
|
|
|
|
{
|
|
|
|
|
static BTCPayDefaultSettings()
|
|
|
|
|
{
|
|
|
|
|
_Settings = new Dictionary<ChainType, BTCPayDefaultSettings>();
|
|
|
|
|
foreach (var chainType in new[] { ChainType.Main, ChainType.Test, ChainType.Regtest })
|
|
|
|
|
{
|
|
|
|
|
var btcNetwork = (chainType == ChainType.Main ? Network.Main :
|
|
|
|
|
chainType == ChainType.Regtest ? Network.RegTest :
|
|
|
|
|
chainType == ChainType.Test ? Network.TestNet : throw new NotSupportedException(chainType.ToString()));
|
|
|
|
|
|
|
|
|
|
var settings = new BTCPayDefaultSettings();
|
|
|
|
|
_Settings.Add(chainType, settings);
|
|
|
|
|
settings.ChainType = chainType;
|
|
|
|
|
settings.DefaultDataDirectory = StandardConfiguration.DefaultDataDirectory.GetDirectory("BTCPayServer", btcNetwork.Name);
|
|
|
|
|
settings.DefaultConfigurationFile = Path.Combine(settings.DefaultDataDirectory, "settings.config");
|
|
|
|
|
settings.DefaultPort = (chainType == ChainType.Main ? 23000 :
|
|
|
|
|
chainType == ChainType.Regtest ? 23002 :
|
|
|
|
|
chainType == ChainType.Test ? 23001 : throw new NotSupportedException(chainType.ToString()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static Dictionary<ChainType, BTCPayDefaultSettings> _Settings;
|
|
|
|
|
|
|
|
|
|
public static BTCPayDefaultSettings GetDefaultSettings(ChainType chainType)
|
|
|
|
|
{
|
|
|
|
|
return _Settings[chainType];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string DefaultDataDirectory { get; set; }
|
|
|
|
|
public string DefaultConfigurationFile { get; set; }
|
|
|
|
|
public ChainType ChainType { get; internal set; }
|
|
|
|
|
public int DefaultPort { get; set; }
|
|
|
|
|
}
|
2017-12-21 07:52:04 +01:00
|
|
|
|
public class BTCPayNetwork
|
|
|
|
|
{
|
|
|
|
|
public Network NBitcoinNetwork { get; set; }
|
|
|
|
|
public string CryptoCode { get; internal set; }
|
|
|
|
|
public string BlockExplorerLink { get; internal set; }
|
|
|
|
|
public string UriScheme { get; internal set; }
|
2018-01-08 18:57:06 +01:00
|
|
|
|
public IRateProvider DefaultRateProvider { get; set; }
|
2018-01-06 10:57:56 +01:00
|
|
|
|
|
|
|
|
|
[Obsolete("Should not be needed")]
|
|
|
|
|
public bool IsBTC
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return CryptoCode == "BTC";
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-01-09 03:41:07 +01:00
|
|
|
|
|
|
|
|
|
public string CryptoImagePath { get; set; }
|
2018-01-11 14:52:28 +01:00
|
|
|
|
public NetworkInformation NBXplorerNetwork { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public BTCPayDefaultSettings DefaultSettings { get; set; }
|
2018-01-11 09:29:48 +01:00
|
|
|
|
public override string ToString()
|
|
|
|
|
{
|
|
|
|
|
return CryptoCode;
|
|
|
|
|
}
|
2017-12-21 07:52:04 +01:00
|
|
|
|
}
|
|
|
|
|
}
|