async def main(): from mmgen.protocol import init_proto_from_opts proto = init_proto_from_opts() from mmgen.rpc import rpc_init c = await rpc_init(proto) tip = await c.call('getblockcount') assert tip > 1, 'block tip must be > 1' remaining = proto.halving_interval - tip % proto.halving_interval sample_size = int(opt.sample_size) if opt.sample_size else min( tip - 1, max(remaining, 144)) # aiohttp backend will perform these two calls concurrently: cur, old = await c.gathered_call('getblockstats', ((tip, ), (tip - sample_size, ))) clock_time = int(time.time()) time_diff_warning(clock_time - cur['time']) bdr = (cur['time'] - old['time']) / sample_size t_rem = remaining * int(bdr) sub = cur['subsidy'] * proto.coin_amt.min_coin_unit print( f'Current block: {tip}\n' f'Next halving block: {tip + remaining}\n' f'Blocks until halving: {remaining}\n' f'Current block subsidy: {str(sub).rstrip("0")} {proto.coin}\n' f'Current block discovery rate (over last {sample_size} blocks): {bdr/60:0.1f} minutes\n' f'Current clock time (UTC): {date(clock_time)}\n' f'Est. halving date (UTC): {date(cur["time"] + t_rem)}\n' f'Est. time until halving: {dhms(cur["time"] + t_rem - clock_time)}\n')
def __init__(self, trunner, cfgs, spawn): from mmgen.protocol import init_proto_from_opts self.proto = init_proto_from_opts() self.tr = trunner self.cfgs = cfgs self.spawn = spawn self.have_dfl_wallet = False self.usr_rand_chars = (5, 30)[bool(opt.usr_random)] self.usr_rand_arg = '-r{}'.format(self.usr_rand_chars) self.altcoin_pfx = '' if self.proto.base_coin == 'BTC' else '-' + self.proto.base_coin self.tn_ext = ('', '.testnet')[self.proto.testnet] d = {'bch': 'btc', 'btc': 'btc', 'ltc': 'ltc'} self.fork = d[ self.proto.coin.lower()] if self.proto.coin.lower() in d else None
-t, --type=t Specify address type (valid options: 'zcash_z') -v, --verbose Produce more verbose output """, 'notes': """ If no command is given, the whole suite of tests is run. """ } } sys.argv = [sys.argv[0]] + ['--skip-cfg-file'] + sys.argv[1:] cmd_args = opts.init(opts_data, add_opts=['exact_output', 'profile']) from mmgen.protocol import init_proto_from_opts proto = init_proto_from_opts() cmd_data = { 'cryptocoin': { 'desc': 'Cryptocoin address/key commands', 'cmd_data': { 'randwif': (), 'randpair': (), # create 4 pairs: uncomp,comp,segwit,bech32 'wif2addr': ('randpair', 'o4'), 'wif2hex': ('randpair', 'o4'), 'privhex2pubhex': ('wif2hex', 'o3'), # segwit only 'pubhex2addr': ('privhex2pubhex', 'o3'), # segwit only 'hex2wif': ('wif2hex', 'io2'), # uncomp, comp 'addr2pubhash': ('randpair', 'o4'), # uncomp, comp, bech32 'pubhash2addr': ('addr2pubhash', 'io4'), # uncomp, comp, bech32 },