public override string ToString()
        {
            var           type    = typeMappingReverse[ConnectionType];
            StringBuilder builder = new StringBuilder();

            builder.Append($"type={type}");
            switch (ConnectionType)
            {
            case LightningConnectionType.Charge:
                if (Username == null || Username == "api-token")
                {
                    builder.Append($";server={BaseUri};api-token={Password}");
                }
                else
                {
                    builder.Append($";server={ToUri(true)}");
                }
                break;

            case LightningConnectionType.CLightning:
                builder.Append($";server={BaseUri}");
                break;

            case LightningConnectionType.LndREST:
            case LightningConnectionType.LndGRPC:
                if (Username == null)
                {
                    builder.Append($";server={BaseUri}");
                }
                else
                {
                    builder.Append($";server={ToUri(true)}");
                }
                if (Macaroon != null)
                {
                    builder.Append($";macaroon={Encoder.EncodeData(Macaroon)}");
                }
                if (MacaroonFilePath != null)
                {
                    builder.Append($";macaroonfilepath={MacaroonFilePath}");
                }
                if (CertificateThumbprint != null)
                {
                    builder.Append($";certthumbprint={Encoders.Hex.EncodeData(CertificateThumbprint)}");
                }
                if (AllowInsecure)
                {
                    builder.Append($";allowinsecure=true");
                }
                break;

            default:
                throw new NotSupportedException(type);
            }
            return(builder.ToString());
        }
Esempio n. 2
0
        public override string ToString()
        {
            var           type    = typeMappingReverse[ConnectionType];
            StringBuilder builder = new StringBuilder();

            builder.Append($"type={type}");
            switch (ConnectionType)
            {
            case LightningConnectionType.Charge:
                if (Username == null || Username == "api-token")
                {
                    builder.Append($";server={BaseUri}");
                    if (string.IsNullOrEmpty(Password))
                    {
                        builder.Append($";cookiefilepath={CookieFilePath}");
                    }
                    else
                    {
                        builder.Append($";api-token={Password}");
                    }
                }
                else
                {
                    builder.Append($";server={ToUri(true)}");
                }
                break;

            case LightningConnectionType.CLightning:
                builder.Append($";server={BaseUri}");
                break;

            case LightningConnectionType.LndREST:
            case LightningConnectionType.LndGRPC:
                if (Username == null)
                {
                    builder.Append($";server={BaseUri}");
                }
                else
                {
                    builder.Append($";server={ToUri(true)}");
                }
                if (Macaroon != null)
                {
                    builder.Append($";macaroon={Encoder.EncodeData(Macaroon)}");
                }
                if (MacaroonFilePath != null)
                {
                    builder.Append($";macaroonfilepath={MacaroonFilePath}");
                }
                if (MacaroonDirectoryPath != null)
                {
                    builder.Append($";macaroondirectorypath={MacaroonDirectoryPath}");
                }
                if (CertificateThumbprint != null)
                {
                    builder.Append($";certthumbprint={Encoders.Hex.EncodeData(CertificateThumbprint)}");
                }
                if (AllowInsecure)
                {
                    builder.Append($";allowinsecure=true");
                }
                break;

            case LightningConnectionType.Eclair:
                builder.Append($";server={BaseUri}");
                if (Password != null)
                {
                    builder.Append($";password={Password}");
                }
                if (BitcoinHost != null)
                {
                    builder.Append($";bitcoin-host={BitcoinHost}");
                }
                if (BitcoinAuth != null)
                {
                    builder.Append($";bitcoin-auth={BitcoinAuth}");
                }

                break;

            case LightningConnectionType.Ptarmigan:
                builder.Append($";server={BaseUri}");
                break;

            default:
                throw new NotSupportedException(type);
            }
            return(builder.ToString());
        }