Bitcoin
Wallet – Why doesn’t my Bitcoin testnet address work in the testnet faucet?
I created a Bitcoin testnet address, but the address is displayed incorrectly. I made it this way
passphrase = b'blah'
secret = little_endian_to_int(hash256(passphrase))
print(PrivateKey(secret).point.address(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.point = secret * G
def address(self, compressed=True, testnet=False):
'''Returns the address 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 generated address is as follows: n1tS4gT4ksDvRUgQwpPDFR56GjbVrYb2Tw
It should start with n, but it still shows the wrong address.