test: generalise byte_to_base58 utility function to allow more version types

Passing a version in the byte form is allowed now in addition to the integral
version type. This will be helpful in the next commit.
This commit is contained in:
rkrux
2026-06-16 18:36:14 +05:30
parent 6d5c1fb3ee
commit 4dbaa7cc65

View File

@@ -56,10 +56,12 @@ def create_deterministic_address_bcrt1_p2tr_op_true(explicit_internal_key=None):
def byte_to_base58(b, version):
result = ''
b = bytes([version]) + b # prepend version
if isinstance(version, int):
version = bytes([version])
b = version + b # prepend version
b += hash256(b)[:4] # append checksum
value = int.from_bytes(b, 'big')
result = ''
while value > 0:
result = b58chars[value % 58] + result
value //= 58