Remove disable BOLT11 option

This commit is contained in:
Dennis Reimann
2023-04-25 12:21:27 +02:00
parent b13a636f89
commit c95f75bc6c
10 changed files with 5 additions and 63 deletions

View File

@@ -4,7 +4,6 @@ namespace BTCPayServer.Client.Models
{ {
public string ConnectionString { get; set; } public string ConnectionString { get; set; }
public bool DisableBOLT11PaymentOption { get; set; }
public LightningNetworkPaymentMethodBaseData() public LightningNetworkPaymentMethodBaseData()
{ {

View File

@@ -16,13 +16,12 @@ namespace BTCPayServer.Client.Models
{ {
} }
public LightningNetworkPaymentMethodData(string cryptoCode, string connectionString, bool enabled, string paymentMethod, bool disableBOLT11PaymentOption) public LightningNetworkPaymentMethodData(string cryptoCode, string connectionString, bool enabled, string paymentMethod)
{ {
Enabled = enabled; Enabled = enabled;
CryptoCode = cryptoCode; CryptoCode = cryptoCode;
ConnectionString = connectionString; ConnectionString = connectionString;
PaymentMethod = paymentMethod; PaymentMethod = paymentMethod;
DisableBOLT11PaymentOption = disableBOLT11PaymentOption;
} }
public string PaymentMethod { get; set; } public string PaymentMethod { get; set; }

View File

@@ -2146,14 +2146,8 @@ namespace BTCPayServer.Tests
// Ensure the toggles are set correctly // Ensure the toggles are set correctly
s.GoToLightningSettings(); s.GoToLightningSettings();
Assert.False(s.Driver.FindElement(By.Id("LNURLBech32Mode")).Selected); Assert.False(s.Driver.FindElement(By.Id("LNURLBech32Mode")).Selected);
//even though we set DisableBolt11PaymentMethod to true, logic when saving it turns it back off as otherwise no lightning option is available at all!
Assert.False(s.Driver.FindElement(By.Id("DisableBolt11PaymentMethod")).Selected);
// Invoice creation should fail, because it is a standard invoice with amount, but DisableBolt11PaymentMethod = true
s.CreateInvoice(storeId, 0.0000001m, cryptoCode, "", null, expectedSeverity: StatusMessageModel.StatusSeverity.Success);
i = s.CreateInvoice(storeId, null, cryptoCode); i = s.CreateInvoice(storeId, null, cryptoCode);
s.GoToInvoiceCheckout(i); s.GoToInvoiceCheckout(i);
s.Driver.FindElement(By.ClassName("payment__currencies_noborder")); s.Driver.FindElement(By.ClassName("payment__currencies_noborder"));
@@ -2168,14 +2162,13 @@ namespace BTCPayServer.Tests
s.AddLightningNode(LightningConnectionType.LndREST, false); s.AddLightningNode(LightningConnectionType.LndREST, false);
s.GoToLightningSettings(); s.GoToLightningSettings();
s.Driver.SetCheckbox(By.Id("LNURLEnabled"), true); s.Driver.SetCheckbox(By.Id("LNURLEnabled"), true);
s.Driver.SetCheckbox(By.Id("DisableBolt11PaymentMethod"), true);
s.Driver.FindElement(By.Id("save")).Click(); s.Driver.FindElement(By.Id("save")).Click();
Assert.Contains($"{cryptoCode} Lightning settings successfully updated", s.FindAlertMessage().Text); Assert.Contains($"{cryptoCode} Lightning settings successfully updated", s.FindAlertMessage().Text);
var invForPP = s.CreateInvoice(0.0000001m, cryptoCode); var invForPP = s.CreateInvoice(null, cryptoCode);
s.GoToInvoiceCheckout(invForPP); s.GoToInvoiceCheckout(invForPP);
s.Driver.FindElement(By.Id("copy-tab")).Click(); s.Driver.FindElement(By.Id("copy-tab")).Click();
lnurl = s.Driver.FindElement(By.CssSelector("input.checkoutTextbox")).GetAttribute("value"); lnurl = s.Driver.FindElement(By.CssSelector("input.checkoutTextbox")).GetAttribute("value");
parsed = LNURL.LNURL.Parse(lnurl, out tag); LNURL.LNURL.Parse(lnurl, out tag);
// Check that pull payment has lightning option // Check that pull payment has lightning option
s.GoToStore(s.StoreId, StoreNavPages.PullPayments); s.GoToStore(s.StoreId, StoreNavPages.PullPayments);

View File

@@ -66,8 +66,7 @@ namespace BTCPayServer.Controllers.Greenfield
paymentMethod.GetExternalLightningUrl()?.ToString() ?? paymentMethod.GetExternalLightningUrl()?.ToString() ??
paymentMethod.GetDisplayableConnectionString(), paymentMethod.GetDisplayableConnectionString(),
!excludedPaymentMethods.Match(paymentMethod.PaymentId), !excludedPaymentMethods.Match(paymentMethod.PaymentId),
paymentMethod.PaymentId.ToStringNormalized(), paymentMethod.PaymentId.ToStringNormalized()
paymentMethod.DisableBOLT11PaymentOption
) )
) )
.Where((result) => enabled is null || enabled == result.Enabled) .Where((result) => enabled is null || enabled == result.Enabled)
@@ -207,7 +206,7 @@ namespace BTCPayServer.Controllers.Greenfield
? null ? null
: new LightningNetworkPaymentMethodData(paymentMethod.PaymentId.CryptoCode, : new LightningNetworkPaymentMethodData(paymentMethod.PaymentId.CryptoCode,
paymentMethod.GetDisplayableConnectionString(), !excluded, paymentMethod.GetDisplayableConnectionString(), !excluded,
paymentMethod.PaymentId.ToStringNormalized(), paymentMethod.DisableBOLT11PaymentOption); paymentMethod.PaymentId.ToStringNormalized());
} }
private BTCPayNetwork AssertSupportLightning(string cryptoCode) private BTCPayNetwork AssertSupportLightning(string cryptoCode)

