mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2026-02-23 15:14:49 +01:00
Adding lightning invoice fallback to onchain bitcoin url if enabled
This commit is contained in:
@@ -62,6 +62,7 @@ namespace BTCPayServer.Data
|
||||
_DefaultCurrencyPairs = value;
|
||||
}
|
||||
}
|
||||
public bool OnChainWithLnInvoiceFallback { get; set; } = true;
|
||||
|
||||
public string GetDefaultCurrencyPairString()
|
||||
{
|
||||
@@ -189,6 +190,7 @@ namespace BTCPayServer.Data
|
||||
public bool PayJoinEnabled { get; set; }
|
||||
|
||||
public StoreHints Hints { get; set; }
|
||||
|
||||
public class StoreHints
|
||||
{
|
||||
public bool Wallet { get; set; }
|
||||
|
||||
@@ -46,8 +46,7 @@ namespace BTCPayServer.Payments.Bitcoin
|
||||
public Task<KeyPathInformation> ReserveAddress;
|
||||
}
|
||||
|
||||
public override void PreparePaymentModel(PaymentModel model, InvoiceResponse invoiceResponse,
|
||||
StoreBlob storeBlob)
|
||||
public override void PreparePaymentModel(PaymentModel model, InvoiceResponse invoiceResponse, StoreBlob storeBlob)
|
||||
{
|
||||
var paymentMethodId = new PaymentMethodId(model.CryptoCode, PaymentTypes.BTCLike);
|
||||
|
||||
@@ -55,8 +54,19 @@ namespace BTCPayServer.Payments.Bitcoin
|
||||
var network = _networkProvider.GetNetwork<BTCPayNetwork>(model.CryptoCode);
|
||||
model.IsLightning = false;
|
||||
model.PaymentMethodName = GetPaymentMethodName(network);
|
||||
model.InvoiceBitcoinUrl = cryptoInfo.PaymentUrls.BIP21;
|
||||
model.InvoiceBitcoinUrlQR = cryptoInfo.PaymentUrls.BIP21;
|
||||
|
||||
var invoiceBitcoinUrl = cryptoInfo.PaymentUrls.BIP21;
|
||||
|
||||
if (storeBlob.OnChainWithLnInvoiceFallback)
|
||||
{
|
||||
var lightningInfo = invoiceResponse.CryptoInfo.FirstOrDefault(a =>
|
||||
a.GetpaymentMethodId() == new PaymentMethodId(model.CryptoCode, PaymentTypes.LightningLike));
|
||||
if (!String.IsNullOrEmpty(lightningInfo?.PaymentUrls?.BOLT11))
|
||||
invoiceBitcoinUrl += "&" + lightningInfo.PaymentUrls.BOLT11.Replace("lightning:", "lightning=", StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
model.InvoiceBitcoinUrl = invoiceBitcoinUrl;
|
||||
model.InvoiceBitcoinUrlQR = invoiceBitcoinUrl;
|
||||
}
|
||||
|
||||
public override string GetCryptoImage(PaymentMethodId paymentMethodId)
|
||||
|
||||
Reference in New Issue
Block a user