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

Function decode_base58

code-ch08/helper.py:50–59  ·  view source on GitHub ↗
(s)

Source from the content-addressed store, hash-verified

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

Callers 1

test_base58Method · 0.70

Calls 1

hash256Function · 0.70

Tested by 1

test_base58Method · 0.56