View File

@@ -244,25 +244,12 @@ namespace BTCPayServer.Controllers
}; };
SetExistingValues(store, vm); SetExistingValues(store, vm);
if (lightning != null)
{
vm.DisableBolt11PaymentMethod = lightning.DisableBOLT11PaymentOption;
}
var lnurl = GetExistingLNURLSupportedPaymentMethod(vm.CryptoCode, store); var lnurl = GetExistingLNURLSupportedPaymentMethod(vm.CryptoCode, store);
if (lnurl != null) if (lnurl != null)
{ {
vm.LNURLEnabled = !store.GetStoreBlob().GetExcludedPaymentMethods().Match(lnurl.PaymentId); vm.LNURLEnabled = !store.GetStoreBlob().GetExcludedPaymentMethods().Match(lnurl.PaymentId);
vm.LNURLBech32Mode = lnurl.UseBech32Scheme; vm.LNURLBech32Mode = lnurl.UseBech32Scheme;
vm.LUD12Enabled = lnurl.LUD12Enabled; vm.LUD12Enabled = lnurl.LUD12Enabled;
vm.DisableBolt11PaymentMethod =
vm.LNURLEnabled && vm.DisableBolt11PaymentMethod;
}
else
{
//disable by default for now
//vm.LNURLEnabled = !lnSet;
vm.DisableBolt11PaymentMethod = false;
} }
return View(vm); return View(vm);
@@ -288,18 +275,8 @@ namespace BTCPayServer.Controllers
blob.LightningAmountInSatoshi = vm.LightningAmountInSatoshi; blob.LightningAmountInSatoshi = vm.LightningAmountInSatoshi;
blob.LightningPrivateRouteHints = vm.LightningPrivateRouteHints; blob.LightningPrivateRouteHints = vm.LightningPrivateRouteHints;
blob.OnChainWithLnInvoiceFallback = vm.OnChainWithLnInvoiceFallback; blob.OnChainWithLnInvoiceFallback = vm.OnChainWithLnInvoiceFallback;
var disableBolt11PaymentMethod =
vm.LNURLEnabled && vm.DisableBolt11PaymentMethod;
var lnurlId = new PaymentMethodId(vm.CryptoCode, PaymentTypes.LNURLPay); var lnurlId = new PaymentMethodId(vm.CryptoCode, PaymentTypes.LNURLPay);
blob.SetExcluded(lnurlId, !vm.LNURLEnabled); blob.SetExcluded(lnurlId, !vm.LNURLEnabled);
var lightning = GetExistingLightningSupportedPaymentMethod(vm.CryptoCode, store);
// Going to mark "lightning" as non-null here assuming that if we are POSTing here it's because we have a Lightning Node set-up
if (lightning!.DisableBOLT11PaymentOption != disableBolt11PaymentMethod)
{
needUpdate = true;
lightning.DisableBOLT11PaymentOption = disableBolt11PaymentMethod;
store.SetSupportedPaymentMethod(lightning);
}
var lnurl = GetExistingLNURLSupportedPaymentMethod(vm.CryptoCode, store); var lnurl = GetExistingLNURLSupportedPaymentMethod(vm.CryptoCode, store);
if (lnurl is null || ( if (lnurl is null || (

View File

@@ -26,8 +26,5 @@ namespace BTCPayServer.Models.StoreViewModels
[Display(Name = "Allow payee to pass a comment")] [Display(Name = "Allow payee to pass a comment")]
public bool LUD12Enabled { get; set; } public bool LUD12Enabled { get; set; }
[Display(Name = "Do not offer BOLT11 for standard invoices")]
public bool DisableBolt11PaymentMethod { get; set; }
} }
} }

