package billing import ( "encoding/json" "io" ) // ParseWebhook reads the payment hash from an LNbits webhook body. LNbits // posts the whole payment object; only the hash is used, and only as a // pointer to the purchase that is then confirmed with LNbits itself. func ParseWebhook(body io.Reader) (paymentHash string, ok bool) { var doc struct { PaymentHash string `json:"payment_hash"` } if err := json.NewDecoder(io.LimitReader(body, 64*1024)).Decode(&doc); err != nil { return "", false } return doc.PaymentHash, doc.PaymentHash != "" }