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-02-16 17:34:40 +01:00
|
|
|
|
using BTCPayServer.Services.Invoices;
|
2018-01-08 18:57:06 +01:00
|
|
|
|
using BTCPayServer.Services.Rates;
|
2017-12-21 07:52:04 +01:00
|
|
|
|
using NBitcoin;
|
2018-01-12 03:54:57 +01:00
|
|
|
|
using NBXplorer;
|
2017-12-21 07:52:04 +01:00
|
|
|
|
|
|
|
|
|
namespace BTCPayServer
|
|
|
|
|
{
|
2018-01-11 14:52:28 +01:00
|
|
|
|
public class BTCPayDefaultSettings
|
|
|
|
|
{
|
|
|
|
|
static BTCPayDefaultSettings()
|
|
|
|
|
{
|
2018-04-19 09:54:25 +02:00
|
|
|
|
_Settings = new Dictionary<NetworkType, BTCPayDefaultSettings>();
|
|
|
|
|
foreach (var chainType in new[] { NetworkType.Mainnet, NetworkType.Testnet, NetworkType.Regtest })
|
2018-01-11 14:52:28 +01:00
|
|
|
|
{
|
|
|
|
|
var settings = new BTCPayDefaultSettings();
|
|
|
|
|
_Settings.Add(chainType, settings);
|
2018-04-19 09:54:25 +02:00
|
|
|
|
settings.DefaultDataDirectory = StandardConfiguration.DefaultDataDirectory.GetDirectory("BTCPayServer", NBXplorerDefaultSettings.GetFolderName(chainType));
|
2018-01-11 14:52:28 +01:00
|
|
|
|
settings.DefaultConfigurationFile = Path.Combine(settings.DefaultDataDirectory, "settings.config");
|
2018-04-19 09:54:25 +02:00
|
|
|
|
settings.DefaultPort = (chainType == NetworkType.Mainnet ? 23000 :
|
|
|
|
|
chainType == NetworkType.Regtest ? 23002 :
|
|
|
|
|
chainType == NetworkType.Testnet ? 23001 : throw new NotSupportedException(chainType.ToString()));
|
2018-01-11 14:52:28 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-19 09:54:25 +02:00
|
|
|
|
static Dictionary<NetworkType, BTCPayDefaultSettings> _Settings;
|
2018-01-11 14:52:28 +01:00
|
|
|
|
|
2018-04-19 09:54:25 +02:00
|
|
|
|
public static BTCPayDefaultSettings GetDefaultSettings(NetworkType chainType)
|
2018-01-11 14:52:28 +01:00
|
|
|
|
{
|
|
|
|
|
return _Settings[chainType];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string DefaultDataDirectory { get; set; }
|
|
|
|
|
public string DefaultConfigurationFile { get; 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-06-30 15:05:41 +02:00
|
|
|
|
public Money MinFee { get; internal set; }
|
2018-07-17 06:25:28 +02:00
|
|
|
|
public string DisplayName { 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-02-25 16:48:12 +01:00
|
|
|
|
public string LightningImagePath { get; set; }
|
2018-01-12 03:54:57 +01:00
|
|
|
|
public NBXplorer.NBXplorerNetwork NBXplorerNetwork { get; set; }
|
2018-01-11 14:52:28 +01:00
|
|
|
|
|
|
|
|
|
public BTCPayDefaultSettings DefaultSettings { get; set; }
|
2018-02-12 19:27:36 +01:00
|
|
|
|
public KeyPath CoinType { get; internal set; }
|
2018-02-17 18:19:35 +01:00
|
|
|
|
public int MaxTrackedConfirmation { get; internal set; } = 6;
|
2018-05-02 20:32:42 +02:00
|
|
|
|
public string[] DefaultRateRules { get; internal set; } = Array.Empty<string>();
|
2018-02-12 19:27:36 +01:00
|
|
|
|
|
2018-01-11 09:29:48 +01:00
|
|
|
|
public override string ToString()
|
|
|
|
|
{
|
|
|
|
|
return CryptoCode;
|
2018-04-12 04:48:33 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal KeyPath GetRootKeyPath()
|
|
|
|
|
{
|
|
|
|
|
return new KeyPath(NBitcoinNetwork.Consensus.SupportSegwit ? "49'" : "44'")
|
|
|
|
|
.Derive(CoinType);
|
|
|
|
|
}
|
2017-12-21 07:52:04 +01:00
|
|
|
|
}
|
|
|
|
|
}
|