minor fixes and cleanups
This commit is contained in:
parent
b5f0a4c653
commit
f2bf16bbdb
15 changed files with 41 additions and 33 deletions
|
|
@ -200,9 +200,9 @@ class KeccakState:
|
|||
i = 0
|
||||
for y in self.rangeH:
|
||||
for x in self.rangeW:
|
||||
v = KeccakState.lane2bytes(self.s[x][y], self.lanew)
|
||||
out[i:i+8] = v
|
||||
i += 8
|
||||
v = KeccakState.lane2bytes(self.s[x][y], self.lanew)
|
||||
out[i:i+8] = v
|
||||
i += 8
|
||||
return out
|
||||
|
||||
def set_bytes(self, bb):
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ class Daemon(Lockable):
|
|||
out = (PIPE,None)[is_daemon and self.opt.no_daemonize]
|
||||
try:
|
||||
cp = run(cmd,check=False,stdout=out,stderr=out)
|
||||
except Exception as e:
|
||||
except OSError as e:
|
||||
die( 'MMGenCalledProcessError', f'Error starting executable: {type(e).__name__} [Errno {e.errno}]' )
|
||||
set_vt100()
|
||||
if self.debug:
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ from .addrlist import AddrIdxList
|
|||
from .passwdlist import PasswordList
|
||||
from .wallet import Wallet
|
||||
from .obj import MMGenPWIDString
|
||||
from .ui import keypress_confirm
|
||||
|
||||
pwi = PasswordList.pw_info
|
||||
|
||||
|
|
@ -178,7 +179,6 @@ af = al.file
|
|||
|
||||
af.format()
|
||||
|
||||
from .ui import keypress_confirm
|
||||
if keypress_confirm( cfg, 'Encrypt password list?' ):
|
||||
af.encrypt()
|
||||
af.write(binary=True,desc='encrypted password list')
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import sys,re,base64,json,asyncio,importlib
|
|||
from decimal import Decimal
|
||||
from collections import namedtuple
|
||||
|
||||
from .util import msg,die,fmt,fmt_list,pp_fmt,oneshot_warning
|
||||
from .util import msg,ymsg,die,fmt,fmt_list,pp_fmt,oneshot_warning
|
||||
from .base_obj import AsyncInit
|
||||
from .obj import NonNegativeInt
|
||||
from .objmethods import HiliteStr,InitErrors,MMGenObject
|
||||
|
|
@ -93,6 +93,7 @@ class RPCBackends:
|
|||
self.timeout = caller.timeout
|
||||
self.http_hdrs = caller.http_hdrs
|
||||
self.name = type(self).__name__
|
||||
self.caller = caller
|
||||
|
||||
class aiohttp(base,metaclass=AsyncInit):
|
||||
"""
|
||||
|
|
@ -231,7 +232,8 @@ class RPCBackends:
|
|||
async def run(self,payload,timeout,host_path):
|
||||
data = json.dumps(payload,cls=json_encoder)
|
||||
if len(data) > self.arg_max:
|
||||
return self.httplib(payload,timeout=timeout) # TODO: check
|
||||
ymsg('Warning: Curl data payload length exceeded - falling back on httplib')
|
||||
return RPCBackends.httplib(self.caller).run(payload,timeout,host_path)
|
||||
dmsg_rpc_backend(self.host_url,host_path,payload)
|
||||
exec_cmd = [
|
||||
'curl',
|
||||
|
|
|
|||
|
|
@ -63,13 +63,10 @@ class Sha2:
|
|||
cbrt = lambda n: pow(n, 1 / 3)
|
||||
|
||||
# First wordBits bits of the fractional parts of the square roots of the first 8 primes
|
||||
H = (getFractionalBits(sqrt(n)) for n in primes[:8])
|
||||
cls.H_init = tuple(getFractionalBits(sqrt(n)) for n in primes[:8])
|
||||
|
||||
# First wordBits bits of the fractional parts of the cube roots of the first nRounds primes
|
||||
K = (getFractionalBits(cbrt(n)) for n in primes)
|
||||
|
||||
cls.H_init = tuple(H)
|
||||
cls.K = tuple(K)
|
||||
cls.K = tuple(getFractionalBits(cbrt(n)) for n in primes)
|
||||
|
||||
def __init__(self,message,preprocess=True):
|
||||
'Use preprocess=False for Sha256Compress'
|
||||
|
|
|
|||
|
|
@ -64,10 +64,12 @@ class TwAddresses(TwView):
|
|||
MMGenListItem.__init__(self,**kwargs)
|
||||
|
||||
class conv_funcs:
|
||||
def amt(self,value):
|
||||
return self.proto.coin_amt(value)
|
||||
def recvd(self,value):
|
||||
return self.proto.coin_amt(value)
|
||||
@staticmethod
|
||||
def amt(instance,value):
|
||||
return instance.proto.coin_amt(value)
|
||||
@staticmethod
|
||||
def recvd(instance,value):
|
||||
return instance.proto.coin_amt(value)
|
||||
|
||||
@property
|
||||
def coinaddr_list(self):
|
||||
|
|
|
|||
|
|
@ -70,10 +70,12 @@ class TwUnspentOutputs(TwView):
|
|||
MMGenListItem.__init__(self,**kwargs)
|
||||
|
||||
class conv_funcs:
|
||||
def amt(self,value):
|
||||
return self.proto.coin_amt(value)
|
||||
def amt2(self,value):
|
||||
return self.proto.coin_amt(value)
|
||||
@staticmethod
|
||||
def amt(instance,value):
|
||||
return instance.proto.coin_amt(value)
|
||||
@staticmethod
|
||||
def amt2(instance,value):
|
||||
return instance.proto.coin_amt(value)
|
||||
|
||||
async def __init__(self,cfg,proto,minconf=1,addrs=[]):
|
||||
await super().__init__(cfg,proto)
|
||||
|
|
|
|||
|
|
@ -76,6 +76,7 @@ class TwView(MMGenObject,metaclass=AsyncInit):
|
|||
class line_processing:
|
||||
|
||||
class print:
|
||||
@staticmethod
|
||||
def do(method,data,cw,fs,color,fmt_method):
|
||||
return [l.rstrip() for l in method(data,cw,fs,color,fmt_method)]
|
||||
|
||||
|
|
|
|||
|
|
@ -57,8 +57,9 @@ class MMGenTxIO(MMGenListItem):
|
|||
None )
|
||||
|
||||
class conv_funcs:
|
||||
def amt(self,value):
|
||||
return self.proto.coin_amt(value)
|
||||
@staticmethod
|
||||
def amt(instance,value):
|
||||
return instance.proto.coin_amt(value)
|
||||
|
||||
class MMGenTxIOList(list,MMGenObject):
|
||||
|
||||
|
|
|
|||
|
|
@ -63,7 +63,8 @@ class MMGenTxFile(MMGenObject):
|
|||
try:
|
||||
desc = 'data'
|
||||
if len(tx_data) > tx.cfg.max_tx_file_size:
|
||||
die( 'MaxFileSizeExceeded', f'Transaction file size exceeds limit ({tx.cfg.max_tx_file_size} bytes)' )
|
||||
die('MaxFileSizeExceeded',
|
||||
f'Transaction file size exceeds limit ({tx.cfg.max_tx_file_size} bytes)')
|
||||
tx_data = tx_data.splitlines()
|
||||
assert len(tx_data) >= 5,'number of lines less than 5'
|
||||
assert len(tx_data[0]) == 6,'invalid length of first line'
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@
|
|||
test.include.coin_daemon_control: Start and stop daemons for the MMGen test suite
|
||||
"""
|
||||
|
||||
import include.test_init
|
||||
from mmgen.cfg import Config,gc
|
||||
from mmgen.util import msg,die,oneshot_warning,async_run
|
||||
from mmgen.protocol import init_proto
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ from .unspent_orig import *
|
|||
|
||||
if overlay_fake_os.getenv('MMGEN_BOGUS_UNSPENT_DATA'):
|
||||
|
||||
class overlay_fake_data:
|
||||
class overlay_fake_BitcoinTwUnspentOutputs(BitcoinTwUnspentOutputs):
|
||||
|
||||
async def get_rpc_data(self):
|
||||
from decimal import Decimal
|
||||
|
|
@ -14,4 +14,4 @@ if overlay_fake_os.getenv('MMGEN_BOGUS_UNSPENT_DATA'):
|
|||
overlay_fake_os.getenv('MMGEN_BOGUS_UNSPENT_DATA')
|
||||
), parse_float=Decimal)
|
||||
|
||||
BitcoinTwUnspentOutputs.get_rpc_data = overlay_fake_data.get_rpc_data
|
||||
BitcoinTwUnspentOutputs.get_rpc_data = overlay_fake_BitcoinTwUnspentOutputs.get_rpc_data
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@ from .unspent_orig import *
|
|||
|
||||
if overlay_fake_os.getenv('MMGEN_BOGUS_UNSPENT_DATA'):
|
||||
|
||||
class overlay_fake_data:
|
||||
class overlay_fake_TwUnspentOutputs(TwUnspentOutputs):
|
||||
|
||||
async def set_dates(_,us):
|
||||
async def set_dates(self,us):
|
||||
for o in us:
|
||||
o.date = 1831006505 - int(9.7 * 60 * (o.confs - 1))
|
||||
|
||||
TwUnspentOutputs.set_dates = overlay_fake_data.set_dates
|
||||
TwUnspentOutputs.set_dates = overlay_fake_TwUnspentOutputs.set_dates
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@ from .new_orig import *
|
|||
|
||||
if overlay_fake_os.getenv('MMGEN_BOGUS_UNSPENT_DATA'):
|
||||
|
||||
class overlay_fake_data:
|
||||
class overlay_fake_New(New):
|
||||
|
||||
async def warn_chg_addr_used(_,us):
|
||||
async def warn_chg_addr_used(self,_):
|
||||
from ..util import ymsg
|
||||
ymsg('Bogus unspent data: skipping change address is used check')
|
||||
ymsg('Bogus unspent data: skipping used change address check')
|
||||
|
||||
New.warn_chg_addr_used = overlay_fake_data.warn_chg_addr_used
|
||||
New.warn_chg_addr_used = overlay_fake_New.warn_chg_addr_used
|
||||
|
|
|
|||
|
|
@ -80,6 +80,7 @@ def do_msg(rpc,backend):
|
|||
|
||||
class init_test:
|
||||
|
||||
@staticmethod
|
||||
async def btc(proto,backend,daemon):
|
||||
rpc = await rpc_init(cfg,proto,backend,daemon)
|
||||
do_msg(rpc,backend)
|
||||
|
|
@ -89,6 +90,7 @@ class init_test:
|
|||
await rpc.gathered_call(None,(('getblock',(bh,)),('getblock',(bh,1))),timeout=300)
|
||||
return rpc
|
||||
|
||||
@staticmethod
|
||||
async def bch(proto,backend,daemon):
|
||||
rpc = await rpc_init(cfg,proto,backend,daemon)
|
||||
do_msg(rpc,backend)
|
||||
|
|
@ -96,6 +98,7 @@ class init_test:
|
|||
|
||||
ltc = bch
|
||||
|
||||
@staticmethod
|
||||
async def eth(proto,backend,daemon):
|
||||
rpc = await rpc_init(cfg,proto,backend,daemon)
|
||||
do_msg(rpc,backend)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue