From 00d530bd9160b2406a2c69e30a37f844b8d59bc1 Mon Sep 17 00:00:00 2001 From: Wilmer Paulino Date: Tue, 9 Jan 2018 00:59:06 -0500 Subject: [PATCH] invoice: remove duplicate code when parsing the timestamp --- zpay32/invoice.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/zpay32/invoice.go b/zpay32/invoice.go index c27ded22..aa01f73a 100644 --- a/zpay32/invoice.go +++ b/zpay32/invoice.go @@ -557,8 +557,7 @@ func parseData(invoice *Invoice, data []byte, net *chaincfg.Params) error { return fmt.Errorf("data too short: %d", len(data)) } - // Timestamp: 35 bits, 7 groups. - t, err := base32ToUint64(data[:7]) + t, err := parseTimestamp(data[:timestampBase32Len]) if err != nil { return err } @@ -575,7 +574,7 @@ func parseData(invoice *Invoice, data []byte, net *chaincfg.Params) error { // parseTimestamp converts a 35-bit timestamp (encoded in base32) to uint64. func parseTimestamp(data []byte) (uint64, error) { - if len(data) != 7 { + if len(data) != timestampBase32Len { return 0, fmt.Errorf("timestamp must be 35 bits, was %d", len(data)*5) }