mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-17 22:14:26 +01:00
Fix crash if impossible to get the network of a payment
This commit is contained in:
@@ -144,6 +144,7 @@ namespace BTCPayServer.Controllers
|
||||
.Select(o => new PaymentMethodId(o, PaymentTypes.BTCLike))
|
||||
.ToList();
|
||||
var defaultRefund = invoice.Payments.Select(p => p.GetBlob(_NetworkProvider))
|
||||
.Where(p => p != null)
|
||||
.Select(p => p.GetPaymentMethodId().CryptoCode)
|
||||
.FirstOrDefault();
|
||||
// TODO: What if no option?
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace BTCPayServer.Data
|
||||
PaymentEntity paymentEntity = null;
|
||||
if (network == null)
|
||||
{
|
||||
paymentEntity = NBitcoin.JsonConverters.Serializer.ToObject<PaymentEntity>(unziped, null);
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -484,6 +484,8 @@ retry:
|
||||
entity.Payments = invoice.Payments.Select(p =>
|
||||
{
|
||||
var paymentEntity = p.GetBlob(_Networks);
|
||||
if (paymentEntity is null)
|
||||
return null;
|
||||
// PaymentEntity on version 0 does not have their own fee, because it was assumed that the payment method have fixed fee.
|
||||
// We want to hide this legacy detail in InvoiceRepository, so we fetch the fee from the PaymentMethod and assign it to the PaymentEntity.
|
||||
if (paymentEntity.Version == 0)
|
||||
@@ -497,6 +499,7 @@ retry:
|
||||
|
||||
return paymentEntity;
|
||||
})
|
||||
.Where(p => p != null)
|
||||
.OrderBy(a => a.ReceivedTime).ToList();
|
||||
#pragma warning restore CS0618
|
||||
var state = invoice.GetInvoiceState();
|
||||
|
||||
Reference in New Issue
Block a user