invoice: remove duplicate code when parsing the timestamp

This commit is contained in:
Wilmer Paulino 2018-01-09 00:59:06 -05:00
parent 6f5d673679
commit 00d530bd91
No known key found for this signature in database
GPG Key ID: 6DF57B9F9514972F

@ -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)
}