public ImportProvider_AddEnergie(NetworkType network)
        {
            this.SelectedNetworkType = network;

            ServiceUserName = "******";
            ProviderName = "AddEnergie";

            if (network == NetworkType.ReseauVER)
            {
                ServiceBaseURL = "https://admin.reseauver.com";
                ServicePassword = System.Configuration.ConfigurationManager.AppSettings["ImportProviderAPIKey_AddEnergieReseauVER"];
                ProviderName += " [ReseauVER]";
                DataProviderID = 24;
            }

            if (network == NetworkType.LeCircuitElectrique)
            {
                ServiceBaseURL = "https://lecircuitelectrique.co";
                ServicePassword = System.Configuration.ConfigurationManager.AppSettings["ImportProviderAPIKey_AddEnergieLeCircuitElectrique"];
                ProviderName += " [LeCircuitElectrique]";
                DataProviderID = 24;
            }

            AutoRefreshURL = ServiceBaseURL + "/Network/StationsList";

            OutputNamePrefix = "AddEnergie_" + network.ToString();

            IsAutoRefreshed = true;
            IsProductionReady = true;

            SourceEncoding = Encoding.GetEncoding("UTF-8");

            //this provider requires InitImportProvider to be called
            ImportInitialisationRequired = true;
        }
Beispiel #2
0
 public NetworkInfo(string network_name,int transport_id,int network_id)
 {
   netType = NetworkType.Unknown;
   NetworkName = network_name;
   this.transport_id = transport_id;
   this.network_id = network_id;
   LCN = -1;
   service_id = -1;
 }
Beispiel #3
0
 public AccountInfo()
 {
     this.publicKey = new Hash();
     this.money = 0;
     this.name = "";
     this.accountState = AccountState.Normal;
     this.networkType = NetworkType.MainNet;
     this.accountType = AccountType.MainNormal;
     this.lastTransactionTime = 0;
 }
Beispiel #4
0
 /// <summary>
 /// 设置字节流,并解开包的头部信息
 /// </summary>
 /// <param name="buffer"></param>
 /// <param name="type"></param>
 /// <returns></returns>
 public bool pushNetStream(byte[] buffer, NetworkType type)
 {
     byte[] data;
     if (!_formater.TryParse(buffer, out _head, out data))
     {
         Debug.LogError(" Failed: NetReader's pushNetStream parse head error: buffer Length " + buffer.Length);
         return false;
     }
     SetBuffer(data);
     return true;
 }
Beispiel #5
0
        public AccountInfo(Hash publicKey, long money)
        {
            this.publicKey = publicKey;
            this.money = money;
            this.name = "";
            this.accountState = AccountState.Normal;
            this.networkType = NetworkType.MainNet;
            this.accountType = AccountType.MainNormal;
            this.lastTransactionTime = 0;

            updateInternalHash();
        }
        static void CallbackNetworkType(GetNetworkTypePayload payload,NetworkType result)
        {
            if(payload.OnUiThread)
            {
                Deployment.Current.Dispatcher.BeginInvoke(() => payload.Callback(result));

            }
            else
            {
                payload.Callback(result);
            }
        }
Beispiel #7
0
        public AccountInfo(Hash publicKey, long money, string name, AccountState accountState,
            NetworkType networkType, AccountType accountType, long lastTransactionTime)
        {
            if (!Utils.ValidateUserName(name)) throw new ArgumentException("Usernames should be lowercase and alphanumeric, _ is allowed");

            this.publicKey = publicKey;
            this.money = money;
            this.name = name;
            this.accountState = accountState;
            this.networkType = networkType;
            this.accountType = accountType;
            this.lastTransactionTime = lastTransactionTime;

            updateInternalHash();
        }
 private void GetNetworkInfo()
 {
     var profile = Windows.Networking.Connectivity.NetworkInformation.GetInternetConnectionProfile();
     if (profile == null)
         _NetworkType = NetworkType.None;
     else if (profile.GetConnectionCost().NetworkCostType == Windows.Networking.Connectivity.NetworkCostType.Unrestricted)
     {
         _NetworkType = NetworkType.Unlimited;
         _UnlimitedNetwork = true;
     }
     else
     {
         _NetworkType = NetworkType.Metered;
         _UnlimitedNetwork = false;
     }
 }
Beispiel #9
0
			public ProfilePack(
				string name,
				string interfaceName,
				string ssid,
				NetworkType networkType,
				string authentication,
				string encryption,
				int position,
				bool isAutomatic)
			{
				this.Name = name;
				this.InterfaceName = interfaceName;
				this.Ssid = ssid;
				this.NetworkType = networkType;
				this.Authentication = authentication;
				this.Encryption = encryption;
				this.Position = position;
				this.IsAutomatic = isAutomatic;
			}
        // If we ever want to make an implementation of INetwork that we want in core,
        /// <summary>
        /// Creates an INetwork instance of the specified network type.
        /// </summary>
        /// <param name="networkType">Type of the file.</param>
        /// <returns></returns>
        internal static INetwork Create(NetworkType networkType)
        {
            INetwork network = new NetworkAsynch();

            switch (networkType)
            {
                case NetworkType.NetworkAsynch:
                    network = new NetworkAsynch();
                    break;
                case NetworkType.NetworkSynch:
                    network = new NetworkSynch();
                    break;
                default:
                    // returns the default - BasicNetwork implementation                 
                    break;
            }

            return network;
        }
Beispiel #11
0
    public bool TryParse(string data, NetworkType type, out PackageHead head, out object body)
    {
        body = null;
        head = null;
        try
        {
            ResponseBody result = JsonConvert.DeserializeObject<ResponseBody>(data);
            if (result == null) return false;

            head = new PackageHead();
            head.StatusCode = result.StateCode;
            head.Description = result.StateDescription;
            body = result.Data;
            return true;

        }
        catch (Exception ex)
        {
            return false;
        }
    }
