Skip to content

Commit

Permalink
nip19: fix decoding faulty kind from tlv.
Browse files Browse the repository at this point in the history
  • Loading branch information
fiatjaf committed Sep 5, 2024
1 parent 51e5276 commit cd145f4
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion nip19/nip19.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,11 @@ func Decode(bech32string string) (prefix string, value any, err error) {
}
result.Author = hex.EncodeToString(v)
case TLVKind:
result.Kind = int(binary.BigEndian.Uint32(v))
if len(v) == 4 {
result.Kind = int(binary.BigEndian.Uint32(v))
} else {
return prefix, nil, fmt.Errorf("invalid uint32 value for integer (%v)", v)
}
default:
// ignore
}
Expand Down

0 comments on commit cd145f4

Please sign in to comment.