Skip to content

Commit

Permalink
avoid panic when jsonMap["paid"] is not bool
Browse files Browse the repository at this point in the history
  • Loading branch information
believethehype committed Jul 8, 2024
1 parent 4c06b96 commit 674e084
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions waitforinvoice.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,17 +156,24 @@ func WaitForInvoicePaid(payvalues LNURLPayValuesCustom, params *Params) {
return
}

if jsonMap["paid"].(bool) {
r, ok := jsonMap["paid"]
if !ok {
fmt.Print("Can't read paid tag")
return
// returnValues not present in Params map. Handle the scenario
// and don't continue below
}
if r.(bool) {

payvalues.PaidAt = time.Now()
fmt.Print("LnBits says paid..\n")
fmt.Print("Payment hash:" + bolt11.PaymentHash + "\n")
fmt.Println(string(responseData))
payvalues.Paid = true

} else {
fmt.Print("Checking invoice..\n")
}
// else {
//fmt.Print("Checking invoice..\n")
//}

case LNPayParams:
//TODO
Expand Down

0 comments on commit 674e084

Please sign in to comment.