Beispiel #12
0
        internal override byte[] GenerateBytes()
        {
            var builder = new FlatBufferBuilder(1);

            var transactionsBytes = new byte[0];

            transactionsBytes = InnerTransactions.Aggregate(transactionsBytes, (current, innerTransaction) => current.Concat(innerTransaction.ToAggregate()).ToArray());

            // Create Vectors
            var signatureVector    = AggregateTransactionBuffer.CreateSignatureVector(builder, new byte[64]);
            var signerVector       = AggregateTransactionBuffer.CreateSignerVector(builder, GetSigner());
            var deadlineVector     = AggregateTransactionBuffer.CreateDeadlineVector(builder, Deadline.Ticks.ToUInt8Array());
            var feeVector          = AggregateTransactionBuffer.CreateFeeVector(builder, Fee.ToUInt8Array());
            var transactionsVector = AggregateTransactionBuffer.CreateTransactionsVector(builder, transactionsBytes);

            ushort version = ushort.Parse(NetworkType.GetNetworkByte().ToString("X") + "0" + Version.ToString("X"), System.Globalization.NumberStyles.HexNumber);

            // add vectors
            AggregateTransactionBuffer.StartAggregateTransactionBuffer(builder);
            AggregateTransactionBuffer.AddSize(builder, (uint)(120 + 4 + transactionsBytes.Length));
            AggregateTransactionBuffer.AddSignature(builder, signatureVector);
            AggregateTransactionBuffer.AddSigner(builder, signerVector);
            AggregateTransactionBuffer.AddVersion(builder, version);
            AggregateTransactionBuffer.AddType(builder, TransactionType.GetValue());
            AggregateTransactionBuffer.AddFee(builder, feeVector);
            AggregateTransactionBuffer.AddDeadline(builder, deadlineVector);
            AggregateTransactionBuffer.AddTransactionsSize(builder, (uint)transactionsBytes.Length);
            AggregateTransactionBuffer.AddTransactions(builder, transactionsVector);

            // end build
            var codedTransaction = AggregateTransactionBuffer.EndAggregateTransactionBuffer(builder).Value;

            builder.Finish(codedTransaction);

            return(new AggregateTransactionSchema().Serialize(builder.SizedByteArray()));
        }
            /// <summary>
            /// 初始化网络频道的新实例。
            /// </summary>
            /// <param name="name">网络频道名称。</param>
            /// <param name="networkChannelHelper">网络频道辅助器。</param>
            public NetworkChannel(string name, INetworkChannelHelper networkChannelHelper)
            {
                m_Name                 = name ?? string.Empty;
                m_SendPacketPool       = new Queue <Packet>();
                m_ReceivePacketPool    = new EventPool <Packet>(EventPoolMode.Default);
                m_NetworkChannelHelper = networkChannelHelper;
                m_NetworkType          = NetworkType.Unknown;
                m_ResetHeartBeatElapseSecondsWhenReceivePacket = false;
                m_HeartBeatInterval = DefaultHeartBeatInterval;
                m_Socket            = null;
                m_SendState         = new SendState();
                m_ReceiveState      = new ReceiveState();
                m_HeartBeatState    = new HeartBeatState();
                m_Active            = false;
                m_Disposed          = false;

                NetworkChannelConnected     = null;
                NetworkChannelClosed        = null;
                NetworkChannelMissHeartBeat = null;
                NetworkChannelError         = null;
                NetworkChannelCustomError   = null;

                networkChannelHelper.Initialize(this);
            }
 public NBXplorerNetworkProvider(NetworkType networkType)
 {
     InitBitcoin(networkType);
     InitBitcore(networkType);
     InitLitecoin(networkType);
     InitDogecoin(networkType);
     InitBCash(networkType);
     InitGroestlcoin(networkType);
     InitBGold(networkType);
     InitDash(networkType);
     InitPolis(networkType);
     InitMonacoin(networkType);
     InitFeathercoin(networkType);
     InitUfo(networkType);
     InitViacoin(networkType);
     InitMonoeci(networkType);
     InitGobyte(networkType);
     InitColossus(networkType);
     NetworkType = networkType;
     foreach (var chain in _Networks.Values)
     {
         chain.DerivationStrategyFactory = new DerivationStrategy.DerivationStrategyFactory(chain.NBitcoinNetwork);
     }
 }
Beispiel #15
0
        public ImportProvider_AddEnergie(NetworkType network, string apiKey)
        {
            this.SelectedNetworkType = network;
            this.ApiKey = apiKey;

            ServiceUserName = "******";
            ProviderName    = "AddEnergie";

            if (network == NetworkType.ReseauVER)
            {
                ServiceBaseURL  = "https://admin.reseauver.com";
                ServicePassword = apiKey;
                ProviderName   += " [ReseauVER]";
                DataProviderID  = 24;
            }

            if (network == NetworkType.LeCircuitElectrique)
            {
                ServiceBaseURL  = "https://lecircuitelectrique.co";
                ServicePassword = apiKey;
                ProviderName   += " [LeCircuitElectrique]";
                DataProviderID  = 24;
            }

            AutoRefreshURL = ServiceBaseURL + "/Network/StationsList";

            OutputNamePrefix = "AddEnergie_" + network.ToString();

            IsAutoRefreshed   = true;
            IsProductionReady = true;

            SourceEncoding = Encoding.GetEncoding("UTF-8");

            //this provider requires InitImportProvider to be called
            ImportInitialisationRequired = true;
        }
Beispiel #16
0
        public void ParseOption(NetworkType networkType, object option)
        {
            var generateKeyStoreOption = (GenerateKeyStoreOption)option;

            if (!_fileSystem.SetCurrentPath(generateKeyStoreOption.Path))
            {
                _userOutput.WriteLine("Invalid path.");
                return;
            }

            var       secureStr = _passwordLoader.PreloadPassword(generateKeyStoreOption.Password);
            Exception error     = null;

            try
            {
                var privateKey = _keyStore.KeyStoreGenerateAsync(networkType, KeyRegistryTypes.DefaultKey).ConfigureAwait(false)
                                 .GetAwaiter().GetResult();
                var publicKey = privateKey.GetPublicKey().Bytes.KeyToString();

                _userOutput.WriteLine($"Generated key store at path: {Path.GetFullPath(generateKeyStoreOption.Path)}");
                _userOutput.WriteLine($"Public Key: {publicKey}");
            }
            catch (Exception e)
            {
                _userOutput.WriteLine($"Error generating keystore at path {generateKeyStoreOption.Path}");
                error = e;
            }
            finally
            {
                secureStr?.Dispose();
                if (error != null)
                {
                    throw error;
                }
            }
        }
Beispiel #17
0
        public override void OnReceive(Context context, Intent intent)
        {
            INetworkService networkService = Locator.Current.GetService <INetworkService>();
            NetworkType     status         = networkService.GetConnectivityStatus();

            switch (status)
            {
            case NetworkType.Not_Conected:
                //Toast.MakeText(context, "Not connected", ToastLength.Short).Show();
                break;

            case NetworkType.Wifi:
                //Toast.MakeText(context, "WIFI", ToastLength.Short).Show();
                Locator.Current.GetService <SincroPendingUseCase>().Execute();
                break;

            case NetworkType.Mobile:
                //Toast.MakeText(context, "MOBILE", ToastLength.Short).Show();
                //if (synchronizationService.GetPendingEntries() > 0)
                //    Task.Run(() => synchronizationService.SynchronicePendingEntries());
                Locator.Current.GetService <SincroPendingUseCase>().Execute();
                break;
            }
        }
