diff --git a/zpay32/invoice.go b/zpay32/invoice.go index d36b31ca..9a9fde33 100644 --- a/zpay32/invoice.go +++ b/zpay32/invoice.go @@ -86,6 +86,10 @@ var ( // ErrInvoiceTooLarge is returned when an invoice exceeds maxInvoiceLength. ErrInvoiceTooLarge = errors.New("invoice is too large") + + // ErrInvalidFieldLength is returned when a tagged field was specified + // with a length larger than the left over bytes of the data field. + ErrInvalidFieldLength = errors.New("invalid field length") ) // MessageSigner is passed to the Encode method to provide a signature @@ -617,7 +621,7 @@ func parseTaggedFields(invoice *Invoice, fields []byte, net *chaincfg.Params) er // If we don't have enough field data left to read this length, // return error. if len(fields) < index+3+int(dataLength) { - return fmt.Errorf("invalid field length") + return ErrInvalidFieldLength } base32Data := fields[index+3 : index+3+int(dataLength)]