mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2025-02-22 22:25:28 +01:00
Make sure FindPaymentViaPolling does not requests over and over the same coins
This commit is contained in:
parent
4a1fb71e09
commit
08beffb005
1 changed files with 9 additions and 2 deletions
|
@ -320,6 +320,8 @@ namespace BTCPayServer.Payments.Bitcoin
|
|||
{
|
||||
int totalPayment = 0;
|
||||
var invoices = await _InvoiceRepository.GetPendingInvoices();
|
||||
var coinsPerDerivationStrategy =
|
||||
new Dictionary<DerivationStrategyBase, ReceivedCoin[]>();
|
||||
foreach (var invoiceId in invoices)
|
||||
{
|
||||
var invoice = await _InvoiceRepository.GetInvoice(invoiceId, true);
|
||||
|
@ -334,8 +336,13 @@ namespace BTCPayServer.Payments.Bitcoin
|
|||
|
||||
if (!invoice.Support(cryptoId))
|
||||
continue;
|
||||
var coins = (await wallet.GetUnspentCoins(strategy))
|
||||
.Where(c => invoice.AvailableAddressHashes.Contains(c.ScriptPubKey.Hash.ToString() + cryptoId))
|
||||
|
||||
if (!coinsPerDerivationStrategy.TryGetValue(strategy, out var coins))
|
||||
{
|
||||
coins = await wallet.GetUnspentCoins(strategy);
|
||||
coinsPerDerivationStrategy.Add(strategy, coins);
|
||||
}
|
||||
coins = coins.Where(c => invoice.AvailableAddressHashes.Contains(c.ScriptPubKey.Hash.ToString() + cryptoId))
|
||||
.ToArray();
|
||||
foreach (var coin in coins.Where(c => !alreadyAccounted.Contains(c.OutPoint)))
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue