pylint throughout (excluding tests) - unused variables
This commit is contained in:
parent
881c6fea03
commit
a4cb7e3c72
32 changed files with 53 additions and 69 deletions
|
|
@ -63,7 +63,7 @@ class AddrFile(MMGenObject):
|
|||
('.' + self.parent.proto.network) if self.parent.proto.testnet else '',
|
||||
self.ext )
|
||||
|
||||
def write(self,fn=None,ask_tty=True,binary=False,desc=None,ask_overwrite=True):
|
||||
def write(self,fn=None,binary=False,desc=None,ask_overwrite=True):
|
||||
from .fileutil import write_data_to_file
|
||||
write_data_to_file(
|
||||
self.cfg,
|
||||
|
|
|
|||
|
|
@ -711,7 +711,6 @@ def init_genonly_altcoins(usr_coin=None,testnet=False):
|
|||
if usr_coin is None:
|
||||
for network in networks:
|
||||
data[network] = CoinInfo.get_supported_coins(network)
|
||||
trust_level = 0
|
||||
else:
|
||||
if usr_coin.lower() in gc.core_coins: # core coin, so return immediately
|
||||
from .protocol import CoinProtocol
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ class Crypto:
|
|||
|
||||
def sha256_rounds(self,s):
|
||||
from hashlib import sha256
|
||||
for i in range(self.scramble_hash_rounds):
|
||||
for _ in range(self.scramble_hash_rounds):
|
||||
s = sha256(s).digest()
|
||||
return s
|
||||
|
||||
|
|
@ -373,7 +373,7 @@ class Crypto:
|
|||
if self.cfg.echo_passphrase:
|
||||
pw = ' '.join(get_words_from_user( self.cfg, f'Enter {pw_desc} for {data_desc}: ' ))
|
||||
else:
|
||||
for i in range(gc.passwd_max_tries):
|
||||
for _ in range(gc.passwd_max_tries):
|
||||
pw = ' '.join(get_words_from_user( self.cfg, f'Enter {pw_desc} for {data_desc}: ' ))
|
||||
pw_chk = ' '.join(get_words_from_user( self.cfg, f'Repeat {pw_desc}: ' ))
|
||||
self.util.dmsg(f'Passphrases: [{pw}] [{pw_chk}]')
|
||||
|
|
|
|||
|
|
@ -233,7 +233,7 @@ class Daemon(Lockable):
|
|||
return True
|
||||
|
||||
def wait_for_state(self,req_state):
|
||||
for i in range(300):
|
||||
for _ in range(300):
|
||||
if self.state == req_state:
|
||||
return True
|
||||
time.sleep(0.2)
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ async def main():
|
|||
msg(orig_tx.info.format(terse=True))
|
||||
|
||||
kal = get_keyaddrlist(cfg,orig_tx.proto)
|
||||
kl = get_keylist(cfg,orig_tx.proto)
|
||||
kl = get_keylist(cfg)
|
||||
sign_and_send = bool(seed_files or kl or kal)
|
||||
|
||||
from .tw.ctl import TwCtl
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@ async def main():
|
|||
caller = 'txdo' )
|
||||
|
||||
kal = get_keyaddrlist(cfg,cfg._proto)
|
||||
kl = get_keylist(cfg,cfg._proto)
|
||||
kl = get_keylist(cfg)
|
||||
|
||||
tx3 = await txsign(cfg,tx2,seed_files,kl,kal)
|
||||
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ if not cfg.info and not cfg.terse_info:
|
|||
|
||||
from .tx.sign import txsign,get_tx_files,get_seed_files,get_keylist,get_keyaddrlist
|
||||
|
||||
tx_files = get_tx_files(cfg,infiles)
|
||||
tx_files = get_tx_files(infiles)
|
||||
seed_files = get_seed_files(cfg,infiles)
|
||||
|
||||
async def main():
|
||||
|
|
@ -149,7 +149,7 @@ async def main():
|
|||
tx1.info.view_with_prompt(f'View data for transaction{tx_num_disp}?')
|
||||
|
||||
kal = get_keyaddrlist(cfg,tx1.proto)
|
||||
kl = get_keylist(cfg,tx1.proto)
|
||||
kl = get_keylist(cfg)
|
||||
|
||||
tx2 = await txsign(cfg,tx1,seed_files,kl,kal,tx_num_disp)
|
||||
if tx2:
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ class MnEntryModeFull(MnEntryMode):
|
|||
def get_word(self,mne):
|
||||
s,pad = ('', 0)
|
||||
while True:
|
||||
ch,s,foo = self.get_char(s)
|
||||
ch,s,_ = self.get_char(s)
|
||||
if ch in _return_chars:
|
||||
if s:
|
||||
break
|
||||
|
|
@ -116,7 +116,7 @@ class MnEntryModeShort(MnEntryMode):
|
|||
def get_word(self,mne):
|
||||
s,pad = ('', 0)
|
||||
while True:
|
||||
ch,s,foo = self.get_char(s)
|
||||
ch,s,_ = self.get_char(s)
|
||||
if ch in _return_chars:
|
||||
if s:
|
||||
break
|
||||
|
|
@ -159,7 +159,7 @@ class MnEntryModeFixed(MnEntryMode):
|
|||
def get_word(self,mne):
|
||||
s,pad = ('', 0)
|
||||
while True:
|
||||
ch,s,foo = self.get_char(s)
|
||||
ch,s,_ = self.get_char(s)
|
||||
if ch in _return_chars:
|
||||
if s:
|
||||
break
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ class UserOpts:
|
|||
self.usage_data = od['text'].get('usage2') or od['text']['usage']
|
||||
|
||||
# po: (user_opts,cmd_args,opts,filtered_opts)
|
||||
po = parsed_opts or Opts.parse_opts(od,opt_filter=opt_filter,parse_only=parse_only)
|
||||
po = parsed_opts or Opts.parse_opts(od,opt_filter=opt_filter)
|
||||
|
||||
cfg._args = po.cmd_args
|
||||
cfg._uopts = uopts = po.user_opts
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ class PasswordList(AddrList):
|
|||
return
|
||||
if self.hex2bip39:
|
||||
ymsg(self.feature_warn_fs.format(pw_fmt))
|
||||
self.set_pw_len_vs_seed_len(pw_len,seed) # sets self.bip39, self.xmrseed, self.xmrproto self.baseconv
|
||||
self.set_pw_len_vs_seed_len(seed) # sets self.bip39, self.xmrseed, self.xmrproto self.baseconv
|
||||
self.al_id = AddrListID( sid=seed.sid, mmtype=MMGenPasswordType(self.proto,'P') )
|
||||
self.data = self.generate(seed,pw_idxs)
|
||||
|
||||
|
|
@ -154,7 +154,7 @@ class PasswordList(AddrList):
|
|||
self.pw_len = int(pw_len)
|
||||
self.chk_pw_len()
|
||||
|
||||
def set_pw_len_vs_seed_len(self,pw_len,seed):
|
||||
def set_pw_len_vs_seed_len(self,seed):
|
||||
pf = self.pw_fmt
|
||||
if pf == 'hex':
|
||||
pw_bytes = self.pw_len // 2
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ class BitcoinTwGetBalance(TwGetBalance):
|
|||
|
||||
async def create_data(self):
|
||||
lbl_id = ('account','label')['label_api' in self.rpc.caps]
|
||||
amt0 = self.proto.coin_amt('0')
|
||||
for d in await self.rpc.call('listunspent',0):
|
||||
tw_lbl = get_tw_label(self.proto,d[lbl_id])
|
||||
if tw_lbl:
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ class TxInfo(TxInfo):
|
|||
Fee: {a} {c}{r}
|
||||
""")
|
||||
|
||||
def format_rel_fee(self,terse):
|
||||
def format_rel_fee(self):
|
||||
tx = self.tx
|
||||
return ' ({} {}, {} of spend amount)'.format(
|
||||
pink(str(tx.fee_abs2rel(tx.fee))),
|
||||
|
|
|
|||
|
|
@ -95,28 +95,24 @@ class TokenCommon(MMGenObject):
|
|||
self,
|
||||
to_addr,
|
||||
amt,
|
||||
method_sig = 'transfer(address,uint256)',
|
||||
from_addr = None):
|
||||
from_arg = from_addr.rjust(64,'0') if from_addr else ''
|
||||
method_sig = 'transfer(address,uint256)'):
|
||||
from_arg = ''
|
||||
to_arg = to_addr.rjust(64,'0')
|
||||
amt_arg = '{:064x}'.format( int(amt / self.base_unit) )
|
||||
return self.create_method_id(method_sig) + from_arg + to_arg + amt_arg
|
||||
|
||||
def make_tx_in(
|
||||
self,
|
||||
from_addr,
|
||||
to_addr,
|
||||
amt,
|
||||
start_gas,
|
||||
gasPrice,
|
||||
nonce,
|
||||
method_sig = 'transfer(address,uint256)',
|
||||
from_addr2 = None):
|
||||
method_sig = 'transfer(address,uint256)'):
|
||||
data = self.create_data(
|
||||
to_addr,
|
||||
amt,
|
||||
method_sig = method_sig,
|
||||
from_addr = from_addr2)
|
||||
method_sig = method_sig)
|
||||
return {
|
||||
'to': bytes.fromhex(self.addr),
|
||||
'startgas': start_gas.toWei(),
|
||||
|
|
@ -162,18 +158,14 @@ class TokenCommon(MMGenObject):
|
|||
key,
|
||||
start_gas,
|
||||
gasPrice,
|
||||
method_sig = 'transfer(address,uint256)',
|
||||
from_addr2=None,
|
||||
return_data=False):
|
||||
method_sig = 'transfer(address,uint256)'):
|
||||
tx_in = self.make_tx_in(
|
||||
from_addr,
|
||||
to_addr,
|
||||
amt,
|
||||
start_gas,
|
||||
gasPrice,
|
||||
nonce = int(await self.rpc.call('eth_getTransactionCount','0x'+from_addr,'pending'),16),
|
||||
method_sig = method_sig,
|
||||
from_addr2 = from_addr2 )
|
||||
method_sig = method_sig)
|
||||
txhex,_ = await self.txsign(tx_in,key,from_addr)
|
||||
return await self.txsend(txhex)
|
||||
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ class Base(TxBase.Base):
|
|||
def is_replaceable(self):
|
||||
return True
|
||||
|
||||
async def get_receipt(self,txid,silent=False):
|
||||
async def get_receipt(self,txid):
|
||||
rx = await self.rpc.call('eth_getTransactionReceipt','0x'+txid) # -> null if pending
|
||||
if not rx:
|
||||
return None
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ class TxInfo(TxInfo):
|
|||
def format_abs_fee(self,color,iwidth):
|
||||
return self.tx.fee.fmt(color=color,iwidth=iwidth) + (' (max)' if self.tx.txobj['data'] else '')
|
||||
|
||||
def format_rel_fee(self,terse):
|
||||
def format_rel_fee(self):
|
||||
return ' ({} of spend amount)'.format(
|
||||
pink('{:0.6f}%'.format( self.tx.fee / self.tx.send_amt * 100 ))
|
||||
)
|
||||
|
|
@ -73,7 +73,7 @@ class TxInfo(TxInfo):
|
|||
class TokenTxInfo(TxInfo):
|
||||
fmt_keys = ('from','token_to','amt','nonce')
|
||||
|
||||
def format_rel_fee(self,terse):
|
||||
def format_rel_fee(self):
|
||||
return ''
|
||||
|
||||
def format_body(self,*args,**kwargs):
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ class TokenOnlineSigned(TokenSigned,OnlineSigned):
|
|||
def parse_txfile_serialized_data(self):
|
||||
from ....addr import TokenAddr
|
||||
from ..contract import Token
|
||||
d = OnlineSigned.parse_txfile_serialized_data(self)
|
||||
OnlineSigned.parse_txfile_serialized_data(self)
|
||||
o = self.txobj
|
||||
assert self.twctl.token == o['to']
|
||||
o['token_addr'] = TokenAddr(self.proto,o['to'])
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ class Unsigned(Completed,TxBase.Unsigned):
|
|||
self.txobj = o
|
||||
return d # 'token_addr','decimals' required by Token subclass
|
||||
|
||||
async def do_sign(self,wif,tx_num_str):
|
||||
async def do_sign(self,wif):
|
||||
o = self.txobj
|
||||
o_conv = {
|
||||
'to': bytes.fromhex(o['to']),
|
||||
|
|
@ -77,7 +77,7 @@ class Unsigned(Completed,TxBase.Unsigned):
|
|||
msg_r(f'Signing transaction{tx_num_str}...')
|
||||
|
||||
try:
|
||||
await self.do_sign(keys[0].sec.wif,tx_num_str)
|
||||
await self.do_sign(keys[0].sec.wif)
|
||||
msg('OK')
|
||||
from ....tx import SignedTX
|
||||
return await SignedTX(cfg=self.cfg,data=self.__dict__)
|
||||
|
|
@ -97,7 +97,7 @@ class TokenUnsigned(TokenCompleted,Unsigned):
|
|||
o['data'] = t.create_data(o['to'],o['amt'])
|
||||
o['token_to'] = t.transferdata2sendaddr(o['data'])
|
||||
|
||||
async def do_sign(self,wif,tx_num_str):
|
||||
async def do_sign(self,wif):
|
||||
o = self.txobj
|
||||
t = Token(self.cfg,self.proto,o['token_addr'],o['decimals'])
|
||||
tx_in = t.make_tx_in(
|
||||
|
|
|
|||
|
|
@ -155,7 +155,7 @@ def process_uopts(opts_data,short_opts,long_opts):
|
|||
|
||||
return uopts,uargs
|
||||
|
||||
def parse_opts(opts_data,opt_filter=None,parse_only=False):
|
||||
def parse_opts(opts_data,opt_filter=None):
|
||||
|
||||
short_opts,long_opts,filtered_opts = [],[],[]
|
||||
def parse_lines(opts_type):
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ rand_h = sha256('.'.join(sys.argv).encode())
|
|||
def fake_urandom(n):
|
||||
|
||||
def gen(rounds):
|
||||
for i in range(rounds):
|
||||
for _ in range(rounds):
|
||||
rand_h.update(b'foo')
|
||||
yield rand_h.digest()
|
||||
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ class tool_cmd(tool_cmd_base):
|
|||
need_proto = True
|
||||
need_addrtype = True
|
||||
|
||||
def _init_generators(self,arg=None):
|
||||
def _init_generators(self):
|
||||
return generator_data(
|
||||
kg = KeyGenerator( self.cfg, self.proto, self.mmtype.pubkey_type ),
|
||||
ag = AddrGenerator( self.cfg, self.proto, self.mmtype ),
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue