We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
byte_to_base58
1 parent 473ee8e commit 51e1170Copy full SHA for 51e1170
test/functional/test_framework/address.py
@@ -25,17 +25,15 @@
25
26
def byte_to_base58(b, version):
27
result = ''
28
- str = b.hex()
29
- str = chr(version).encode('latin-1').hex() + str
30
- checksum = hash256(bytes.fromhex(str)).hex()
31
- str += checksum[:8]
32
- value = int('0x' + str, 0)
+ b = bytes([version]) + b # prepend version
+ b += hash256(b)[:4] # append checksum
+ value = int.from_bytes(b, 'big')
33
while value > 0:
34
result = chars[value % 58] + result
35
value //= 58
36
- while (str[:2] == '00'):
+ while b[0] == 0:
37
result = chars[0] + result
38
- str = str[2:]
+ b = b[1:]
39
return result
40
41
0 commit comments