Beispiel #18
0
    public bool TryParse(string data, NetworkType type, out PackageHead head, out object body)
    {
        body = null;
        head = null;
        try
        {
            //ResponseBody result = JsonConvert.DeserializeObject<ResponseBody>(data);
            ResponseBody result = LitJson.JsonMapper.ToObject <ResponseBody>(data);
            if (result == null)
            {
                return(false);
            }

            head             = new PackageHead();
            head.StatusCode  = result.StateCode;
            head.Description = result.StateDescription;
            body             = result.Data;
            return(true);
        }
        catch (Exception ex)
        {
            return(false);
        }
    }
Beispiel #19
0
        public BTCPayNetworkProvider(NetworkType networkType)
        {
            UnfilteredNetworks        = this;
            _NBXplorerNetworkProvider = new NBXplorerNetworkProvider(networkType);
            NetworkType = networkType;
            InitBitcoin();
            InitLitecoin();
            InitBitcore();
            InitDogecoin();
            InitBitcoinGold();
            InitMonacoin();
            InitDash();
            InitFeathercoin();
            InitGroestlcoin();
            InitViacoin();
            // Assume that electrum mappings are same as BTC if not specified
            foreach (var network in _Networks.Values.OfType <BTCPayNetwork>())
            {
                if (network.ElectrumMapping.Count == 0)
                {
                    network.ElectrumMapping = GetNetwork <BTCPayNetwork>("BTC").ElectrumMapping;
                    if (!network.NBitcoinNetwork.Consensus.SupportSegwit)
                    {
                        network.ElectrumMapping =
                            network.ElectrumMapping
                            .Where(kv => kv.Value == DerivationType.Legacy)
                            .ToDictionary(k => k.Key, k => k.Value);
                    }
                }
            }

            // Disabled because of https://twitter.com/Cryptopia_NZ/status/1085084168852291586
            //InitPolis();
            //InitBitcoinplus();
            //InitUfo();
        }
Beispiel #20
0
        /// <summary>
        /// Return the pay to witness script hash address from the given <see cref="IScript"/>.
        /// </summary>
        /// <exception cref="ArgumentException"/>
        /// <exception cref="ArgumentNullException"/>
        /// <param name="script">Script to use</param>
        /// <param name="witVer">Witness version to use</param>
        /// <param name="netType">[Default value = <see cref="NetworkType.MainNet"/>] Network type</param>
        /// <returns>The resulting address</returns>
        public string GetP2wsh(IScript script, byte witVer, NetworkType netType = NetworkType.MainNet)
        {
            if (script is null)
            {
                throw new ArgumentNullException(nameof(script), "Script can not be null.");
            }
            if (witVer != 0)
            {
                throw new ArgumentException("Currently only address version 0 is defined for P2WSH.", nameof(witVer));
            }

            string hrp = netType switch
            {
                NetworkType.MainNet => HrpMainNet,
                NetworkType.TestNet => HrpTestNet,
                NetworkType.RegTest => HrpRegTest,
                _ => throw new ArgumentException(Err.InvalidNetwork),
            };

            using Sha256 witHashFunc = new Sha256();
            byte[] hash = witHashFunc.ComputeHash(script.Data);

            return(b32Encoder.Encode(hash, witVer, hrp));
        }
Beispiel #21
0
 /// <summary>
 /// 设置字节流,并解开包的头部信息
 /// </summary>
 /// <param name="buffer"></param>
 /// <param name="type"></param>
 /// <param name="respContentType"></param>
 /// <returns></returns>
 public bool pushNetStream(byte[] buffer, NetworkType type, ResponseContentType respContentType)
 {
     if (respContentType == ResponseContentType.Json)
     {
         string jsonData = Encoding.UTF8.GetString(buffer);
         Debug.Log("response json:" + jsonData);
         if (!_formater.TryParse(jsonData, type, out _head, out Data))
         {
             Debug.LogError(" Failed: NetReader's pushNetStream parse error.");
             return(false);
         }
         SetBuffer(new byte[0]);
         Debug.Log("parse json ok." + _head.Description);
         return(true);
     }
     byte[] data;
     if (!_formater.TryParse(buffer, out _head, out data))
     {
         Debug.LogError(" Failed: NetReader's pushNetStream parse head error: buffer Length " + buffer.Length);
         return(false);
     }
     SetBuffer(data);
     return(true);
 }
        // GET api/FBToken
        public async Task<string> Get(NetworkType providerType)
        {
            ServiceUser user = this.User as ServiceUser;
            if (user == null)
            {
                throw new InvalidOperationException("Choosen provider is not authenticated with the user at the moment!");
            }
            ProviderCredentials creds = null;
            if (providerType == NetworkType.FACEBOOK)
            {
                creds = (await user.GetIdentitiesAsync()).OfType<FacebookCredentials>().FirstOrDefault();
                if (creds != null)
                    return ((FacebookCredentials)creds).AccessToken;
            }
            else if (providerType == NetworkType.LINKED_IN)
            {
                creds = (await user.GetIdentitiesAsync()).OfType<LinkedInCredentials>().FirstOrDefault();
                if (creds != null)
                    return ((LinkedInCredentials)creds).AccessToken;
            }
           

            throw new InvalidOperationException("Choosen provider is not authenticated with the user at the moment!");
        }
Beispiel #23
0
        private async Task <PeerApi> GetInitialPeer(NetworkType type, int retryCount = 0)
        {
            var peerUrl = _peerSeedListMainNet[new Random().Next(_peerSeedListMainNet.Count)];

            if (type == NetworkType.DevNet)
            {
                peerUrl = _peerSeedListDevNet[new Random().Next(_peerSeedListDevNet.Count)];
            }

            var peer = new PeerApi(peerUrl.Item1, peerUrl.Item2);

            if (await peer.IsOnline())
            {
                return(peer);
            }

            if ((type == NetworkType.DevNet && retryCount == _peerSeedListDevNet.Count) ||
                (type == NetworkType.MainNet && retryCount == _peerSeedListMainNet.Count))
            {
                throw new Exception("Unable to connect to a seed peer");
            }

            return(await GetInitialPeer(type, retryCount + 1));
        }
Beispiel #24
0
        //peer connects to hosts(interprocesses)
        public NetPeer CreatePeer(string ip, int port, NetworkType netType)
        {
//#if !CLIENT
            var ep   = new IPEndPoint(IPAddress.Parse(ip), port);
            var addr = ep.ToString();

            var hostId = Global.IdManager.GetHostId(addr);

            if (hostId != 0)
            {
                return(Global.NetManager.GetPeerById(hostId, netType));
            }
//#endif

            var peer = NetPeer.Create(ep, netType);

            if (peer == null)
            {
                return(null);
            }

            peer.OnClose     += OnClose;
            peer.OnReceive   += OnReceive;
            peer.OnException += OnException;

            if (netType == NetworkType.TCP)
            {
                tcpPeers[peer.ConnId] = peer;
            }
            else
            {
                kcpPeers[peer.ConnId] = peer;
            }
            peer.Register();
            return(peer);
        }
	void Awake()
	{
		networktype = Networktype;
	}
