minor changes and fixes

This commit is contained in:
The MMGen Project 2022-05-28 19:41:43 +00:00
commit 15f4e1405f
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
11 changed files with 30 additions and 27 deletions

View file

@ -147,9 +147,9 @@ class BitcoinTrackingWallet(TrackingWallet):
msg_r(f'{CR}Rescanning block: {block} ({n+1}/{len(blocks)})')
# httplib seems to require fresh connection here, so specify timeout
await self.rpc.call('rescanblockchain',block,block,timeout=60)
msg('\nRescan completed OK')
msg(f'\nAddress balance{suf(coin_addrs)} updated successfully')
return True
else:
msg('Imported address has no balance' if len(coin_addrs) == 1 else
'Imported addresses have no balances' )
msg('Address has no balance' if len(coin_addrs) == 1 else
'Addresses have no balances' )
return True

View file

@ -87,11 +87,11 @@ class Daemon(Lockable):
def run_cmd(self,cmd,silent=False,is_daemon=False):
if is_daemon and not silent:
msg(f'Starting {self.desc} on port {self.bind_port}')
if self.debug:
msg(f'\nExecuting: {" ".join(cmd)}')
msg('\n\n')
if self.debug or (is_daemon and not silent):
msg(f'Starting {self.desc} on port {self.bind_port}')
if self.use_threads and is_daemon and not self.opt.no_daemonize:
ret = self.exec_cmd_thread(cmd)

View file

@ -1 +1 @@
13.2.dev3
13.2.dev4

View file

@ -97,8 +97,10 @@ def parse_cmd_args(rpc,cmd_args):
if opt.addrlist:
al = AddrList(
proto = proto,
addrlist = get_lines_from_file(infile,f'non-{g.proj_name} addresses',
trim_comments = True) )
addrlist = get_lines_from_file(
infile,
f'non-{g.proj_name} addresses',
trim_comments = True ) )
else:
al = import_mmgen_list(infile)
elif len(cmd_args) == 0 and opt.address:

View file

@ -34,7 +34,7 @@ class mainnet(CoinProtocol.Secp256k1): # chainparams.cpp
_finfo(478559,'00000000000000000019f112ec0a9982926f1258cdcc558dd7c3b7e5dc7fa148','BCH',False),
]
caps = ('rbf','segwit')
mmcaps = ('key','addr','rpc','tx')
mmcaps = ('key','addr','rpc_init','tx')
base_coin = 'BTC'
base_proto = 'Bitcoin'
# From BIP173: witness version 'n' is stored as 'OP_n'. OP_0 is encoded as 0x00,

View file

@ -31,7 +31,7 @@ class mainnet(CoinProtocol.DummyWIF,CoinProtocol.Secp256k1):
chain_names = ['ethereum','foundation']
sign_mode = 'standalone'
caps = ('token',)
mmcaps = ('key','addr','rpc','tx')
mmcaps = ('key','addr','rpc_init','tx')
base_proto = 'Ethereum'
avg_bdi = 15
ignore_daemon_version = False

View file

@ -466,11 +466,14 @@ def handle_unsupported_daemon_version(rpc,name,warn_only):
option, in which case you proceed at your own risk.
""",indent=' '))
async def rpc_init(proto,backend=None,daemon=None,ignore_daemon_version=False):
if not 'rpc' in proto.mmcaps:
die(1,f'Coin daemon operations not supported for {proto.name} protocol!')
async def rpc_init(
proto,
backend = None,
daemon = None,
ignore_daemon_version = False ):
if not 'rpc_init' in proto.mmcaps:
die(1,f'rpc_init() not supported for {proto.name} protocol!')
cls = getattr(
importlib.import_module(f'mmgen.base_proto.{proto.base_proto.lower()}.rpc'),

View file

@ -20,6 +20,8 @@
twctl: Tracking wallet control class for the MMGen suite
"""
from collections import namedtuple
from ..globalvars import g
from ..util import msg,dmsg,write_mode,base_proto_subclass,die
from ..base_obj import AsyncInit
@ -251,7 +253,6 @@ class TrackingWallet(MMGenObject,metaclass=AsyncInit):
if not mmaddr:
mmaddr = f'{self.proto.base_coin.lower()}:{coinaddr}'
from collections import namedtuple
return namedtuple('addr_info',['mmaddr','coinaddr'])(
TwMMGenID(self.proto,mmaddr),
coinaddr )

View file

@ -4,13 +4,9 @@ if os.getenv('MMGEN_BOGUS_UNSPENT_DATA'):
rpc_init_orig = rpc_init
async def rpc_init(proto,backend=None,daemon=None,ignore_daemon_version=False):
async def rpc_init(*args,**kwargs):
ret = await rpc_init_orig(
proto = proto,
backend = backend,
daemon = daemon,
ignore_daemon_version = ignore_daemon_version )
ret = await rpc_init_orig(*args,**kwargs)
ret.blockcount = 1000000

View file

@ -981,7 +981,7 @@ class TestSuiteRunner(object):
elif ret == 'ok':
ok()
self.cmd_total += 1
elif ret == 'skip':
elif ret in ('skip','silent'):
pass
elif type(ret) == tuple and ret[0] == 'skip_warn':
self.skipped_warnings.append(

View file

@ -338,7 +338,8 @@ class TestSuiteRegtest(TestSuiteBase,TestSuiteShared):
def setup(self):
stop_test_daemons(self.proto.network_id,force=True,remove_datadir=True)
try: shutil.rmtree(joinpath(self.tr.data_dir,'regtest'))
from shutil import rmtree
try: rmtree(joinpath(self.tr.data_dir,'regtest'))
except: pass
t = self.spawn('mmgen-regtest',['-n','setup'])
for s in ('Starting','Creating','Creating','Creating','Mined','Setup complete'):
@ -942,7 +943,7 @@ class TestSuiteRegtest(TestSuiteBase,TestSuiteShared):
sid = self._user_sid('bob')
t = self.spawn('mmgen-tool',['--bob','rescan_address',f'{sid}:C:1'])
t.expect('Found 1 unspent output')
t.expect('completed OK')
t.expect('updated successfully')
return t
def bob_rescan_blockchain(self,add_args,expect):