invoice: avoid negative msat amounts

This commit is contained in:
Wilmer Paulino committed 2018-01-23 14:38:20 -05:00
1 parent dd08662c87
commit cfb19b8d51
3 files changed
+17

No files matched your search

+5
View File
@@ -514,6 +514,11 @@ func validateInvoice(invoice *Invoice) error {
return fmt.Errorf("net params not set")
}
// Ensure that if there is an amount set, it is not negative.
if invoice.MilliSat != nil && *invoice.MilliSat < 0 {
return fmt.Errorf("negative amount: %v", *invoice.MilliSat)
}
// The invoice must contain a payment hash.
if invoice.PaymentHash == nil {
return fmt.Errorf("no payment hash found")