mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2024-11-19 09:54:30 +01:00
5571413a78
* Allowing for POS to be displayed at website root * Switching to asp attributes for form post action * Applying default formatting rules on HTML * The destination pays mining fees => Subtract fees from amount * small cleanup (#851) * Part2: Openiddict: Init OpenIddict & Database Migration & Auth Policies (#567) * Part 1: OpenIddict - Minor Changes & Config prep * Part 1: OpenIddict - Minor Changes & Config prep * Part2: Openiddict: Init OpenIddict & Database Migration & Auth Policies * pr changes * pr changes * fix merge * pr fixes * remove config for openid -- no need for it for now * fix compile * fix compile #2 * remove extra ns using * Update Startup.cs * compile * adjust settings a bit * remove duplicate * remove external login provider placeholder html * remove unused directives * regenerate db snapshot model * Remove dynamic policy * Provide Pretty descriptions for payment methods from their handlers (#852) * small cleanup * Provide Pretty descriptions for payment methods from their handlers * remove PrettyMethod() * integration with trezor * rough load xpub from trezor * update deriv scheme trezor * move ledger import to dialog * add import from hw wallet dropdown * Support temporary links for local file system provider (#848) * wip * Support temporary links for local file system provider * pass base url to file services * fix test * do not crash on errors with local filesystem * remove console * fix paranthesis * work on trezor.net integration * pushed non compiling sign wallet code * comment out wallet code * abstract ledger ws in add deriv * Auto stash before merge of "trezor" and "btcpayserver/master" * final add changes * cleanup * improve connectivity and fix e2e tests * fix selenium * add experimental warning for trezor * move import button to right and convert to text link * switch to defer and async scripts in add deriv scheme * make defer not async * more elaborate import trezor dialog * Fix small issues * hide trezor for now
112 lines
4.0 KiB
C#
112 lines
4.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using NBitcoin;
|
|
using NBXplorer;
|
|
|
|
namespace BTCPayServer
|
|
{
|
|
public enum DerivationType
|
|
{
|
|
Legacy,
|
|
SegwitP2SH,
|
|
Segwit
|
|
}
|
|
public class BTCPayDefaultSettings
|
|
{
|
|
static BTCPayDefaultSettings()
|
|
{
|
|
_Settings = new Dictionary<NetworkType, BTCPayDefaultSettings>();
|
|
foreach (var chainType in new[] { NetworkType.Mainnet, NetworkType.Testnet, NetworkType.Regtest })
|
|
{
|
|
var settings = new BTCPayDefaultSettings();
|
|
_Settings.Add(chainType, settings);
|
|
settings.DefaultDataDirectory = StandardConfiguration.DefaultDataDirectory.GetDirectory("BTCPayServer", NBXplorerDefaultSettings.GetFolderName(chainType));
|
|
settings.DefaultConfigurationFile = Path.Combine(settings.DefaultDataDirectory, "settings.config");
|
|
settings.DefaultPort = (chainType == NetworkType.Mainnet ? 23000 :
|
|
chainType == NetworkType.Regtest ? 23002 :
|
|
chainType == NetworkType.Testnet ? 23001 : throw new NotSupportedException(chainType.ToString()));
|
|
}
|
|
}
|
|
|
|
static Dictionary<NetworkType, BTCPayDefaultSettings> _Settings;
|
|
|
|
public static BTCPayDefaultSettings GetDefaultSettings(NetworkType chainType)
|
|
{
|
|
return _Settings[chainType];
|
|
}
|
|
|
|
public string DefaultDataDirectory { get; set; }
|
|
public string DefaultConfigurationFile { get; set; }
|
|
public int DefaultPort { get; set; }
|
|
}
|
|
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; }
|
|
public string DisplayName { get; set; }
|
|
|
|
[Obsolete("Should not be needed")]
|
|
public bool IsBTC
|
|
{
|
|
get
|
|
{
|
|
return CryptoCode == "BTC";
|
|
}
|
|
}
|
|
|
|
public string CryptoImagePath { get; set; }
|
|
public string LightningImagePath { get; set; }
|
|
public NBXplorer.NBXplorerNetwork NBXplorerNetwork { get; set; }
|
|
|
|
public BTCPayDefaultSettings DefaultSettings { get; set; }
|
|
public KeyPath CoinType { get; internal set; }
|
|
public int MaxTrackedConfirmation { get; internal set; } = 6;
|
|
public string[] DefaultRateRules { get; internal set; } = Array.Empty<string>();
|
|
public bool SupportRBF { get; internal set; }
|
|
public Dictionary<uint, DerivationType> ElectrumMapping = new Dictionary<uint, DerivationType>();
|
|
public override string ToString()
|
|
{
|
|
return CryptoCode;
|
|
}
|
|
|
|
public KeyPath GetRootKeyPath(DerivationType type)
|
|
{
|
|
KeyPath baseKey;
|
|
if (!NBitcoinNetwork.Consensus.SupportSegwit)
|
|
{
|
|
baseKey = new KeyPath("44'");
|
|
}
|
|
else
|
|
{
|
|
switch (type)
|
|
{
|
|
case DerivationType.Legacy:
|
|
baseKey = new KeyPath("44'");
|
|
break;
|
|
case DerivationType.SegwitP2SH:
|
|
baseKey = new KeyPath("49'");
|
|
break;
|
|
case DerivationType.Segwit:
|
|
baseKey = new KeyPath("84'");
|
|
break;
|
|
default:
|
|
throw new ArgumentOutOfRangeException(nameof(type), type, null);
|
|
}
|
|
}
|
|
return baseKey
|
|
.Derive(CoinType);
|
|
}
|
|
|
|
public KeyPath GetRootKeyPath()
|
|
{
|
|
return new KeyPath(NBitcoinNetwork.Consensus.SupportSegwit ? "49'" : "44'")
|
|
.Derive(CoinType);
|
|
}
|
|
}
|
|
}
|