mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-21 14:04:12 +01:00
Move bitcoin payment data specific stuff in NBXplorerListener (#5294)
This commit is contained in:
parent
7873f94848
commit
616883648f
2 changed files with 11 additions and 10 deletions
|
@ -5,6 +5,8 @@ using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using BTCPayServer;
|
using BTCPayServer;
|
||||||
|
using BTCPayServer.Client.Models;
|
||||||
|
using BTCPayServer.Data;
|
||||||
using BTCPayServer.Events;
|
using BTCPayServer.Events;
|
||||||
using BTCPayServer.HostedServices;
|
using BTCPayServer.HostedServices;
|
||||||
using BTCPayServer.Logging;
|
using BTCPayServer.Logging;
|
||||||
|
@ -414,6 +416,15 @@ namespace BTCPayServer.Payments.Bitcoin
|
||||||
if (invoice == null)
|
if (invoice == null)
|
||||||
return null;
|
return null;
|
||||||
var paymentMethod = invoice.GetPaymentMethod(wallet.Network, PaymentTypes.BTCLike);
|
var paymentMethod = invoice.GetPaymentMethod(wallet.Network, PaymentTypes.BTCLike);
|
||||||
|
var bitcoinPaymentMethod = (Payments.Bitcoin.BitcoinLikeOnChainPaymentMethod)paymentMethod.GetPaymentMethodDetails();
|
||||||
|
if (bitcoinPaymentMethod.NetworkFeeMode == NetworkFeeMode.MultiplePaymentsOnly &&
|
||||||
|
bitcoinPaymentMethod.NextNetworkFee == Money.Zero)
|
||||||
|
{
|
||||||
|
bitcoinPaymentMethod.NextNetworkFee = bitcoinPaymentMethod.NetworkFeeRate.GetFee(100); // assume price for 100 bytes
|
||||||
|
paymentMethod.SetPaymentMethodDetails(bitcoinPaymentMethod);
|
||||||
|
await this._InvoiceRepository.UpdateInvoicePaymentMethod(invoice.Id, paymentMethod);
|
||||||
|
invoice = await _InvoiceRepository.GetInvoice(invoice.Id);
|
||||||
|
}
|
||||||
wallet.InvalidateCache(strategy);
|
wallet.InvalidateCache(strategy);
|
||||||
_Aggregator.Publish(new InvoiceEvent(invoice, InvoiceEvent.ReceivedPayment) { Payment = payment });
|
_Aggregator.Publish(new InvoiceEvent(invoice, InvoiceEvent.ReceivedPayment) { Payment = payment });
|
||||||
return invoice;
|
return invoice;
|
||||||
|
|
|
@ -59,16 +59,6 @@ namespace BTCPayServer.Services.Invoices
|
||||||
Network = network
|
Network = network
|
||||||
};
|
};
|
||||||
entity.SetCryptoPaymentData(paymentData);
|
entity.SetCryptoPaymentData(paymentData);
|
||||||
//TODO: abstract
|
|
||||||
if (paymentMethodDetails is Payments.Bitcoin.BitcoinLikeOnChainPaymentMethod bitcoinPaymentMethod &&
|
|
||||||
bitcoinPaymentMethod.NetworkFeeMode == NetworkFeeMode.MultiplePaymentsOnly &&
|
|
||||||
bitcoinPaymentMethod.NextNetworkFee == Money.Zero)
|
|
||||||
{
|
|
||||||
bitcoinPaymentMethod.NextNetworkFee = bitcoinPaymentMethod.NetworkFeeRate.GetFee(100); // assume price for 100 bytes
|
|
||||||
paymentMethod.SetPaymentMethodDetails(bitcoinPaymentMethod);
|
|
||||||
invoiceEntity.SetPaymentMethod(paymentMethod);
|
|
||||||
invoice.SetBlob(invoiceEntity);
|
|
||||||
}
|
|
||||||
PaymentData data = new PaymentData
|
PaymentData data = new PaymentData
|
||||||
{
|
{
|
||||||
Id = paymentData.GetPaymentId(),
|
Id = paymentData.GetPaymentId(),
|
||||||
|
|
Loading…
Add table
Reference in a new issue