Prevent null invoice to be added to InvoiceWatcher

This commit is contained in:
nicolas.dorier 2017-10-13 14:53:42 +09:00
parent 9806cab090
commit 62e3f2d8e1

View file

@ -46,7 +46,8 @@ namespace BTCPayServer.Servcices.Invoices
public async Task NotifyReceived(Script scriptPubKey) public async Task NotifyReceived(Script scriptPubKey)
{ {
var invoice = await _Wallet.GetInvoiceId(scriptPubKey); var invoice = await _Wallet.GetInvoiceId(scriptPubKey);
_WatchRequests.Add(invoice); if(invoice != null)
_WatchRequests.Add(invoice);
} }
public async Task NotifyBlock() public async Task NotifyBlock()
@ -240,6 +241,8 @@ namespace BTCPayServer.Servcices.Invoices
public async Task WatchAsync(string invoiceId, bool singleShot = false) public async Task WatchAsync(string invoiceId, bool singleShot = false)
{ {
if(invoiceId == null)
throw new ArgumentNullException(nameof(invoiceId));
if(!singleShot) if(!singleShot)
await _InvoiceRepository.AddPendingInvoice(invoiceId).ConfigureAwait(false); await _InvoiceRepository.AddPendingInvoice(invoiceId).ConfigureAwait(false);
_WatchRequests.Add(invoiceId); _WatchRequests.Add(invoiceId);