From 07ac2787710841a8c0cca0fd04b0e58b1aea4b57 Mon Sep 17 00:00:00 2001 From: Wilmer Paulino Date: Tue, 9 Jan 2018 07:08:21 -0500 Subject: [PATCH] invoice: properly parse the field data length When accessing a value from a byte slice, the value is returned as a byte, which is just a uint8. When the first byte takes more than 3 bits of space, shifting 5 bits left results in data loss. --- zpay32/invoice.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zpay32/invoice.go b/zpay32/invoice.go index e95d040a..00960fac 100644 --- a/zpay32/invoice.go +++ b/zpay32/invoice.go @@ -700,7 +700,7 @@ func parseFieldDataLength(data []byte) (uint16, error) { len(data)) } - return uint16(data[0]<<5) | uint16(data[1]), nil + return uint16(data[0])<<5 | uint16(data[1]), nil } // parsePaymentHash converts a 256-bit payment hash (encoded in base32)