View File

@@ -53,10 +53,6 @@ namespace BTCPayServer.Payments.Lightning
LightningSupportedPaymentMethod supportedPaymentMethod, PaymentMethod paymentMethod, Data.StoreData store, LightningSupportedPaymentMethod supportedPaymentMethod, PaymentMethod paymentMethod, Data.StoreData store,
BTCPayNetwork network, object preparePaymentObject, IEnumerable<PaymentMethodId> invoicePaymentMethods) BTCPayNetwork network, object preparePaymentObject, IEnumerable<PaymentMethodId> invoicePaymentMethods)
{ {
if (supportedPaymentMethod.DisableBOLT11PaymentOption)
{
throw new PaymentMethodUnavailableException("BOLT11 payment method is disabled");
}
if (paymentMethod.ParentEntity.Type == InvoiceType.TopUp) if (paymentMethod.ParentEntity.Type == InvoiceType.TopUp)
{ {
throw new PaymentMethodUnavailableException("Lightning Network payment method is not available for top-up invoices"); throw new PaymentMethodUnavailableException("Lightning Network payment method is not available for top-up invoices");

View File

@@ -17,8 +17,6 @@ namespace BTCPayServer.Payments.Lightning
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
public string? LightningConnectionString { get; set; } public string? LightningConnectionString { get; set; }
public bool DisableBOLT11PaymentOption { get; set; } = false;
public LightningConnectionString? GetExternalLightningUrl() public LightningConnectionString? GetExternalLightningUrl()
{ {
#pragma warning disable CS0618 // Type or member is obsolete #pragma warning disable CS0618 // Type or member is obsolete

View File

@@ -98,17 +98,6 @@
</div> </div>
</label> </label>
</div> </div>
<div class="form-group">
<label class="form-group d-flex align-items-center">
<input type="checkbox" asp-for="DisableBolt11PaymentMethod" class="btcpay-toggle me-3" />
<div class="">
<label asp-for="DisableBolt11PaymentMethod" class="form-label mb-0 me-1"></label>
<div class="form-text">Performance: Turn it off if users should pay only via LNURL.</div>
</div>
</label>
</div>
<div class="form-group mb-3"> <div class="form-group mb-3">
<div class="d-flex align-items-center"> <div class="d-flex align-items-center">
<input type="checkbox" asp-for="LUD12Enabled" class="btcpay-toggle me-3" /> <input type="checkbox" asp-for="LUD12Enabled" class="btcpay-toggle me-3" />

View File

@@ -279,11 +279,6 @@
"type": "string", "type": "string",
"description": "The lightning connection string. Set to 'Internal Node' to use the internal node. (See [this doc](https://github.com/btcpayserver/BTCPayServer.Lightning/blob/master/README.md#examples) for some example)", "description": "The lightning connection string. Set to 'Internal Node' to use the internal node. (See [this doc](https://github.com/btcpayserver/BTCPayServer.Lightning/blob/master/README.md#examples) for some example)",
"example": "type=clightning;server=..." "example": "type=clightning;server=..."
},
"disableBOLT11PaymentOption": {
"type": "boolean",
"description": "Whether to disable generation of bolt11 invoices. Useful when wanting to only use LNURL Pay exclusively."
} }
} }
}, },