Beispiel #26
0
        private static ProfilePack GetProfile(IEnumerable <string> outputLines, string interfaceName, string profileName, int position)
        {
            bool?       autoConnect    = null;
            bool?       autoSwitch     = null;
            string      ssid           = null;
            NetworkType networkType    = default(NetworkType);
            string      authentication = null;
            string      encryption     = null;

            foreach (var outputLine in outputLines.Where(x => !string.IsNullOrWhiteSpace(x)))
            {
                try
                {
                    if (!autoConnect.HasValue)
                    {
                        var autoConnectBuff = FindElement(outputLine, "Connection mode");
                        if (autoConnectBuff != null)
                        {
                            autoConnect = autoConnectBuff.Equals("Connect automatically", StringComparison.OrdinalIgnoreCase);
                        }

                        continue;
                    }
                    if (!autoSwitch.HasValue)
                    {
                        var autoSwitchBuff = FindElement(outputLine, "AutoSwitch");
                        if (autoSwitchBuff != null)
                        {
                            autoSwitch = autoSwitchBuff.Equals("Switch to more preferred network if possible", StringComparison.OrdinalIgnoreCase);
                        }

                        continue;
                    }
                    if (ssid == null)
                    {
                        var ssidBuff = FindElement(outputLine, "SSID name");
                        if (ssidBuff != null)
                        {
                            ssid = ssidBuff.Trim('"');
                        }

                        continue;
                    }
                    if (networkType == default(NetworkType))
                    {
                        networkType = ConvertToNetworkType(FindElement(outputLine, "Network type"));
                        continue;
                    }
                    if (authentication == null)
                    {
                        authentication = FindElement(outputLine, "Authentication");
                        continue;
                    }
                    if (encryption == null)
                    {
                        encryption = FindElement(outputLine, "Cipher");
                        break;
                    }
                }
                catch (Exception ex)
                {
                    Debug.WriteLine("Failed to enumerate profiles." + Environment.NewLine
                                    + ex);
                    throw;
                }
            }

            if (!autoConnect.HasValue ||
                !autoSwitch.HasValue ||
                (ssid == null) ||
                (networkType == default(NetworkType)) ||
                (authentication == null) ||
                (encryption == null))
            {
                return(null);
            }

            //Debug.WriteLine("Profile: {0}, Interface: {1}, SSID: {2}, BSS: {3}, Authentication: {4}, Encryption: {5}, AutoConnect: {6}, AutoSwitch: {7}, Position: {8}",
            //	profileName,
            //	interfaceName,
            //	ssid,
            //	networkType,
            //	authentication,
            //	encryption,
            //	autoConnect.Value,
            //	autoSwitch.Value,
            //	position);

            return(new ProfilePack(
                       name: profileName,
                       interfaceName: interfaceName,
                       ssid: ssid,
                       networkType: networkType,
                       authentication: authentication,
                       encryption: encryption,
                       isAutoConnectEnabled: autoConnect.Value,
                       isAutoSwitchEnabled: autoSwitch.Value,
                       position: position));
        }
        // POST api/FBConnectUser
        public async System.Threading.Tasks.Task<HttpResponseMessage> Get(NetworkType providerType)
        {
            ServiceUser user = this.User as ServiceUser;
            HttpStatusCode httpStatus = HttpStatusCode.OK;
            MobileServiceContext context = new MobileServiceContext();
            Account account = null;
            ProviderCredentials creds = null;
            bool firstLogin = false;

            if (providerType == NetworkType.FACEBOOK)
            {
                creds = (await user.GetIdentitiesAsync()).OfType<FacebookCredentials>().FirstOrDefault();
                if (creds != null)
                {
                    account = context.Accounts.FirstOrDefault(a => a.FacebookId == creds.UserId);
                    if(account == null)
                    {
                        firstLogin = true;
                        account = new Account()
                        {
                            Id = Guid.NewGuid().ToString(),
                            Username =  "******",
                            FacebookId = creds.UserId
                        };
                        context.Accounts.Add(account);
                        UserInfo newUserInfo;
                        context.UserInfos.Add(newUserInfo = new UserInfo()
                        {
                            UserId = account.Id,
                            Id = Guid.NewGuid().ToString()
                        });

                        context.SaveChanges();
                        httpStatus = HttpStatusCode.Created;
                    }
                }
            }

            if (providerType == NetworkType.LINKED_IN)
            {
                creds = (await user.GetIdentitiesAsync()).OfType<LinkedInCredentials>().FirstOrDefault();
                if (creds != null)
                {
                    account = context.Accounts.FirstOrDefault(a => a.LinkedInId == creds.UserId);
                    if (account == null)
                    {
                        firstLogin = true;
                        account = new Account()
                        {
                            Id = Guid.NewGuid().ToString(),
                            Username = "******",
                            LinkedInId = creds.UserId
                        };
                        context.Accounts.Add(account);
                        UserInfo newUserInfo;
                        context.UserInfos.Add(newUserInfo = new UserInfo()
                        {
                            UserId = account.Id,
                            Id = Guid.NewGuid().ToString()
                        });

                        context.SaveChanges();
                        httpStatus = HttpStatusCode.Created;
                    }
                }
            }

            if (account != null)
            {
                var customLoginResult = new ProviderLoginResult()
                {
                    AccountId = account.Id,
                    username = account.Username,
                    FirstLogin = firstLogin
                };
                return this.Request.CreateResponse(httpStatus, customLoginResult);
            }

            return this.Request.CreateResponse(httpStatus);
        }
Beispiel #28
0
 public abstract void SetNetwork(NetworkType network);
Beispiel #29
0
 public void RunConfigStartUp_Should_Not_Overwrite_An_Existing_Config_File(string moduleFileName,
                                                                           NetworkType network)
 {
     RunConfigStartUp_Should_Not_Overwrite_Existing_Files(moduleFileName, network);
 }
 public InputLayerAbstract(int inputParametersCount, int outputParametersCount, NetworkType nType)
 {
     _inputParametersCount  = inputParametersCount;
     _outputParametersCount = outputParametersCount;
     _networkT = nType;
 }
Beispiel #31
0
 public PortStatus GetPortStatus(NetworkType type)
 {
     return(GetPortStatus(type.GetAddressFamily()));
 }
