From 2b4d7101c4202809d1c6e41cebfccc7b73111187 Mon Sep 17 00:00:00 2001 From: "Dr. Tobias Baur" Date: Thu, 2 Mar 2023 15:51:44 +0100 Subject: [PATCH] Update waitforinvoice.go --- waitforinvoice.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/waitforinvoice.go b/waitforinvoice.go index 77e0a51..783f5c7 100644 --- a/waitforinvoice.go +++ b/waitforinvoice.go @@ -242,11 +242,6 @@ func WaitForInvoicePaid(payvalues LNURLPayValuesCustom, params *Params) { //TODO } - //Timeout waiting for payment after maxiterations - if maxiterations == 0 { - log.Debug().Str("NIP57", bolt11.PaymentHash).Msg("Timed out") - close(quit) - } //If invoice is paid and DescriptionHash matches Nip57 DescriptionHash, publish Zap Nostr Event. This is rather a sanity check. if isPaid { @@ -257,9 +252,16 @@ func WaitForInvoicePaid(payvalues LNURLPayValuesCustom, params *Params) { close(quit) return } - - maxiterations-- } + + //Timeout waiting for payment after maxiterations + if maxiterations == 0 { + log.Debug().Str("NIP57", bolt11.PaymentHash).Msg("Timed out") + close(quit) + return + } + maxiterations-- + case <-quit: ticker.Stop() return