def __new__(cls, s, on_fail='die'): if type(s) == cls: return s cls.arg_chk(cls, on_fail) try: assert set(s) <= set(ascii_letters + digits), 'contains non-ascii characters' me = str.__new__(cls, s) from mmgen.bitcoin import verify_addr va = verify_addr(s, return_dict=True) assert va, 'failed verification' me.addr_fmt = va['format'] me.hex = va['hex'] me.testnet = va['net'] == 'testnet' return me except Exception as e: m = "{!r}: value cannot be converted to Bitcoin address ({})" return cls.init_fail(m.format(s, e[0]), on_fail)
def Addr2hexaddr(addr): Msg(mmb.verify_addr(addr, return_dict=True)['hex'])
def addr2hexaddr(addr): Msg(bitcoin.verify_addr(addr,return_hex=True))
a.idx,a.addr,a.comment = None,btcaddr,None adata.append(a) ai.initialize(None,adata) else: ai = AddrInfo(infile,has_keys=opt.keyaddr_file) else: msg(""" You must specify an {pnm} address file (or a list of non-{pnm} addresses with the '--addrlist' option) """.strip().format(pnm=g.proj_name)) sys.exit(1) from mmgen.bitcoin import verify_addr qmsg_r("Validating addresses...") for e in ai.addrdata: if not verify_addr(e.addr,verbose=True): msg("%s: invalid address" % e.addr) sys.exit(2) m = (" from Seed ID %s" % ai.seed_id) if ai.seed_id else "" qmsg("OK. %s addresses%s" % (ai.num_addrs,m)) g.http_timeout = 3600 if not opt.test: c = connect_to_bitcoind() m = """ WARNING: You've chosen the '--rescan' option. Rescanning the blockchain is necessary only if an address you're importing is already on the blockchain, has a balance and is not already in your tracking wallet. Note that the
def is_btc_addr(s): from mmgen.bitcoin import verify_addr return verify_addr(s)