mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2024-11-19 18:11:36 +01:00
Saving of Macaroon and Tls for LND connection
This commit is contained in:
parent
d34ffc0d9a
commit
3c4c99ee42
@ -27,7 +27,7 @@ namespace BTCPayServer.Controllers
|
||||
LightningNodeViewModel vm = new LightningNodeViewModel();
|
||||
vm.CryptoCode = cryptoCode;
|
||||
vm.InternalLightningNode = GetInternalLighningNode(cryptoCode)?.UriWithCreds?.AbsoluteUri;
|
||||
vm.Url = GetExistingLightningSupportedPaymentMethod(vm.CryptoCode, store)?.GetLightningUrl()?.UriWithCreds.AbsoluteUri;
|
||||
vm.Url = GetExistingLightningSupportedPaymentMethod(vm.CryptoCode, store)?.GetLightningUrl()?.ToFullEditString();
|
||||
return View(vm);
|
||||
}
|
||||
|
||||
|
@ -461,7 +461,7 @@ namespace BTCPayServer.Controllers
|
||||
vm.LightningNodes.Add(new StoreViewModel.LightningNode()
|
||||
{
|
||||
CryptoCode = network.CryptoCode,
|
||||
Address = lightning?.GetLightningUrl()?.UriPlain.AbsoluteUri ?? string.Empty
|
||||
Address = lightning?.GetLightningUrl()?.BaseUri.AbsoluteUri ?? string.Empty
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -25,8 +25,8 @@ namespace BTCPayServer.Payments.Lightning
|
||||
public LightningConnectionType ConnectionType { get; private set; }
|
||||
|
||||
// Extract this to LndConnectionString class
|
||||
public string Tls { get; set; }
|
||||
public string Macaroon { get; set; }
|
||||
public string Tls { get; set; }
|
||||
//
|
||||
|
||||
public Uri UriWithCreds
|
||||
@ -44,6 +44,23 @@ namespace BTCPayServer.Payments.Lightning
|
||||
return UriWithCreds.AbsoluteUri;
|
||||
}
|
||||
|
||||
public string ToFullEditString()
|
||||
{
|
||||
var dict = new Dictionary<string,string>();
|
||||
if (!String.IsNullOrEmpty(Macaroon))
|
||||
dict.Add("macaroon", Macaroon);
|
||||
if (!String.IsNullOrEmpty(Tls))
|
||||
dict.Add("tls", Tls);
|
||||
|
||||
if (dict.Count > 0)
|
||||
{
|
||||
var qs = dict.Select(a => $"{a.Key}={a.Value}");
|
||||
return UriWithCreds.AbsoluteUri + "?" + String.Join("&", qs);
|
||||
}
|
||||
else
|
||||
return UriWithCreds.AbsoluteUri;
|
||||
}
|
||||
|
||||
//
|
||||
public static bool TryParse(string str, out LightningConnectionString connectionString)
|
||||
{
|
||||
|
@ -8,9 +8,21 @@ namespace BTCPayServer.Payments.Lightning
|
||||
public class LightningSupportedPaymentMethod : ISupportedPaymentMethod
|
||||
{
|
||||
public string CryptoCode { get; set; }
|
||||
public PaymentMethodId PaymentId => new PaymentMethodId(CryptoCode, PaymentTypes.LightningLike);
|
||||
|
||||
[Obsolete("Use Get/SetLightningUrl")]
|
||||
public string LightningChargeUrl { get; set; }
|
||||
|
||||
[Obsolete("Use Get/SetLightningUrl")]
|
||||
public string Username { get; set; }
|
||||
[Obsolete("Use Get/SetLightningUrl")]
|
||||
public string Password { get; set; }
|
||||
|
||||
[Obsolete("Use Get/SetLightningUrl")]
|
||||
public string Macaroon { get; set; }
|
||||
[Obsolete("Use Get/SetLightningUrl")]
|
||||
public string Tls { get; set; }
|
||||
|
||||
public LightningConnectionString GetLightningUrl()
|
||||
{
|
||||
#pragma warning disable CS0618 // Type or member is obsolete
|
||||
@ -19,6 +31,8 @@ namespace BTCPayServer.Payments.Lightning
|
||||
{
|
||||
throw new FormatException(error);
|
||||
}
|
||||
connectionString.Macaroon = Macaroon;
|
||||
connectionString.Tls = Tls;
|
||||
return connectionString;
|
||||
#pragma warning restore CS0618 // Type or member is obsolete
|
||||
}
|
||||
@ -31,14 +45,11 @@ namespace BTCPayServer.Payments.Lightning
|
||||
#pragma warning disable CS0618 // Type or member is obsolete
|
||||
Username = connectionString.Username;
|
||||
Password = connectionString.Password;
|
||||
Macaroon = connectionString.Macaroon;
|
||||
Tls = connectionString.Tls;
|
||||
|
||||
LightningChargeUrl = connectionString.BaseUri.AbsoluteUri;
|
||||
#pragma warning restore CS0618 // Type or member is obsolete
|
||||
}
|
||||
|
||||
[Obsolete("Use Get/SetLightningUrl")]
|
||||
public string Username { get; set; }
|
||||
[Obsolete("Use Get/SetLightningUrl")]
|
||||
public string Password { get; set; }
|
||||
public PaymentMethodId PaymentId => new PaymentMethodId(CryptoCode, PaymentTypes.LightningLike);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user