Refactor how we handle and validate LN ConnectionStrings (#2314)

* Refactor how we handle and validate LN ConnectionStrings

* Migrate existing connection string to Internal Node if they are the same. Cleanup some obsolete fields

* Fix typos, remove duplicated method

* Add a InternalNodeRef to LightningSupportedPaymentMethod
This commit is contained in:
Nicolas Dorier
2021-03-02 11:11:58 +09:00
committed by GitHub
parent 49ae62b02e
commit 7e714f1ef8
24 changed files with 572 additions and 297 deletions

View File

@@ -69,14 +69,6 @@ namespace BTCPayServer.Data
#pragma warning disable CS0618
bool btcReturned = false;
// Legacy stuff which should go away
if (!string.IsNullOrEmpty(storeData.DerivationStrategy))
{
btcReturned = true;
yield return DerivationSchemeSettings.Parse(storeData.DerivationStrategy, networks.BTC);
}
if (!string.IsNullOrEmpty(storeData.DerivationStrategies))
{
JObject strategies = JObject.Parse(storeData.DerivationStrategies);
@@ -130,11 +122,6 @@ namespace BTCPayServer.Data
foreach (var strat in strategies.Properties().ToList())
{
var stratId = PaymentMethodId.Parse(strat.Name);
if (stratId.IsBTCOnChain)
{
// Legacy stuff which should go away
storeData.DerivationStrategy = null;
}
if (stratId == paymentMethodId)
{
if (supportedPaymentMethod == null)
@@ -149,12 +136,7 @@ namespace BTCPayServer.Data
break;
}
}
if (!existing && supportedPaymentMethod == null && paymentMethodId.IsBTCOnChain)
{
storeData.DerivationStrategy = null;
}
else if (!existing && supportedPaymentMethod != null)
if (!existing && supportedPaymentMethod != null)
strategies.Add(new JProperty(supportedPaymentMethod.PaymentId.ToString(), PaymentMethodExtensions.Serialize(supportedPaymentMethod)));
storeData.DerivationStrategies = strategies.ToString();
#pragma warning restore CS0618