Beispiel #32
0
 public static AccountIdentifier PrivateKeyToAccount(byte[] PrivateSecretSeed, string Name = "",
     NetworkType NetworkType = NetworkType.MainNet, AccountType AccountType = AccountType.MainNormal)
 {
     byte[] PublicKey;
     byte[] SecretKeyExpanded;
     Ed25519.KeyPairFromSeed(out PublicKey, out SecretKeyExpanded, PrivateSecretSeed);
     return PublicKeyToAccount(PublicKey, Name, NetworkType, AccountType);
 }
        public void LoadArgs(IConfiguration conf)
        {
            NetworkType = DefaultConfiguration.GetNetworkType(conf);
            var defaultSettings = BTCPayDefaultSettings.GetDefaultSettings(NetworkType);

            DataDir = conf.GetOrDefault <string>("datadir", defaultSettings.DefaultDataDirectory);
            Logs.Configuration.LogInformation("Network: " + NetworkType.ToString());

            var supportedChains = conf.GetOrDefault <string>("chains", "btc")
                                  .Split(',', StringSplitOptions.RemoveEmptyEntries)
                                  .Select(t => t.ToUpperInvariant());

            NetworkProvider = new BTCPayNetworkProvider(NetworkType).Filter(supportedChains.ToArray());
            foreach (var chain in supportedChains)
            {
                if (NetworkProvider.GetNetwork(chain) == null)
                {
                    throw new ConfigException($"Invalid chains \"{chain}\"");
                }
            }

            var validChains = new List <string>();

            foreach (var net in NetworkProvider.GetAll())
            {
                NBXplorerConnectionSetting setting = new NBXplorerConnectionSetting();
                setting.CryptoCode  = net.CryptoCode;
                setting.ExplorerUri = conf.GetOrDefault <Uri>($"{net.CryptoCode}.explorer.url", net.NBXplorerNetwork.DefaultSettings.DefaultUrl);
                setting.CookieFile  = conf.GetOrDefault <string>($"{net.CryptoCode}.explorer.cookiefile", net.NBXplorerNetwork.DefaultSettings.DefaultCookieFile);
                NBXplorerConnectionSettings.Add(setting);
                var lightning = conf.GetOrDefault <string>($"{net.CryptoCode}.lightning", string.Empty);
                if (lightning.Length != 0)
                {
                    if (!LightningConnectionString.TryParse(lightning, true, out var connectionString, out var error))
                    {
                        throw new ConfigException($"Invalid setting {net.CryptoCode}.lightning, " + Environment.NewLine +
                                                  $"If you have a lightning server use: 'type=clightning;server=/root/.lightning/lightning-rpc', " + Environment.NewLine +
                                                  $"If you have a lightning charge server: 'type=charge;server=https://charge.example.com;api-token=yourapitoken'" + Environment.NewLine +
                                                  $"If you have a lnd server: 'type=lnd-rest;server=https://lnd:[email protected];macaron=abf239...;certthumbprint=2abdf302...'");
                    }
                    if (connectionString.IsLegacy)
                    {
                        Logs.Configuration.LogWarning($"Setting {net.CryptoCode}.lightning will work but use an deprecated format, please replace it by '{connectionString.ToString()}'");
                    }
                    InternalLightningByCryptoCode.Add(net.CryptoCode, connectionString);
                }
            }

            Logs.Configuration.LogInformation("Supported chains: " + String.Join(',', supportedChains.ToArray()));

            PostgresConnectionString = conf.GetOrDefault <string>("postgres", null);
            BundleJsCss = conf.GetOrDefault <bool>("bundlejscss", true);
            ExternalUrl = conf.GetOrDefault <Uri>("externalurl", null);

            RootPath = conf.GetOrDefault <string>("rootpath", "/");
            if (!RootPath.StartsWith("/", StringComparison.InvariantCultureIgnoreCase))
            {
                RootPath = "/" + RootPath;
            }
            var old = conf.GetOrDefault <Uri>("internallightningnode", null);

            if (old != null)
            {
                throw new ConfigException($"internallightningnode should not be used anymore, use btclightning instead");
            }
        }
Beispiel #34
0
 public static AccountIdentifier PublicKeyToAccount(byte[] PublicKey, string Name = "",
     NetworkType NetworkType = NetworkType.MainNet, AccountType AccountType = AccountType.MainNormal)
 {
     byte[] Address = GetAddress(PublicKey, Name, NetworkType, AccountType);
     string ADD = Base58Encoding.EncodeWithCheckSum(Address);
     return new AccountIdentifier(PublicKey, Name, ADD);
 }
Beispiel #35
0
        public static bool VerfiyAddress(string Address, byte[] PublicKey, string UserName, NetworkType networkType, AccountType accountType)
        {
            if (!Utils.ValidateUserName(UserName)) return false;

            if (Address == Base58Encoding.EncodeWithCheckSum(GetAddress(PublicKey, UserName, networkType, accountType)))
            {
                return true;
            }

            return false;
        }
Beispiel #36
0
 public AddressFactory()
 {
     _NetworkType = NetworkType.MainNet;
     _AccountType = AccountType.MainNormal;
 }
Beispiel #37
0
        public void Deserialize(byte[] Data)
        {
            List<ProtocolDataType> PDTs = ProtocolPackager.UnPackRaw(Data);
            int cnt = 0;

            while (cnt < (int)PDTs.Count)
            {
                ProtocolDataType PDT = PDTs[cnt++];

                switch (PDT.NameType)
                {
                    case 0:
                        ProtocolPackager.UnpackHash(PDT, 0, out publicKey);
                        break;

                    case 1:
                        ProtocolPackager.UnpackInt64(PDT, 1, ref money);
                        break;

                    case 2:
                        ProtocolPackager.UnpackString(PDT, 2, ref name);
                        break;

                    case 3:
                        byte _accountState = 0;
                        ProtocolPackager.UnpackByte(PDT, 3, ref _accountState);
                        accountState = (AccountState)_accountState;
                        break;

                    case 4:
                        byte _networkType = 0;
                        ProtocolPackager.UnpackByte(PDT, 4, ref _networkType);
                        networkType = (NetworkType)_networkType;
                        break;

                    case 5:
                        byte _accountType = 0;
                        ProtocolPackager.UnpackByte(PDT, 5, ref _accountType);
                        accountType = (AccountType)_accountType;
                        break;

                    case 6:
                        ProtocolPackager.UnpackInt64(PDT, 6, ref lastTransactionTime);
                        break;
                }
            }

            updateInternalHash();
        }
Beispiel #38
0
 public static NBXplorerDefaultSettings GetDefaultSettings(NetworkType networkType)
 {
     return(_Settings[networkType]);
 }
