MCPcopy Index your code
hub / github.com/jimmysong/programmingbitcoin / decode_base58

Function decode_base58

code-ch13/helper.py:56–65  ·  view source on GitHub ↗
(s)

Source from the content-addressed store, hash-verified

54
55
56def decode_base58(s):
57 num = 0
58 for c in s:
59 num *= 58
60 num += BASE58_ALPHABET.index(c)
61 combined = num.to_bytes(25, byteorder='big')
62 checksum = combined[-4:]
63 if hash256(combined[:-4])[:4] != checksum:
64 raise ValueError('bad address: {} {}'.format(checksum, hash256(combined[:-4])[:4]))
65 return combined[1:-4]
66
67
68def little_endian_to_int(b):

Callers 2

test_addressMethod · 0.90
test_base58Method · 0.70

Calls 1

hash256Function · 0.70

Tested by 2

test_addressMethod · 0.72
test_base58Method · 0.56