def randpair(compressed=False): r_hex = ba.hexlify(get_random(32)) wif = bitcoin.hextowif(r_hex,compressed) addr = bitcoin.privnum2addr(int(r_hex,16),compressed) Vmsg("Key (hex): %s" % r_hex) Vmsg_r("Key (WIF): "); Msg(wif) Vmsg_r("Addr: "); Msg(addr)
if opt.system: sys.path.pop(0) from mmgen.addr import test_for_keyconv if not test_for_keyconv(silent=True): msg( "To run this test, you must install 'keyconv' from the vanitygen package.") sys.exit(1) msg(green("Comparing {}'s internally generated addresses against output of 'keyconv'").format(g.proj_name)) from subprocess import check_output for i in range(1,rounds+1): msg_r("\rRound %s/%s " % (i,rounds)) sec = hexlify(os.urandom(32)) wif = hextowif(sec) a = privnum2addr(int(sec,16)) vmsg("\nkey: %s\naddr: %s\n" % (wif,a)) b = check_output(["keyconv", wif]).split()[1] if a != b: msg_r(red("\nERROR: Addresses do not match!")) msg(""" sec key: {} WIF key: {} {pnm}: {} keyconv: {} """.format(sec,wif,a,b,pnm=g.proj_name).rstrip()) sys.exit(3) msg(green("%sOK" % ("" if opt.verbose else "\n")))
def hex2wif(hexpriv,compressed=False): Msg(bitcoin.hextowif(hexpriv,compressed))
def randwif(compressed=False): r_hex = ba.hexlify(get_random(32)) enc = bitcoin.hextowif(r_hex,compressed) dec = bitcoin.wiftohex(enc,compressed) print_convert_results(r_hex,enc,dec,"hex")