Beispiel #39
0
	public void Initial(NetworkType netType, string ipAddress, int port) {
		
		type = netType;
		this.ipAddress = ipAddress;
		this.port = port;
	}
Beispiel #40
0
			public NetworkPack(
				string interfaceName,
				string ssid,
				NetworkType networkType,
				string authentication,
				string encryption,
				int signal)
			{
				this.InterfaceName = interfaceName;
				this.Ssid = ssid;
				this.NetworkType = networkType;
				this.Authenticaion = authentication;
				this.Encryption = encryption;
				this.Signal = signal;
			}
Beispiel #41
0
 public IClient(NetworkType netType, string ipAddress, int port)
 {
     type = netType;
     this.ipAddress = ipAddress;
     this.port = port;
 }
Beispiel #42
0
        /// <summary>
        /// Returns the 
        /// H = SHA512, 
        /// Address Format : Address = NetType || AccountType || [H(H(PK) || PK || NAME || NetType || AccountType)], Take first 20 bytes}
        /// </summary>
        public static byte[] GetAddress(byte[] PublicKey, string UserName, NetworkType networkType, AccountType accountType)
        {
            if (!Utils.ValidateUserName(UserName)) throw new ArgumentException("Usernames should be lowercase and alphanumeric, _ is allowed");

            if (networkType == NetworkType.MainNet)
            {
                if (accountType == AccountType.TestGenesis ||
                    accountType == AccountType.TestValidator ||
                    accountType == AccountType.TestNormal)
                {
                    throw new ArgumentException("Invalid AccountType for the provided NetworkType.");
                }
            }

            byte[] NAME = Utils.Encoding88591.GetBytes(UserName);

            byte[] Hpk = (new SHA512Cng()).ComputeHash(PublicKey);

            byte[] NA_Type = new byte[] { (byte)networkType, (byte)accountType };

            byte[] Hpk__PK__NAME = Hpk.Concat(PublicKey).Concat(NAME).Concat(NA_Type).ToArray();

            byte[] H_Hpk__PK__NAME = (new SHA512Cng()).ComputeHash(Hpk__PK__NAME).Take(20).ToArray();

            byte[] Address_PH = new byte[22];

            Address_PH[0] = NA_Type[0];
            Address_PH[1] = NA_Type[1];
            Array.Copy(H_Hpk__PK__NAME, 0, Address_PH, 2, 20);

            /* byte[] CheckSum = (new SHA512Managed()).ComputeHash(Address_PH, 0, 22).Take(4).ToArray();
             Array.Copy(CheckSum, 0, Address_PH, 22, 4);*/

            return Address_PH;
        }
Beispiel #43
0
 protected override IEnumerable <string> RequiredConfigFiles(NetworkType network,
                                                             string overrideNetworkFile = null)
 {
     return(new List <string>(GetExpectedFileList(network)));
 }
Beispiel #44
0
 /// <summary>
 ///     GetValue
 /// </summary>
 /// <param name="type">The network type</param>
 /// <returns>int</returns>
 public static int GetValue(this NetworkType type)
 {
     return((int)type);
 }
 public ServiceBlockedAttribute(NetworkType networkType)
 {
     this.NetworkType = networkType;
 }
