From 9000ec49a2a17555a26db86bf6edadb9be3e570b Mon Sep 17 00:00:00 2001 From: Pierre Aoun Date: Wed, 25 Mar 2026 16:53:22 +0100 Subject: [PATCH] fix: handle bytearray length_value() --- src/erc7730/common/binary.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/erc7730/common/binary.py b/src/erc7730/common/binary.py index a570be0..1f106d4 100644 --- a/src/erc7730/common/binary.py +++ b/src/erc7730/common/binary.py @@ -31,7 +31,7 @@ def tlv(tag: int | IntEnum, value: bytes | str | None = None) -> bytes: def length_value( - value: bytes | str | None, + value: bytes | bytearray | str | None, ) -> bytes: """ Prepend the length (DER encoded) of the value encoded to the value itself. @@ -46,8 +46,8 @@ def length_value( if value is None: return (0).to_bytes(1, "big") match value: - case bytes(): - value_encoded = value + case bytes() | bytearray(): + value_encoded = bytes(value) case str(): value_encoded = value.encode("ascii", errors="strict") return der_encode_int(len(value_encoded)) + value_encoded