mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-20 13:34:37 +01:00
Do not put payRequest in the metadata (#4870)
This commit is contained in:
parent
1aaccb1e6b
commit
48ebaf5c5a
2 changed files with 16 additions and 17 deletions
|
@ -467,13 +467,13 @@ namespace BTCPayServer
|
|||
lnurlRequest ??= new LNURLPayRequest();
|
||||
lnUrlMetadata ??= new Dictionary<string, string>();
|
||||
|
||||
var pm = i.GetPaymentMethod(pmi);
|
||||
var paymentMethodDetails = (LNURLPayPaymentMethodDetails)pm.GetPaymentMethodDetails();
|
||||
bool updatePaymentMethodDetails = false;
|
||||
if (lnUrlMetadata?.TryGetValue("text/identifier", out var lnAddress) is true && lnAddress is not null)
|
||||
{
|
||||
var pm = i.GetPaymentMethod(pmi);
|
||||
var paymentMethodDetails = (LNURLPayPaymentMethodDetails)pm.GetPaymentMethodDetails();
|
||||
paymentMethodDetails.ConsumedLightningAddress = lnAddress;
|
||||
pm.SetPaymentMethodDetails(paymentMethodDetails);
|
||||
await _invoiceRepository.UpdateInvoicePaymentMethod(i.Id, pm);
|
||||
updatePaymentMethodDetails = true;
|
||||
}
|
||||
|
||||
if (!lnUrlMetadata.ContainsKey("text/plain"))
|
||||
|
@ -507,15 +507,16 @@ namespace BTCPayServer
|
|||
lnurlRequest.MaxSendable = LightMoney.FromUnit(6.12m, LightMoneyUnit.BTC);
|
||||
|
||||
lnurlRequest = await _pluginHookService.ApplyFilter("modify-lnurlp-request", lnurlRequest) as LNURLPayRequest;
|
||||
|
||||
i.Metadata ??= new InvoiceMetadata();
|
||||
var metadata = i.Metadata.ToJObject();
|
||||
if (metadata.Property("payRequest") is null)
|
||||
if (paymentMethodDetails.PayRequest is null)
|
||||
{
|
||||
metadata.Add("payRequest", JToken.FromObject(lnurlRequest));
|
||||
await _invoiceRepository.UpdateInvoiceMetadata(i.Id, i.StoreId, metadata);
|
||||
paymentMethodDetails.PayRequest = lnurlRequest;
|
||||
updatePaymentMethodDetails = true;
|
||||
}
|
||||
if (updatePaymentMethodDetails)
|
||||
{
|
||||
pm.SetPaymentMethodDetails(paymentMethodDetails);
|
||||
await _invoiceRepository.UpdateInvoicePaymentMethod(i.Id, pm);
|
||||
}
|
||||
|
||||
return lnurlRequest;
|
||||
}
|
||||
|
||||
|
@ -572,13 +573,9 @@ namespace BTCPayServer
|
|||
if (paymentMethodDetails?.LightningSupportedPaymentMethod is null)
|
||||
return NotFound();
|
||||
|
||||
LNURLPayRequest lnurlPayRequest;
|
||||
LNURLPayRequest lnurlPayRequest = paymentMethodDetails.PayRequest;
|
||||
var blob = store.GetStoreBlob();
|
||||
if (i.Metadata.AdditionalData.TryGetValue("payRequest", out var t) && t is JObject jo)
|
||||
{
|
||||
lnurlPayRequest = jo.ToObject<LNURLPayRequest>();
|
||||
}
|
||||
else
|
||||
if (paymentMethodDetails.PayRequest is null)
|
||||
{
|
||||
lnurlPayRequest = await CreateLNUrlRequestFromInvoice(cryptoCode, i, store, blob, allowOverpay: false);
|
||||
if (lnurlPayRequest is null)
|
||||
|
|
|
@ -3,6 +3,7 @@ using BTCPayServer.Client.JsonConverters;
|
|||
using BTCPayServer.Lightning;
|
||||
using BTCPayServer.Payments.Lightning;
|
||||
using BTCPayServer.Services.Invoices;
|
||||
using LNURL;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
|
@ -18,6 +19,7 @@ namespace BTCPayServer.Payments
|
|||
|
||||
public string ProvidedComment { get; set; }
|
||||
public string ConsumedLightningAddress { get; set; }
|
||||
public LNURLPayRequest PayRequest { get; set; }
|
||||
|
||||
public override PaymentType GetPaymentType()
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue