[ad_1]
I’ve created a bitcoin testnet tackle nevertheless it exhibits invalid tackle.
I’ve created it utilizing this fashion
passphrase = b'blah'
secret = little_endian_to_int(hash256(passphrase))
print(PrivateKey(secret).level.tackle(testnet=True))
def little_endian_to_int(b):
ans = int.from_bytes(b, 'little')
return ans
def hash256(s):
'''two rounds of sha256'''
return hashlib.sha256(hashlib.sha256(s).digest()).digest()
G = S256Point(
0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798,
0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8)
class PrivateKey:
def __init__(self, secret):
self.secret = secret
self.level = secret * G
def tackle(self, compressed=True, testnet=False):
'''Returns the tackle string'''
h160 = self.hash160(compressed)
if testnet:
prefix = b'x6f'
else:
prefix = b'x00'
return encode_base58_checksum(prefix + h160)
def hash160(self, compressed=True):
return hash160(self.sec(compressed))
My tackle generated was n1tS4gT4ksDvRUgQwpPDFR56GjbVrYb2Tw
It even begins with n, which it ought to, however nonetheless it exhibits invalid tackle.
[ad_2]
Supply hyperlink
Leave a Reply