zpay32: Switch to ErrInvalidFieldLength sentinel
This switches the applicable error to use an exported sentinel error so that it is more testable.
This commit is contained in:
parent
cb2b8b4513
commit
85f9c03797
@ -86,6 +86,10 @@ var (
|
|||||||
|
|
||||||
// ErrInvoiceTooLarge is returned when an invoice exceeds maxInvoiceLength.
|
// ErrInvoiceTooLarge is returned when an invoice exceeds maxInvoiceLength.
|
||||||
ErrInvoiceTooLarge = errors.New("invoice is too large")
|
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
|
// 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,
|
// If we don't have enough field data left to read this length,
|
||||||
// return error.
|
// return error.
|
||||||
if len(fields) < index+3+int(dataLength) {
|
if len(fields) < index+3+int(dataLength) {
|
||||||
return fmt.Errorf("invalid field length")
|
return ErrInvalidFieldLength
|
||||||
}
|
}
|
||||||
base32Data := fields[index+3 : index+3+int(dataLength)]
|
base32Data := fields[index+3 : index+3+int(dataLength)]
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user