fixes & cleanups throughout
This commit is contained in:
parent
02a71f7443
commit
bd97eca7a6
13 changed files with 88 additions and 47 deletions
|
|
@ -158,7 +158,7 @@ class AddrGeneratorMonero(AddrGenerator):
|
|||
from .protocol import hash256
|
||||
self.hash256 = hash256
|
||||
|
||||
if opt.use_old_ed25519:
|
||||
if getattr(opt,'use_old_ed25519',False):
|
||||
from .ed25519 import edwards,encodepoint,B,scalarmult
|
||||
else:
|
||||
from .ed25519ll_djbec import scalarmult
|
||||
|
|
@ -398,16 +398,19 @@ Removed {{}} duplicate WIF key{{}} from keylist (also in {pnm} key-address file
|
|||
line_ctr = 0
|
||||
|
||||
def __init__(self,proto,
|
||||
addrfile = '',
|
||||
al_id = '',
|
||||
adata = [],
|
||||
seed = '',
|
||||
addr_idxs = '',
|
||||
src = '',
|
||||
addrlist = '',
|
||||
keylist = '',
|
||||
mmtype = None ):
|
||||
addrfile = '',
|
||||
al_id = '',
|
||||
adata = [],
|
||||
seed = '',
|
||||
addr_idxs = '',
|
||||
src = '',
|
||||
addrlist = '',
|
||||
keylist = '',
|
||||
mmtype = None,
|
||||
skip_key_address_validity_check = False,
|
||||
):
|
||||
|
||||
self.skip_ka_check = skip_key_address_validity_check
|
||||
do_chksum = True
|
||||
self.update_msgs()
|
||||
mmtype = mmtype or proto.dfl_mmtype
|
||||
|
|
@ -702,8 +705,8 @@ Removed {{}} duplicate WIF key{{}} from keylist (also in {pnm} key-address file
|
|||
|
||||
ret.append(a)
|
||||
|
||||
if self.has_keys:
|
||||
if (hasattr(opt,'yes') and opt.yes) or keypress_confirm('Check key-to-address validity?'):
|
||||
if self.has_keys and not self.skip_ka_check:
|
||||
if getattr(opt,'yes',False) or keypress_confirm('Check key-to-address validity?'):
|
||||
kg = KeyGenerator(self.proto,self.al_id.mmtype)
|
||||
ag = AddrGenerator(self.proto,self.al_id.mmtype)
|
||||
llen = len(ret)
|
||||
|
|
|
|||
|
|
@ -235,7 +235,9 @@ class MoneroWalletDaemon(Daemon):
|
|||
passwd = None,
|
||||
daemon_addr = None,
|
||||
proxy = None,
|
||||
port_shift = None ):
|
||||
port_shift = None,
|
||||
datadir = None,
|
||||
testnet = False ):
|
||||
|
||||
super().__init__()
|
||||
self.platform = g.platform
|
||||
|
|
@ -246,14 +248,13 @@ class MoneroWalletDaemon(Daemon):
|
|||
|
||||
bn = 'monero-wallet-rpc'
|
||||
id_str = f'{bn}-{self.rpc_port}'
|
||||
self.datadir = os.path.join('test',bn) if test_suite else bn
|
||||
self.datadir = os.path.join(datadir or ('','test')[test_suite], bn)
|
||||
self.pidfile = os.path.join(self.datadir,id_str+'.pid')
|
||||
self.logfile = os.path.join(self.datadir,id_str+'.log')
|
||||
|
||||
self.proxy = proxy
|
||||
self.daemon_addr = daemon_addr
|
||||
if not daemon_addr:
|
||||
self.daemon_port = CoinDaemon('xmr',test_suite=test_suite).rpc_port
|
||||
self.daemon_port = None if daemon_addr else CoinDaemon('xmr',test_suite=test_suite).rpc_port
|
||||
|
||||
if self.platform == 'win':
|
||||
self.use_pidfile = False
|
||||
|
|
@ -271,8 +272,7 @@ class MoneroWalletDaemon(Daemon):
|
|||
"option (insecure, not recommended), or by setting 'monero_wallet_rpc_password'\n" +
|
||||
"in the MMGen config file." )
|
||||
|
||||
self.start_cmd = list_gen(
|
||||
['monero-wallet-rpc'],
|
||||
self.daemon_args = list_gen(
|
||||
['--untrusted-daemon'],
|
||||
[f'--rpc-bind-port={self.rpc_port}'],
|
||||
['--wallet-dir='+self.wallet_dir],
|
||||
|
|
@ -283,8 +283,15 @@ class MoneroWalletDaemon(Daemon):
|
|||
[f'--proxy={self.proxy}', self.proxy],
|
||||
[f'--pidfile={self.pidfile}', self.platform == 'linux'],
|
||||
['--detach', not 'no_daemonize' in self.opts],
|
||||
['--testnet', testnet],
|
||||
)
|
||||
|
||||
self.usr_daemon_args = []
|
||||
|
||||
@property
|
||||
def start_cmd(self):
|
||||
return (['monero-wallet-rpc'] + self.daemon_args + self.usr_daemon_args )
|
||||
|
||||
@property
|
||||
def state(self):
|
||||
return 'ready' if self.test_socket('localhost',self.rpc_port) else 'stopped'
|
||||
|
|
@ -602,12 +609,17 @@ class MoneroDaemon(CoinDaemon):
|
|||
datadir_is_subdir = True
|
||||
|
||||
def subclass_init(self):
|
||||
|
||||
self.p2p_port = self.rpc_port - 1
|
||||
self.zmq_port = self.rpc_port + 1
|
||||
|
||||
if self.platform == 'win':
|
||||
self.use_pidfile = False
|
||||
|
||||
self.shared_args = list_gen(
|
||||
[f'--zmq-rpc-bind-port={self.rpc_port+1}'],
|
||||
[f'--p2p-bind-port={self.p2p_port}'],
|
||||
[f'--rpc-bind-port={self.rpc_port}'],
|
||||
[f'--zmq-rpc-bind-port={self.zmq_port}'],
|
||||
['--testnet', self.network == 'testnet'],
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -139,7 +139,7 @@ addr_type = MMGenAddrType(
|
|||
|
||||
if len(cmd_args) < 1: opts.usage()
|
||||
|
||||
if opt.use_old_ed25519:
|
||||
if getattr(opt,'use_old_ed25519',False):
|
||||
msg('Using old (slow) ed25519 module by user request')
|
||||
|
||||
idxs = AddrIdxList(fmt_str=cmd_args.pop())
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ Type '{pn} help <command>' for help on a particular command
|
|||
}
|
||||
}
|
||||
|
||||
cmd_args = opts.init(opts_data,add_opts=['hidden_incog_input_params','in_fmt','use_old_ed25519'])
|
||||
cmd_args = opts.init(opts_data,add_opts=['hidden_incog_input_params','in_fmt'])
|
||||
|
||||
if len(cmd_args) < 1:
|
||||
opts.usage()
|
||||
|
|
|
|||
|
|
@ -546,8 +546,9 @@ class BCHAmt(BTCAmt): pass
|
|||
class B2XAmt(BTCAmt): pass
|
||||
class LTCAmt(BTCAmt): max_amt = 84000000
|
||||
class XMRAmt(BTCAmt):
|
||||
min_coin_unit = Decimal('0.000000000001')
|
||||
units = ('min_coin_unit',)
|
||||
units = ('min_coin_unit','atomic')
|
||||
min_coin_unit = atomic = Decimal('0.000000000001')
|
||||
max_prec = 12
|
||||
|
||||
from .altcoins.eth.obj import ETHAmt,ETHNonce
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ from collections import namedtuple
|
|||
|
||||
from .util import msg,ymsg,Msg,ydie
|
||||
from .devtools import *
|
||||
from .obj import BTCAmt,LTCAmt,BCHAmt,B2XAmt,ETHAmt,CoinAddr,MMGenAddrType,PrivKey
|
||||
from .obj import BTCAmt,LTCAmt,BCHAmt,B2XAmt,XMRAmt,ETHAmt,CoinAddr,MMGenAddrType,PrivKey
|
||||
from .globalvars import g
|
||||
import mmgen.bech32 as bech32
|
||||
|
||||
|
|
@ -470,6 +470,7 @@ class CoinProtocol(MMGenObject):
|
|||
privkey_len = 32
|
||||
mmcaps = ('key','addr')
|
||||
ignore_daemon_version = False
|
||||
coin_amt = XMRAmt
|
||||
|
||||
def preprocess_key(self,sec,pubkey_type): # reduce key
|
||||
from .ed25519 import l
|
||||
|
|
|
|||
18
mmgen/rpc.py
18
mmgen/rpc.py
|
|
@ -178,7 +178,6 @@ class RPCBackends:
|
|||
'curl',
|
||||
'--proxy', '',
|
||||
'--connect-timeout', str(timeout or self.timeout),
|
||||
'--request', 'POST',
|
||||
'--write-out', '%{http_code}',
|
||||
'--data-binary', data
|
||||
] + self.exec_opts + [self.url + self.make_host_path(wallet)]
|
||||
|
|
@ -242,16 +241,17 @@ class RPCClient(MMGenObject):
|
|||
network_proto = 'http'
|
||||
host_path = ''
|
||||
|
||||
def __init__(self,host,port):
|
||||
def __init__(self,host,port,test_connection=True):
|
||||
|
||||
dmsg_rpc('=== {}.__init__() debug ==='.format(type(self).__name__))
|
||||
dmsg_rpc(f' cls [{type(self).__name__}] host [{host}] port [{port}]\n')
|
||||
|
||||
import socket
|
||||
try:
|
||||
socket.create_connection((host,port),timeout=1).close()
|
||||
except:
|
||||
raise SocketError(f'Unable to connect to {host}:{port}')
|
||||
if test_connection:
|
||||
import socket
|
||||
try:
|
||||
socket.create_connection((host,port),timeout=1).close()
|
||||
except:
|
||||
raise SocketError(f'Unable to connect to {host}:{port}')
|
||||
|
||||
self.http_hdrs = { 'Content-Type': 'application/json' }
|
||||
self.url = f'{self.network_proto}://{host}:{port}{self.host_path}'
|
||||
|
|
@ -662,8 +662,8 @@ class MoneroRPCClient(RPCClient):
|
|||
host_path = '/json_rpc'
|
||||
verify_server = False
|
||||
|
||||
def __init__(self,host,port,user,passwd):
|
||||
super().__init__(host,port)
|
||||
def __init__(self,host,port,user,passwd,test_connection=True):
|
||||
super().__init__(host,port,test_connection)
|
||||
if self.auth_type:
|
||||
self.auth = auth_data(user,passwd)
|
||||
if True:
|
||||
|
|
|
|||
|
|
@ -1129,7 +1129,7 @@ class tool_api(
|
|||
import mmgen.opts
|
||||
opts.UserOpts._reset_ok += ('usr_randchars',)
|
||||
if not hasattr(opt,'version'):
|
||||
opts.init(add_opts=['use_old_ed25519'])
|
||||
opts.init()
|
||||
super().__init__()
|
||||
|
||||
def init_coin(self,coinsym,network):
|
||||
|
|
|
|||
|
|
@ -223,16 +223,16 @@ class MoneroWalletOps:
|
|||
uarg = uarg_tuple
|
||||
uarg_info = xmrwallet_uarg_info
|
||||
|
||||
from .obj import XMRAmt
|
||||
def fmt_amt(amt):
|
||||
return XMRAmt(amt,from_unit='min_coin_unit').fmt(fs='5.12',color=True)
|
||||
return self.proto.coin_amt(amt,from_unit='min_coin_unit').fmt(fs='5.12',color=True)
|
||||
def hl_amt(amt):
|
||||
return XMRAmt(amt,from_unit='min_coin_unit').hl()
|
||||
return self.proto.coin_amt(amt,from_unit='min_coin_unit').hl()
|
||||
|
||||
self.check_uargs()
|
||||
|
||||
from .protocol import init_proto
|
||||
self.kal = KeyAddrList(init_proto('xmr',network='mainnet'),uarg.xmr_keyaddrfile)
|
||||
self.proto = init_proto('xmr',testnet=g.testnet)
|
||||
self.kal = KeyAddrList(self.proto,uarg.xmr_keyaddrfile)
|
||||
self.create_addr_data()
|
||||
|
||||
check_wallets()
|
||||
|
|
@ -302,6 +302,7 @@ class MoneroWalletOps:
|
|||
wallet_exists = False
|
||||
|
||||
async def run(self,d,fn):
|
||||
msg_r('') # for pexpect
|
||||
|
||||
from .baseconv import baseconv
|
||||
ret = await self.c.call(
|
||||
|
|
@ -442,6 +443,9 @@ class MoneroWalletOps:
|
|||
port_shift = 16,
|
||||
)
|
||||
|
||||
if g.test_suite:
|
||||
self.wd2.usr_daemon_args = ['--daemon-ssl-allow-any-cert']
|
||||
|
||||
if uarg.start_wallet_daemon:
|
||||
self.wd2.restart()
|
||||
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ Supported external tools:
|
|||
|
||||
sys.argv = [sys.argv[0]] + ['--skip-cfg-file'] + sys.argv[1:]
|
||||
|
||||
cmd_args = opts.init(opts_data,add_opts=['exact_output','use_old_ed25519'])
|
||||
cmd_args = opts.init(opts_data,add_opts=['exact_output'])
|
||||
|
||||
if not 1 <= len(cmd_args) <= 2:
|
||||
opts.usage()
|
||||
|
|
|
|||
|
|
@ -147,11 +147,11 @@ def init_coverage():
|
|||
|
||||
devnull_fh = open(('/dev/null','null.out')[g.platform == 'win'],'w')
|
||||
def silence():
|
||||
if not (opt.verbose or (hasattr(opt,'exact_output') and opt.exact_output)):
|
||||
if not (opt.verbose or getattr(opt,'exact_output',None)):
|
||||
g.stdout = g.stderr = devnull_fh
|
||||
|
||||
def end_silence():
|
||||
if not (opt.verbose or (hasattr(opt,'exact_output') and opt.exact_output)):
|
||||
if not (opt.verbose or getattr(opt,'exact_output',None)):
|
||||
g.stdout = sys.stdout
|
||||
g.stderr = sys.stderr
|
||||
|
||||
|
|
@ -160,16 +160,27 @@ def omsg(s):
|
|||
def omsg_r(s):
|
||||
sys.stderr.write(s)
|
||||
sys.stderr.flush()
|
||||
|
||||
def imsg(s):
|
||||
if opt.verbose or (hasattr(opt,'exact_output') and opt.exact_output):
|
||||
if opt.verbose or getattr(opt,'exact_output',None):
|
||||
omsg(s)
|
||||
def imsg_r(s):
|
||||
if opt.verbose or (hasattr(opt,'exact_output') and opt.exact_output):
|
||||
if opt.verbose or getattr(opt,'exact_output',None):
|
||||
omsg_r(s)
|
||||
|
||||
def iqmsg(s):
|
||||
if not opt.quiet: omsg(s)
|
||||
if not opt.quiet:
|
||||
omsg(s)
|
||||
def iqmsg_r(s):
|
||||
if not opt.quiet: omsg_r(s)
|
||||
if not opt.quiet:
|
||||
omsg_r(s)
|
||||
|
||||
def oqmsg(s):
|
||||
if not (opt.verbose or getattr(opt,'exact_output',None)):
|
||||
omsg(s)
|
||||
def oqmsg_r(s):
|
||||
if not (opt.verbose or getattr(opt,'exact_output',None)):
|
||||
omsg_r(s)
|
||||
|
||||
def start_test_daemons(*network_ids,remove_datadir=False):
|
||||
if not opt.no_daemon_autostart:
|
||||
|
|
|
|||
12
test/test.py
12
test/test.py
|
|
@ -780,15 +780,25 @@ class TestSuiteRunner(object):
|
|||
else:
|
||||
if ':' in arg:
|
||||
gname,arg = arg.split(':')
|
||||
direct_call_ok = True # allow calling of functions not in cmd_group
|
||||
else:
|
||||
gname = self.gm.find_cmd_in_groups(arg)
|
||||
direct_call_ok = False
|
||||
if gname:
|
||||
same_grp = gname == gname_save # same group as previous cmd: don't clean, suppress blue msg
|
||||
if not self.init_group(gname,arg,quiet=same_grp):
|
||||
continue
|
||||
if not same_grp:
|
||||
clean(self.ts.tmpdir_nums)
|
||||
self.check_needs_rerun(arg,build=True)
|
||||
try:
|
||||
self.check_needs_rerun(arg,build=True)
|
||||
except:
|
||||
if direct_call_ok:
|
||||
ret = getattr(self.ts,arg)()
|
||||
if type(ret).__name__ == 'coroutine':
|
||||
run_session(ret)
|
||||
else:
|
||||
raise
|
||||
do_between()
|
||||
gname_save = gname
|
||||
else:
|
||||
|
|
|
|||
|
|
@ -979,7 +979,6 @@ sys.argv = [sys.argv[0]] + ['--skip-cfg-file'] + sys.argv[1:]
|
|||
|
||||
cmd_args = opts.init(
|
||||
opts_data,
|
||||
add_opts = ['use_old_ed25519'],
|
||||
init_opts = {
|
||||
'usr_randchars': 0,
|
||||
'hash_preset': '1',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue