mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-20 13:34:37 +01:00
Remove disable BOLT11 option
This commit is contained in:
parent
b13a636f89
commit
c95f75bc6c
10 changed files with 5 additions and 63 deletions
|
@ -4,7 +4,6 @@ namespace BTCPayServer.Client.Models
|
|||
{
|
||||
|
||||
public string ConnectionString { get; set; }
|
||||
public bool DisableBOLT11PaymentOption { get; set; }
|
||||
public LightningNetworkPaymentMethodBaseData()
|
||||
{
|
||||
|
||||
|
|
|
@ -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;
|
||||
CryptoCode = cryptoCode;
|
||||
ConnectionString = connectionString;
|
||||
PaymentMethod = paymentMethod;
|
||||
DisableBOLT11PaymentOption = disableBOLT11PaymentOption;
|
||||
}
|
||||
|
||||
public string PaymentMethod { get; set; }
|
||||
|
|
|
@ -2146,14 +2146,8 @@ namespace BTCPayServer.Tests
|
|||
|
||||
// Ensure the toggles are set correctly
|
||||
s.GoToLightningSettings();
|
||||
|
||||
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);
|
||||
s.GoToInvoiceCheckout(i);
|
||||
s.Driver.FindElement(By.ClassName("payment__currencies_noborder"));
|
||||
|
@ -2168,14 +2162,13 @@ namespace BTCPayServer.Tests
|
|||
s.AddLightningNode(LightningConnectionType.LndREST, false);
|
||||
s.GoToLightningSettings();
|
||||
s.Driver.SetCheckbox(By.Id("LNURLEnabled"), true);
|
||||
s.Driver.SetCheckbox(By.Id("DisableBolt11PaymentMethod"), true);
|
||||
s.Driver.FindElement(By.Id("save")).Click();
|
||||
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.Driver.FindElement(By.Id("copy-tab")).Click();
|
||||
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
|
||||
s.GoToStore(s.StoreId, StoreNavPages.PullPayments);
|
||||
|
|
|
@ -66,8 +66,7 @@ namespace BTCPayServer.Controllers.Greenfield
|
|||
paymentMethod.GetExternalLightningUrl()?.ToString() ??
|
||||
paymentMethod.GetDisplayableConnectionString(),
|
||||
!excludedPaymentMethods.Match(paymentMethod.PaymentId),
|
||||
paymentMethod.PaymentId.ToStringNormalized(),
|
||||
paymentMethod.DisableBOLT11PaymentOption
|
||||
paymentMethod.PaymentId.ToStringNormalized()
|
||||
)
|
||||
)
|
||||
.Where((result) => enabled is null || enabled == result.Enabled)
|
||||
|
@ -207,7 +206,7 @@ namespace BTCPayServer.Controllers.Greenfield
|
|||
? null
|
||||
: new LightningNetworkPaymentMethodData(paymentMethod.PaymentId.CryptoCode,
|
||||
paymentMethod.GetDisplayableConnectionString(), !excluded,
|
||||
paymentMethod.PaymentId.ToStringNormalized(), paymentMethod.DisableBOLT11PaymentOption);
|
||||
paymentMethod.PaymentId.ToStringNormalized());
|
||||
}
|
||||
|
||||
private BTCPayNetwork AssertSupportLightning(string cryptoCode)
|
||||
|
|
|
@ -244,25 +244,12 @@ namespace BTCPayServer.Controllers
|
|||
};
|
||||
SetExistingValues(store, vm);
|
||||
|
||||
if (lightning != null)
|
||||
{
|
||||
vm.DisableBolt11PaymentMethod = lightning.DisableBOLT11PaymentOption;
|
||||
}
|
||||
|
||||
var lnurl = GetExistingLNURLSupportedPaymentMethod(vm.CryptoCode, store);
|
||||
if (lnurl != null)
|
||||
{
|
||||
vm.LNURLEnabled = !store.GetStoreBlob().GetExcludedPaymentMethods().Match(lnurl.PaymentId);
|
||||
vm.LNURLBech32Mode = lnurl.UseBech32Scheme;
|
||||
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);
|
||||
|
@ -288,18 +275,8 @@ namespace BTCPayServer.Controllers
|
|||
blob.LightningAmountInSatoshi = vm.LightningAmountInSatoshi;
|
||||
blob.LightningPrivateRouteHints = vm.LightningPrivateRouteHints;
|
||||
blob.OnChainWithLnInvoiceFallback = vm.OnChainWithLnInvoiceFallback;
|
||||
var disableBolt11PaymentMethod =
|
||||
vm.LNURLEnabled && vm.DisableBolt11PaymentMethod;
|
||||
var lnurlId = new PaymentMethodId(vm.CryptoCode, PaymentTypes.LNURLPay);
|
||||
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);
|
||||
if (lnurl is null || (
|
||||
|
|
|
@ -26,8 +26,5 @@ namespace BTCPayServer.Models.StoreViewModels
|
|||
|
||||
[Display(Name = "Allow payee to pass a comment")]
|
||||
public bool LUD12Enabled { get; set; }
|
||||
|
||||
[Display(Name = "Do not offer BOLT11 for standard invoices")]
|
||||
public bool DisableBolt11PaymentMethod { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,10 +53,6 @@ namespace BTCPayServer.Payments.Lightning
|
|||
LightningSupportedPaymentMethod supportedPaymentMethod, PaymentMethod paymentMethod, Data.StoreData store,
|
||||
BTCPayNetwork network, object preparePaymentObject, IEnumerable<PaymentMethodId> invoicePaymentMethods)
|
||||
{
|
||||
if (supportedPaymentMethod.DisableBOLT11PaymentOption)
|
||||
{
|
||||
throw new PaymentMethodUnavailableException("BOLT11 payment method is disabled");
|
||||
}
|
||||
if (paymentMethod.ParentEntity.Type == InvoiceType.TopUp)
|
||||
{
|
||||
throw new PaymentMethodUnavailableException("Lightning Network payment method is not available for top-up invoices");
|
||||
|
|
|
@ -17,8 +17,6 @@ namespace BTCPayServer.Payments.Lightning
|
|||
[JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
public string? LightningConnectionString { get; set; }
|
||||
|
||||
public bool DisableBOLT11PaymentOption { get; set; } = false;
|
||||
|
||||
public LightningConnectionString? GetExternalLightningUrl()
|
||||
{
|
||||
#pragma warning disable CS0618 // Type or member is obsolete
|
||||
|
|
|
@ -98,17 +98,6 @@
|
|||
</div>
|
||||
</label>
|
||||
</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="d-flex align-items-center">
|
||||
<input type="checkbox" asp-for="LUD12Enabled" class="btcpay-toggle me-3" />
|
||||
|
|
|
@ -279,11 +279,6 @@
|
|||
"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)",
|
||||
"example": "type=clightning;server=..."
|
||||
},
|
||||
"disableBOLT11PaymentOption": {
|
||||
|
||||
"type": "boolean",
|
||||
"description": "Whether to disable generation of bolt11 invoices. Useful when wanting to only use LNURL Pay exclusively."
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
Loading…
Add table
Reference in a new issue