mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-22 22:25:28 +01:00
LNURL: Add missing logic from lnurl merges and rebases
This commit is contained in:
parent
fccbbb6fb7
commit
1ecd1c1e54
7 changed files with 23 additions and 6 deletions
|
@ -4,6 +4,7 @@
|
|||
{
|
||||
|
||||
public string ConnectionString { get; set; }
|
||||
public bool DisableBOLT11PaymentOption { get; set; }
|
||||
public LightningNetworkPaymentMethodBaseData()
|
||||
{
|
||||
|
||||
|
|
|
@ -16,12 +16,13 @@ namespace BTCPayServer.Client.Models
|
|||
{
|
||||
}
|
||||
|
||||
public LightningNetworkPaymentMethodData(string cryptoCode, string connectionString, bool enabled, string paymentMethod)
|
||||
public LightningNetworkPaymentMethodData(string cryptoCode, string connectionString, bool enabled, string paymentMethod, bool disableBOLT11PaymentOption)
|
||||
{
|
||||
Enabled = enabled;
|
||||
CryptoCode = cryptoCode;
|
||||
ConnectionString = connectionString;
|
||||
PaymentMethod = paymentMethod;
|
||||
DisableBOLT11PaymentOption = disableBOLT11PaymentOption;
|
||||
}
|
||||
|
||||
public string PaymentMethod { get; set; }
|
||||
|
|
|
@ -59,7 +59,8 @@ namespace BTCPayServer.Controllers.GreenField
|
|||
paymentMethod.GetExternalLightningUrl()?.ToString() ??
|
||||
paymentMethod.GetDisplayableConnectionString(),
|
||||
!excludedPaymentMethods.Match(paymentMethod.PaymentId),
|
||||
paymentMethod.PaymentId.ToStringNormalized()
|
||||
paymentMethod.PaymentId.ToStringNormalized(),
|
||||
paymentMethod.DisableBOLT11PaymentOption
|
||||
)
|
||||
)
|
||||
.Where((result) => enabled is null || enabled == result.Enabled)
|
||||
|
@ -206,7 +207,7 @@ namespace BTCPayServer.Controllers.GreenField
|
|||
? null
|
||||
: new LightningNetworkPaymentMethodData(paymentMethod.PaymentId.CryptoCode,
|
||||
paymentMethod.GetDisplayableConnectionString(), !excluded,
|
||||
paymentMethod.PaymentId.ToStringNormalized());
|
||||
paymentMethod.PaymentId.ToStringNormalized(), paymentMethod.DisableBOLT11PaymentOption);
|
||||
}
|
||||
|
||||
private bool GetNetwork(string cryptoCode, [MaybeNullWhen(false)] out BTCPayNetwork network)
|
||||
|
|
|
@ -60,7 +60,8 @@ namespace BTCPayServer.Controllers
|
|||
}
|
||||
paymentMethod = new LightningSupportedPaymentMethod
|
||||
{
|
||||
CryptoCode = paymentMethodId.CryptoCode
|
||||
CryptoCode = paymentMethodId.CryptoCode,
|
||||
DisableBOLT11PaymentOption = vm.LNURLEnabled && vm.LNURLStandardInvoiceEnabled && vm.DisableBolt11PaymentMethod
|
||||
};
|
||||
paymentMethod.SetInternalNode();
|
||||
}
|
||||
|
@ -89,7 +90,8 @@ namespace BTCPayServer.Controllers
|
|||
|
||||
paymentMethod = new LightningSupportedPaymentMethod
|
||||
{
|
||||
CryptoCode = paymentMethodId.CryptoCode
|
||||
CryptoCode = paymentMethodId.CryptoCode,
|
||||
DisableBOLT11PaymentOption = vm.LNURLEnabled && vm.LNURLStandardInvoiceEnabled && vm.DisableBolt11PaymentMethod
|
||||
};
|
||||
paymentMethod.SetLightningUrl(connectionString);
|
||||
|
||||
|
@ -184,6 +186,8 @@ namespace BTCPayServer.Controllers
|
|||
{
|
||||
vm.LightningNodeType = lightning.IsInternalNode ? LightningNodeType.Internal : LightningNodeType.Custom;
|
||||
vm.ConnectionString = lightning.GetDisplayableConnectionString();
|
||||
|
||||
vm.DisableBolt11PaymentMethod = lightning.DisableBOLT11PaymentOption;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -55,6 +55,10 @@ namespace BTCPayServer.Payments.Lightning
|
|||
LightningSupportedPaymentMethod supportedPaymentMethod, PaymentMethod paymentMethod, Data.StoreData store,
|
||||
BTCPayNetwork network, object preparePaymentObject)
|
||||
{
|
||||
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");
|
||||
}
|
||||
|
@ -66,7 +70,6 @@ namespace BTCPayServer.Payments.Lightning
|
|||
Activated = false
|
||||
};
|
||||
}
|
||||
//direct casting to (BTCPayNetwork) is fixed in other pull requests with better generic interfacing for handlers
|
||||
var storeBlob = store.GetStoreBlob();
|
||||
var nodeInfo = GetNodeInfo(supportedPaymentMethod, network, logs, paymentMethod.PreferOnion);
|
||||
|
||||
|
|
|
@ -17,6 +17,8 @@ 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
|
||||
|
|
|
@ -255,6 +255,11 @@
|
|||
"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