示例#1
0
        public async Task <IActionResult> LndServices(string cryptoCode, int index, uint?nonce)
        {
            if (!_dashBoard.IsFullySynched(cryptoCode, out var unusud))
            {
                StatusMessage = $"Error: {cryptoCode} is not fully synched";
                return(RedirectToAction(nameof(Services)));
            }
            var external = GetExternalLndConnectionString(cryptoCode, index);

            if (external == null)
            {
                return(NotFound());
            }
            var model = new LndGrpcServicesViewModel();

            if (external.ConnectionType == LightningConnectionType.LndGRPC)
            {
                model.Host                = $"{external.BaseUri.DnsSafeHost}:{external.BaseUri.Port}";
                model.SSL                 = external.BaseUri.Scheme == "https";
                model.ConnectionType      = "GRPC";
                model.GRPCSSLCipherSuites = "ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256";
            }
            else if (external.ConnectionType == LightningConnectionType.LndREST)
            {
                model.Uri            = external.BaseUri.AbsoluteUri;
                model.ConnectionType = "REST";
            }

            if (external.CertificateThumbprint != null)
            {
                model.CertificateThumbprint = Encoders.Hex.EncodeData(external.CertificateThumbprint);
            }
            if (external.Macaroon != null)
            {
                model.Macaroon = Encoders.Hex.EncodeData(external.Macaroon);
            }
            var macaroons = external.MacaroonDirectoryPath == null ? null : await Macaroons.GetFromDirectoryAsync(external.MacaroonDirectoryPath);

            model.AdminMacaroon    = macaroons?.AdminMacaroon?.Hex;
            model.InvoiceMacaroon  = macaroons?.InvoiceMacaroon?.Hex;
            model.ReadonlyMacaroon = macaroons?.ReadonlyMacaroon?.Hex;

            if (nonce != null)
            {
                var configKey = GetConfigKey("lnd", cryptoCode, index, nonce.Value);
                var lnConfig  = _LnConfigProvider.GetConfig(configKey);
                if (lnConfig != null)
                {
                    model.QRCodeLink = $"{this.Request.GetAbsoluteRoot().WithTrailingSlash()}lnd-config/{configKey}/lnd.config";
                    model.QRCode     = $"config={model.QRCodeLink}";
                }
            }

            return(View(model));
        }
示例#2
0
        public IActionResult LndServices(string cryptoCode, int index, uint?nonce)
        {
            if (!_dashBoard.IsFullySynched(cryptoCode, out var unusud))
            {
                StatusMessage = $"Error: {cryptoCode} is not fully synched";
                return(RedirectToAction(nameof(Services)));
            }
            var external = GetExternalLndConnectionString(cryptoCode, index);

            if (external == null)
            {
                return(NotFound());
            }
            var model = new LndGrpcServicesViewModel();

            if (external.ConnectionType == LightningConnectionType.LndGRPC)
            {
                model.Host           = $"{external.BaseUri.DnsSafeHost}:{external.BaseUri.Port}";
                model.SSL            = external.BaseUri.Scheme == "https";
                model.ConnectionType = "GRPC";
            }
            else if (external.ConnectionType == LightningConnectionType.LndREST)
            {
                model.Uri            = external.BaseUri.AbsoluteUri;
                model.ConnectionType = "REST";
            }

            if (external.CertificateThumbprint != null)
            {
                model.CertificateThumbprint = Encoders.Hex.EncodeData(external.CertificateThumbprint);
            }
            if (external.Macaroon != null)
            {
                model.Macaroon = Encoders.Hex.EncodeData(external.Macaroon);
            }
            if (external.RestrictedMacaroon != null)
            {
                model.RestrictedMacaroon = Encoders.Hex.EncodeData(external.RestrictedMacaroon);
            }

            if (nonce != null)
            {
                var configKey = GetConfigKey("lnd", cryptoCode, index, nonce.Value);
                var lnConfig  = _LnConfigProvider.GetConfig(configKey);
                if (lnConfig != null)
                {
                    model.QRCodeLink = $"{this.Request.GetAbsoluteRoot().WithTrailingSlash()}lnd-config/{configKey}/lnd.config";
                    model.QRCode     = $"config={model.QRCodeLink}";
                }
            }

            return(View(model));
        }
        private IActionResult LndServices(ExternalService service, ExternalConnectionString connectionString, uint?nonce)
        {
            var model = new LndGrpcServicesViewModel();

            if (service.Type == ExternalServiceTypes.LNDGRPC)
            {
                model.Host                = $"{connectionString.Server.DnsSafeHost}:{connectionString.Server.Port}";
                model.SSL                 = connectionString.Server.Scheme == "https";
                model.ConnectionType      = "GRPC";
                model.GRPCSSLCipherSuites = "ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256";
            }
            else if (service.Type == ExternalServiceTypes.LNDRest)
            {
                model.Uri            = connectionString.Server.AbsoluteUri;
                model.ConnectionType = "REST";
            }

            if (connectionString.CertificateThumbprint != null)
            {
                model.CertificateThumbprint = connectionString.CertificateThumbprint;
            }
            if (connectionString.Macaroon != null)
            {
                model.Macaroon = Encoders.Hex.EncodeData(connectionString.Macaroon);
            }
            model.AdminMacaroon    = connectionString.Macaroons?.AdminMacaroon?.Hex;
            model.InvoiceMacaroon  = connectionString.Macaroons?.InvoiceMacaroon?.Hex;
            model.ReadonlyMacaroon = connectionString.Macaroons?.ReadonlyMacaroon?.Hex;

            if (nonce != null)
            {
                var configKey = GetConfigKey("lnd", service.ServiceName, service.CryptoCode, nonce.Value);
                var lnConfig  = _LnConfigProvider.GetConfig(configKey);
                if (lnConfig != null)
                {
                    model.QRCodeLink = Url.Action(nameof(GetLNDConfig), new { configKey = configKey });
                    model.QRCode     = $"config={model.QRCodeLink}";
                }
            }

            return(View(nameof(LndServices), model));
        }