Beispiel #46
0
 public AddressType(NetworkType networkType, AccountType accountType)
 {
     NetworkType = networkType;
     AccountType = accountType;
 }
        public void LoadArgs(IConfiguration conf)
        {
            NetworkType = DefaultConfiguration.GetNetworkType(conf);
            var defaultSettings = BTCPayDefaultSettings.GetDefaultSettings(NetworkType);

            DataDir = conf.GetOrDefault <string>("datadir", defaultSettings.DefaultDataDirectory);
            Logs.Configuration.LogInformation("Network: " + NetworkType.ToString());

            var supportedChains = conf.GetOrDefault <string>("chains", "btc")
                                  .Split(',', StringSplitOptions.RemoveEmptyEntries)
                                  .Select(t => t.ToUpperInvariant());

            NetworkProvider = new BTCPayNetworkProvider(NetworkType).Filter(supportedChains.ToArray());
            foreach (var chain in supportedChains)
            {
                if (NetworkProvider.GetNetwork(chain) == null)
                {
                    throw new ConfigException($"Invalid chains \"{chain}\"");
                }
            }

            var validChains = new List <string>();

            foreach (var net in NetworkProvider.GetAll())
            {
                NBXplorerConnectionSetting setting = new NBXplorerConnectionSetting();
                setting.CryptoCode  = net.CryptoCode;
                setting.ExplorerUri = conf.GetOrDefault <Uri>($"{net.CryptoCode}.explorer.url", net.NBXplorerNetwork.DefaultSettings.DefaultUrl);
                setting.CookieFile  = conf.GetOrDefault <string>($"{net.CryptoCode}.explorer.cookiefile", net.NBXplorerNetwork.DefaultSettings.DefaultCookieFile);
                NBXplorerConnectionSettings.Add(setting);

                {
                    var lightning = conf.GetOrDefault <string>($"{net.CryptoCode}.lightning", string.Empty);
                    if (lightning.Length != 0)
                    {
                        if (!LightningConnectionString.TryParse(lightning, true, out var connectionString, out var error))
                        {
                            Logs.Configuration.LogWarning($"Invalid setting {net.CryptoCode}.lightning, " + Environment.NewLine +
                                                          $"If you have a c-lightning server use: 'type=clightning;server=/root/.lightning/lightning-rpc', " + Environment.NewLine +
                                                          $"If you have a lightning charge server: 'type=charge;server=https://charge.example.com;api-token=yourapitoken'" + Environment.NewLine +
                                                          $"If you have a lnd server: 'type=lnd-rest;server=https://lnd:[email protected];macaroon=abf239...;certthumbprint=2abdf302...'" + Environment.NewLine +
                                                          $"              lnd server: 'type=lnd-rest;server=https://lnd:[email protected];macaroonfilepath=/root/.lnd/admin.macaroon;certthumbprint=2abdf302...'" + Environment.NewLine +
                                                          $"Error: {error}" + Environment.NewLine +
                                                          "This service will not be exposed through BTCPay Server");
                        }
                        else
                        {
                            if (connectionString.IsLegacy)
                            {
                                Logs.Configuration.LogWarning($"Setting {net.CryptoCode}.lightning is a deprecated format, it will work now, but please replace it for future versions with '{connectionString.ToString()}'");
                            }
                            InternalLightningByCryptoCode.Add(net.CryptoCode, connectionString);
                        }
                    }
                }

                void externalLnd <T>(string code, string lndType)
                {
                    var lightning = conf.GetOrDefault <string>(code, string.Empty);

                    if (lightning.Length != 0)
                    {
                        if (!LightningConnectionString.TryParse(lightning, false, out var connectionString, out var error))
                        {
                            Logs.Configuration.LogWarning($"Invalid setting {code}, " + Environment.NewLine +
                                                          $"lnd server: 'type={lndType};server=https://lnd.example.com;macaroon=abf239...;certthumbprint=2abdf302...'" + Environment.NewLine +
                                                          $"lnd server: 'type={lndType};server=https://lnd.example.com;macaroonfilepath=/root/.lnd/admin.macaroon;certthumbprint=2abdf302...'" + Environment.NewLine +
                                                          $"Error: {error}" + Environment.NewLine +
                                                          "This service will not be exposed through BTCPay Server");
                        }
                        else
                        {
                            var instanceType = typeof(T);
                            ExternalServicesByCryptoCode.Add(net.CryptoCode, (ExternalService)Activator.CreateInstance(instanceType, connectionString));
                        }
                    }
                };

                externalLnd <ExternalLndGrpc>($"{net.CryptoCode}.external.lnd.grpc", "lnd-grpc");
                externalLnd <ExternalLndRest>($"{net.CryptoCode}.external.lnd.rest", "lnd-rest");

                {
                    var spark = conf.GetOrDefault <string>($"{net.CryptoCode}.external.spark", string.Empty);
                    if (spark.Length != 0)
                    {
                        if (!SparkConnectionString.TryParse(spark, out var connectionString, out var error))
                        {
                            Logs.Configuration.LogWarning($"Invalid setting {net.CryptoCode}.external.spark, " + Environment.NewLine +
                                                          $"Valid example: 'server=https://btcpay.example.com/spark/btc/;cookiefile=/etc/clightning_bitcoin_spark/.cookie'" + Environment.NewLine +
                                                          $"Error: {error}" + Environment.NewLine +
                                                          "This service will not be exposed through BTCPay Server");
                        }
                        else
                        {
                            ExternalServicesByCryptoCode.Add(net.CryptoCode, new ExternalSpark(connectionString));
                        }
                    }
                }
Beispiel #48
0
 public AddressFactory(NetworkType networkType, AccountType accountType)
 {
     _NetworkType = networkType;
     _AccountType = accountType;
 }
Beispiel #49
0
 /// <summary>
 ///     GetValueInByte
 /// </summary>
 /// <param name="type">The network type</param>
 /// <returns>byte</returns>
 public static byte GetValueInByte(this NetworkType type)
 {
     return((byte)type);
 }
Beispiel #50
0
 public VirtualEthernet(NetworkType netType, string address, EthernetDeviceType ethType)
 {
     this.netType = netType;
     this.address = address;
     this.ethType = ethType;
 }
Beispiel #51
0
        private static IEnumerable <NetworkPack> EnumerateNetworks(IEnumerable <string> outputLines)
        {
            var ssidPattern    = new Regex(@"\bSSID (?<index>[1-9](?:\d|)(?:\d|)) *: *(?<value>\S.*)");
            var signalPattern  = new Regex(@"\bSignal *: *(?<value>(?:100|[1-9](?:\d|)|0))%");
            var channelPattern = new Regex(@"\bChannel *: *(?<value>[1-9]\d{0,2})");

            string      interfaceName  = null;
            string      ssid           = null;
            NetworkType networkType    = default(NetworkType);
            string      authentication = null;
            string      encryption     = null;
            int?        signal         = null;
            int?        channel        = null;

            foreach (var outputLine in outputLines)
            {
                try
                {
                    var interfaceNameBuff = FindElement(outputLine, "Interface name");
                    if (interfaceNameBuff != null)
                    {
                        interfaceName = interfaceNameBuff;
                    }
                    if (ssid == null)
                    {
                        if (!string.IsNullOrWhiteSpace(outputLine))
                        {
                            var match = ssidPattern.Match(outputLine);
                            if (match.Success)
                            {
                                ssid = match.Groups["value"].Value.Trim();
                            }
                        }
                        continue;
                    }
                    if (networkType == default(NetworkType))
                    {
                        networkType = ConvertToNetworkType(FindElement(outputLine, "Network type"));
                        continue;
                    }
                    if (authentication == null)
                    {
                        authentication = FindElement(outputLine, "Authentication");
                        continue;
                    }
                    if (encryption == null)
                    {
                        encryption = FindElement(outputLine, "Encryption");
                        continue;
                    }
                    if (!signal.HasValue)
                    {
                        if (!string.IsNullOrWhiteSpace(outputLine))
                        {
                            var match = signalPattern.Match(outputLine);
                            if (match.Success)
                            {
                                signal = int.Parse(match.Groups["value"].Value);
                            }
                        }
                        continue;
                    }
                    if (!channel.HasValue)
                    {
                        if (!string.IsNullOrWhiteSpace(outputLine))
                        {
                            var match = channelPattern.Match(outputLine);
                            if (match.Success)
                            {
                                channel = int.Parse(match.Groups["value"].Value);
                            }
                        }
                        continue;
                    }
                }
                catch (Exception ex)
                {
                    Debug.WriteLine("Failed to enumerate networks." + Environment.NewLine
                                    + ex);
                    throw;
                }

                Debug.WriteLine("Interface: {0}, SSID: {1}, BSS type: {2}, Authentication: {3}, Encryption: {4}, Signal: {5}, Channel: {6}",
                                interfaceName,
                                ssid,
                                networkType,
                                authentication,
                                encryption,
                                signal.Value,
                                channel.Value);

                yield return(new NetworkPack(
                                 interfaceName: interfaceName,
                                 ssid: ssid,
                                 networkType: networkType,
                                 authentication: authentication,
                                 encryption: encryption,
                                 signal: signal.Value,
                                 band: (channel.Value <= 14) ? 2.4F : 5F,
                                 channel: channel.Value));

                ssid           = null;
                networkType    = default(NetworkType);
                authentication = null;
                encryption     = null;
                signal         = null;
                channel        = null;
            }
        }
Beispiel #52
0
 public CompNetwork(string name, Company company, float price, string partInterface, int powerRequirement, float defectiveChance, NetworkType networkType, int ping, int bandwidth)
     : base(name, company, price, partInterface, powerRequirement, defectiveChance)
 {
     this.networkType = networkType;
     this.ping = ping;
     this.bandwidth = bandwidth;
 }
Beispiel #53
0
        /* Constructor: NeuralNet

            Creates a neural network of the desired <NetworkType> netType, based on a collection of layers.

            Parameters:
                netType - The desired network type of the neural network
                layers - the collection of layer sizes

            Example:
              >NeuralNet net(NetworkType.LAYER, new uint[] {2, 3, 1});

            This function appears in FANN >= 2.3.0.
         */
        public NeuralNet(NetworkType netType, ICollection<uint> layers)
        {
            using (uintArray newLayers = new uintArray(layers.Count))
            {
                int i = 0;
                foreach (uint count in layers)
                {
                    newLayers.setitem(i, count);
                    i++;
                }
                Outputs = newLayers.getitem(layers.Count - 1);
                net = new neural_net(netType, (uint)layers.Count, newLayers.cast());
            }
        }
 public static BlockchainConfigTransaction Create(Deadline deadline, ulong applyHeightDelta, string blockchainConfig, string supportedEntityVersions, NetworkType networkType)
 {
     return(new BlockchainConfigTransaction(networkType,
                                            EntityVersion.BLOCKCHAIN_CONFIG.GetValue(),
                                            EntityType.BLOCKCHAIN_CONFIG,
                                            deadline,
                                            0,
                                            applyHeightDelta,
                                            blockchainConfig,
                                            supportedEntityVersions));
 }
Beispiel #55
0
        /* Constructor: NeuralNet

            Creates a neural network of the desired <NetworkType> net_type.

            Parameters:
                numLayers - The total number of layers including the input and the output layer.
                ... - Integer values determining the number of neurons in each layer starting with the
                    input layer and ending with the output layer.

            Example:
                >unt numLayes = 3;
                >uint numInput = 2;
                >uint numHidden = 3;
                >uint numOutput = 1;
                >
                >NeuralNet net(numLayers, numInput, numHidden, numOutput);

            This function appears in FANN >= 2.3.0.
        */
        public NeuralNet(NetworkType netType, uint numLayers, params uint[] args)
        {
            using (uintArray newLayers = new uintArray((int)numLayers))
            {
                for (int i = 0; i < args.Length; i++)
                {
                    newLayers.setitem(i, args[i]);
                }
                Outputs = args[args.Length - 1];
                net = new neural_net(netType, numLayers, newLayers.cast());
            }
        }
Beispiel #56
0
 public AbstractBlockchain(Database db, NetworkType net)
 {
     _db      = db;
     _network = net;
 }
Beispiel #57
0
 public static extern NodeSettings kth_config_node_settings_default(NetworkType network);
Beispiel #58
0
 public Network(NetworkType networkType)
 {
     this.Id = (Int16)networkType;
     this.Name = networkType.ToString();
 }
        public void LoadArgs(IConfiguration conf)
        {
            NetworkType = DefaultConfiguration.GetNetworkType(conf);

            Logs.Configuration.LogInformation("Network: " + NetworkType.ToString());

            if (conf.GetOrDefault <bool>("launchsettings", false) && NetworkType != NetworkType.Regtest)
            {
                throw new ConfigException($"You need to run BTCPayServer with the run.sh or run.ps1 script");
            }

            var supportedChains = conf.GetOrDefault <string>("chains", "btc")
                                  .Split(',', StringSplitOptions.RemoveEmptyEntries)
                                  .Select(t => t.ToUpperInvariant()).ToHashSet();

            var networkProvider = new BTCPayNetworkProvider(NetworkType);
            var filtered        = networkProvider.Filter(supportedChains.ToArray());

#if ALTCOINS
            supportedChains.AddRange(filtered.GetAllElementsSubChains(networkProvider));
            supportedChains.AddRange(filtered.GetAllEthereumSubChains(networkProvider));
#endif
#if !ALTCOINS
            var onlyBTC = supportedChains.Count == 1 && supportedChains.First() == "BTC";
            if (!onlyBTC)
            {
                throw new ConfigException($"This build of BTCPay Server does not support altcoins");
            }
#endif
            NetworkProvider = networkProvider.Filter(supportedChains.ToArray());
            foreach (var chain in supportedChains)
            {
                if (NetworkProvider.GetNetwork <BTCPayNetworkBase>(chain) == null)
                {
                    throw new ConfigException($"Invalid chains \"{chain}\"");
                }
            }

            var validChains = new List <string>();
            foreach (var net in NetworkProvider.GetAll().OfType <BTCPayNetwork>())
            {
                NBXplorerConnectionSetting setting = new NBXplorerConnectionSetting();
                setting.CryptoCode  = net.CryptoCode;
                setting.ExplorerUri = conf.GetOrDefault <Uri>($"{net.CryptoCode}.explorer.url", net.NBXplorerNetwork.DefaultSettings.DefaultUrl);
                setting.CookieFile  = conf.GetOrDefault <string>($"{net.CryptoCode}.explorer.cookiefile", net.NBXplorerNetwork.DefaultSettings.DefaultCookieFile);
                NBXplorerConnectionSettings.Add(setting);

                {
                    var lightning = conf.GetOrDefault <string>($"{net.CryptoCode}.lightning", string.Empty);
                    if (lightning.Length != 0)
                    {
                        if (!LightningConnectionString.TryParse(lightning, true, out var connectionString, out var error))
                        {
                            Logs.Configuration.LogWarning($"Invalid setting {net.CryptoCode}.lightning, " + Environment.NewLine +
                                                          $"If you have a c-lightning server use: 'type=clightning;server=/root/.lightning/lightning-rpc', " + Environment.NewLine +
                                                          $"If you have a lightning charge server: 'type=charge;server=https://charge.example.com;api-token=yourapitoken'" + Environment.NewLine +
                                                          $"If you have a lnd server: 'type=lnd-rest;server=https://lnd:[email protected];macaroon=abf239...;certthumbprint=2abdf302...'" + Environment.NewLine +
                                                          $"              lnd server: 'type=lnd-rest;server=https://lnd:[email protected];macaroonfilepath=/root/.lnd/admin.macaroon;certthumbprint=2abdf302...'" + Environment.NewLine +
                                                          $"If you have an eclair server: 'type=eclair;server=http://eclair.com:4570;password=eclairpassword;bitcoin-host=bitcoind:37393;bitcoin-auth=bitcoinrpcuser:bitcoinrpcpassword" + Environment.NewLine +
                                                          $"               eclair server: 'type=eclair;server=http://eclair.com:4570;password=eclairpassword;bitcoin-host=bitcoind:37393" + Environment.NewLine +
                                                          $"Error: {error}" + Environment.NewLine +
                                                          "This service will not be exposed through BTCPay Server");
                        }
                        else
                        {
                            if (connectionString.IsLegacy)
                            {
                                Logs.Configuration.LogWarning($"Setting {net.CryptoCode}.lightning is a deprecated format, it will work now, but please replace it for future versions with '{connectionString.ToString()}'");
                            }
                            InternalLightningByCryptoCode.Add(net.CryptoCode, connectionString);
                        }
                    }
                }

                ExternalServices.Load(net.CryptoCode, conf);
            }
 public bool TryParse(string data, NetworkType type, out PackageHead head, out object body)
 {
     throw new System.NotImplementedException();
 }