def init_generators(arg=None): global at, kg, ag at = MMGenAddrType((hasattr(opt, 'type') and opt.type) or g.proto.dfl_mmtype) if arg != 'at': kg = KeyGenerator(at) ag = AddrGenerator(at)
def __init__(self): m = "Unable to import moneropy. Is moneropy installed on your system?" try: import moneropy.account except: raise ImportError(m) self.mpa = moneropy.account proto = init_proto('xmr') global addr_type addr_type = MMGenAddrType(proto, 'M')
def init_external_prog(): global b, b_desc, ext_lib, ext_sec2addr, sp, eth, addr_type def test_support(k): if b == k: return True if b != 'ext' and b != k: return False if g.coin in ci.external_tests['mainnet'][k] and not g.testnet: return True if g.coin in ci.external_tests['testnet'][k]: return True return False if b == 'zcash_mini' or addr_type.name == 'zcash_z': import subprocess as sp from mmgen.protocol import init_coin ext_sec2addr = zcash_mini_sec2addr ext_lib = 'zcash_mini' init_coin('zec') addr_type = MMGenAddrType('Z') elif test_support('pyethereum'): try: import mmgen.altcoins.eth.pyethereum.utils as eth except: raise ImportError( "Unable to import 'ethereum' module. Is pyethereum installed?") ext_sec2addr = pyethereum_sec2addr ext_lib = 'pyethereum' elif test_support('pycoin'): try: global pcku, secp256k1_generator, network_for_netcode import pycoin.cmds.ku as pcku from pycoin.ecdsa.secp256k1 import secp256k1_generator from pycoin.networks.registry import network_for_netcode except: raise ImportError( "Unable to import pycoin modules. Is pycoin installed and up-to-date?" ) ext_sec2addr = pycoin_sec2addr ext_lib = 'pycoin' elif test_support('keyconv'): import subprocess as sp ext_sec2addr = keyconv_sec2addr ext_lib = 'keyconv' else: m = '{}: coin supported by MMGen but unsupported by gentest.py for {}' raise ValueError(m.format(g.coin, ('mainnet', 'testnet')[g.testnet])) b_desc = ext_lib b = 'ext'
def init_external_prog(): global b, b_desc, ext_lib, ext_sec2addr, sp, eth, pcku, PREFIX_TRANSFORMS, addr_type def test_support(k): if b == k: return True if b != 'ext' and b != k: return False if g.coin in ci.external_tests['mainnet'][k] and not g.testnet: return True if g.coin in ci.external_tests['testnet'][k]: return True return False if b == 'zcash_mini' or addr_type.name == 'zcash_z': import subprocess as sp from mmgen.protocol import init_coin ext_sec2addr = zcash_mini_sec2addr ext_lib = 'zcash_mini' init_coin('zec') addr_type = MMGenAddrType('Z') elif test_support('pyethereum'): try: import ethereum.utils as eth except: raise ImportError, "Unable to import 'pyethereum' module. Is pyethereum installed?" ext_sec2addr = pyethereum_sec2addr ext_lib = 'pyethereum' elif test_support('pycoin'): try: import pycoin.cmds.ku as pcku except: raise ImportError, "Unable to import module 'ku'. Is pycoin installed?" PREFIX_TRANSFORMS = pcku.prefix_transforms_for_network(g.coin) ext_sec2addr = pycoin_sec2addr ext_lib = 'pycoin' elif test_support('keyconv'): import subprocess as sp ext_sec2addr = keyconv_sec2addr ext_lib = 'keyconv' else: m = '{}: coin supported by MMGen but unsupported by gentest.py for {}' raise ValueError, m.format(g.coin, ('mainnet', 'testnet')[g.testnet]) b_desc = ext_lib b = 'ext'
def __init__(self): proto = init_proto('zec') global addr_type addr_type = MMGenAddrType(proto, 'Z')
def __init__(self): proto = init_proto('eth') global addr_type addr_type = MMGenAddrType(proto, 'E')
arg = cmd_args[1] if is_int(arg) and int(arg) > 0: return int(arg) try: return open(arg) except: die(1, m) # begin execution from mmgen.protocol import init_proto from mmgen.altcoin import CoinInfo as ci from mmgen.obj import MMGenAddrType, PrivKey from mmgen.addr import KeyGenerator, AddrGenerator addr_type = MMGenAddrType(proto=proto, id_str=opt.type or proto.dfl_mmtype) ext_progs = list(ci.external_tests[proto.network]) arg1 = cmd_args[0].split(':') if len(arg1) == 1: a, a_num = parse_arg1(arg1[0], 'a') b = None elif len(arg1) == 2: a, a_num = parse_arg1(arg1[0], 'a') b = parse_arg1(arg1[1], 'b') else: opts.usage() if type(a) == type(b): die(1, 'Address generators are the same!')
def Keyaddrfile_chksum(infile,mmtype=''): from mmgen.addr import KeyAddrList mmtype = None if not mmtype else MMGenAddrType(mmtype) KeyAddrList(infile,chksum_only=True,mmtype=mmtype)
if dtype == 'hex': return a.lstrip('0') == b.lstrip('0') if dtype == 'b58': return a.lstrip('1') == b.lstrip('1') else: return a == b def print_convert_results(indata,enc,dec,dtype): error = (True,False)[are_equal(indata,dec,dtype)] if error or opt.verbose: Msg('Input: {}'.format(repr(indata))) Msg('Encoded data: {}'.format(repr(enc))) Msg('Recoded data: {}'.format(repr(dec))) else: Msg(enc) if error: die(3,"Error! Recoded data doesn't match input!") from mmgen.obj import MMGenAddrType at = MMGenAddrType((hasattr(opt,'type') and opt.type) or g.proto.dfl_mmtype) kg = KeyGenerator(at) ag = AddrGenerator(at) def Hexdump(infile,cols=8,line_nums=True): Msg(pretty_hexdump( get_data_from_file(infile,dash=True,silent=True,binary=True), cols=cols,line_nums=line_nums)) def Unhexdump(infile): if g.platform == 'win': import msvcrt msvcrt.setmode(sys.stdout.fileno(),os.O_BINARY) sys.stdout.write(decode_pretty_hexdump( get_data_from_file(infile,dash=True,silent=True)))
+ pycoin (for supported coins) https://github.com/richardkiss/pycoin + keyconv (for all other coins) https://github.com/exploitagency/vanitygen-plus ('keyconv' generates uncompressed addresses only) """.format(prog='gentest.py', pnm=g.proj_name, snum=rounds, dn=g.proto.daemon_name) } sys.argv = [sys.argv[0]] + ['--skip-cfg-file'] + sys.argv[1:] cmd_args = opts.init(opts_data, add_opts=['exact_output']) if not 1 <= len(cmd_args) <= 2: opts.usage() addr_type = MMGenAddrType(opt.type or g.proto.dfl_mmtype) def pyethereum_sec2addr(sec): return sec, eth.privtoaddr(sec).encode('hex') def keyconv_sec2addr(sec): p = sp.Popen(['keyconv', '-C', g.coin, sec.wif], stderr=sp.PIPE, stdout=sp.PIPE) o = p.stdout.read().splitlines() # print p.stderr.read() return o[1].split()[1], o[0].split()[1]
return None arg = cmd_args[1] if is_int(arg) and int(arg) > 0: return int(arg) try: return open(arg) except: die(1,m) # begin execution from mmgen.protocol import init_proto from mmgen.altcoin import CoinInfo as ci from mmgen.obj import MMGenAddrType,PrivKey from mmgen.addr import KeyGenerator,AddrGenerator addr_type = MMGenAddrType(opt.type or g.proto.dfl_mmtype) ext_progs = list(ci.external_tests[g.proto.network]) arg1 = cmd_args[0].split(':') if len(arg1) == 1: a,a_num = parse_arg1(arg1[0],'a') b = None elif len(arg1) == 2: a,a_num = parse_arg1(arg1[0],'a') b = parse_arg1(arg1[1],'b') else: opts.usage() if type(a) == type(b): die(1,'Address generators are the same!')