mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-01-18 21:32:27 +01:00
Prevent an NRE in LNURL (#4908)
* Prevent an NRE in LNURL In addition tof05a7f9f14
. Fixes #4904. * Revert "Prevent an NRE in LNURL" This reverts commit0b241d61ab
. * Fix NRE --------- Co-authored-by: nicolas.dorier <nicolas.dorier@gmail.com>
This commit is contained in:
parent
cb3c5e56fd
commit
47f5d97eaf
@ -468,6 +468,8 @@ namespace BTCPayServer
|
||||
lnUrlMetadata ??= new Dictionary<string, string>();
|
||||
|
||||
var pm = i.GetPaymentMethod(pmi);
|
||||
if (pm is null)
|
||||
return null;
|
||||
var paymentMethodDetails = (LNURLPayPaymentMethodDetails)pm.GetPaymentMethodDetails();
|
||||
bool updatePaymentMethodDetails = false;
|
||||
if (lnUrlMetadata?.TryGetValue("text/identifier", out var lnAddress) is true && lnAddress is not null)
|
||||
@ -494,7 +496,7 @@ namespace BTCPayServer
|
||||
lnurlRequest.Metadata = JsonConvert.SerializeObject(lnUrlMetadata.Select(kv => new[] { kv.Key, kv.Value }));
|
||||
if (i.Type != InvoiceType.TopUp)
|
||||
{
|
||||
lnurlRequest.MinSendable = new LightMoney(i.GetPaymentMethod(pmi).Calculate().Due.ToDecimal(MoneyUnit.Satoshi), LightMoneyUnit.Satoshi);
|
||||
lnurlRequest.MinSendable = new LightMoney(pm.Calculate().Due.ToDecimal(MoneyUnit.Satoshi), LightMoneyUnit.Satoshi);
|
||||
if (!allowOverpay)
|
||||
lnurlRequest.MaxSendable = lnurlRequest.MinSendable;
|
||||
}
|
||||
|
@ -90,11 +90,6 @@ namespace BTCPayServer.Payments
|
||||
};
|
||||
}
|
||||
|
||||
public PaymentMethod GetPaymentMethodInInvoice(InvoiceEntity invoice, PaymentMethodId paymentMethodId)
|
||||
{
|
||||
return invoice.GetPaymentMethod(paymentMethodId);
|
||||
}
|
||||
|
||||
public virtual object PreparePayment(TSupportedPaymentMethod supportedPaymentMethod, StoreData store,
|
||||
BTCPayNetworkBase network)
|
||||
{
|
||||
|
@ -299,9 +299,8 @@ namespace BTCPayServer.Payments.PayJoin
|
||||
if (walletReceiveMatch is null && invoice is not null)
|
||||
{
|
||||
var paymentMethod = invoice.GetPaymentMethod(paymentMethodId);
|
||||
var paymentDetails =
|
||||
paymentMethod.GetPaymentMethodDetails() as Payments.Bitcoin.BitcoinLikeOnChainPaymentMethod;
|
||||
if (paymentDetails is null || !paymentDetails.PayjoinEnabled)
|
||||
var paymentDetails = paymentMethod?.GetPaymentMethodDetails() as Payments.Bitcoin.BitcoinLikeOnChainPaymentMethod;
|
||||
if (paymentMethod is null || paymentDetails is null || !paymentDetails.PayjoinEnabled)
|
||||
continue;
|
||||
due = paymentMethod.Calculate().TotalDue - output.Value;
|
||||
if (due > Money.Zero)
|
||||
|
@ -44,6 +44,8 @@ namespace BTCPayServer.Services.Invoices
|
||||
return null;
|
||||
InvoiceEntity invoiceEntity = invoice.GetBlob(_btcPayNetworkProvider);
|
||||
PaymentMethod paymentMethod = invoiceEntity.GetPaymentMethod(new PaymentMethodId(network.CryptoCode, paymentData.GetPaymentType()));
|
||||
if (paymentMethod is null)
|
||||
return null;
|
||||
IPaymentMethodDetails paymentMethodDetails = paymentMethod.GetPaymentMethodDetails();
|
||||
PaymentEntity entity = new PaymentEntity
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user