minor cleanups
This commit is contained in:
parent
36c6021ce2
commit
fb046dc076
4 changed files with 22 additions and 26 deletions
|
|
@ -1019,7 +1019,7 @@ class MMGenAddrType(str,Hilite,InitErrors,MMGenObject):
|
|||
'M': ati('monero', 'monero', False,'monero', 'monero', 'spendkey',('viewkey','wallet_passwd'),'Monero address'),
|
||||
}
|
||||
def __new__(cls,proto,id_str,errmsg=None):
|
||||
if type(id_str) == cls:
|
||||
if isinstance(id_str,cls):
|
||||
return id_str
|
||||
try:
|
||||
for k,v in cls.mmtypes.items():
|
||||
|
|
|
|||
21
mmgen/tx.py
21
mmgen/tx.py
|
|
@ -260,12 +260,6 @@ class MMGenTxInputList(MMGenTxIOList):
|
|||
desc = 'transaction inputs'
|
||||
member_type = 'MMGenTxInput'
|
||||
|
||||
# def convert_coin(self,verbose=False):
|
||||
# if verbose:
|
||||
# msg(f'{self.desc}:')
|
||||
# for i in self:
|
||||
# i.amt = self.parent.proto.coin_amt(i.amt)
|
||||
|
||||
# Lexicographical Indexing of Transaction Inputs and Outputs
|
||||
# https://github.com/bitcoin/bips/blob/master/bip-0069.mediawiki
|
||||
def sort_bip69(self):
|
||||
|
|
@ -305,10 +299,10 @@ class MMGenTX:
|
|||
rel_fee_disp = 'sat/byte'
|
||||
non_mmgen_inputs_msg = f"""
|
||||
This transaction includes inputs with non-{g.proj_name} addresses. When
|
||||
signing the transaction, private keys for the addresses must be supplied using
|
||||
the --keys-from-file option. The key file must contain one key per line.
|
||||
Please note that this transaction cannot be autosigned, as autosigning does
|
||||
not support the use of key files.
|
||||
signing the transaction, private keys for the addresses listed below must
|
||||
be supplied using the --keys-from-file option. The key file must contain
|
||||
one key per line. Please note that this transaction cannot be autosigned,
|
||||
as autosigning does not support the use of key files.
|
||||
|
||||
Non-{g.proj_name} addresses found in inputs:
|
||||
{{}}
|
||||
|
|
@ -503,13 +497,14 @@ class MMGenTX:
|
|||
def check_non_mmgen_inputs(self,caller,non_mmaddrs=None):
|
||||
non_mmaddrs = non_mmaddrs or self.get_non_mmaddrs('inputs')
|
||||
if non_mmaddrs:
|
||||
fs = fmt(self.non_mmgen_inputs_msg,strip_char='\t')
|
||||
indent = ' '
|
||||
fs = fmt(self.non_mmgen_inputs_msg,strip_char='\t',indent=indent).strip()
|
||||
m = fs.format('\n '.join(non_mmaddrs))
|
||||
if caller in ('txdo','txsign'):
|
||||
if not opt.keys_from_file:
|
||||
raise UserOptError('ERROR: ' + m)
|
||||
raise UserOptError(f'\n{indent}ERROR: {m}\n')
|
||||
else:
|
||||
msg('WARNING: ' + m)
|
||||
msg(f'\n{indent}WARNING: {m}\n')
|
||||
if not (opt.yes or keypress_confirm('Continue?',default_yes=True)):
|
||||
die(1,'Exiting at user request')
|
||||
|
||||
|
|
|
|||
|
|
@ -154,13 +154,13 @@ async def txsign(tx,seed_files,kl,kal,tx_num_str=''):
|
|||
addrlist = non_mmaddrs,
|
||||
skip_chksum = True )
|
||||
tmp.add_wifs(kl)
|
||||
m = tmp.list_missing('sec')
|
||||
if m:
|
||||
die(2, fmt("""
|
||||
ERROR: a key file must be supplied for the following non-{} address{}:
|
||||
{{}}
|
||||
""".format( g.proj_name, suf(m,'es'), '\n '.join(m) ),
|
||||
strip_char='\t').strip() )
|
||||
missing = tmp.list_missing('sec')
|
||||
if missing:
|
||||
sep = '\n '
|
||||
die(2,'ERROR: a key file must be supplied for the following non-{} address{}:{}'.format(
|
||||
g.proj_name,
|
||||
suf(missing,'es'),
|
||||
sep + sep.join(missing) ))
|
||||
keys += tmp.data
|
||||
|
||||
if opt.mmgen_keys_from_file:
|
||||
|
|
|
|||
|
|
@ -808,17 +808,18 @@ def my_raw_input(prompt,echo=True,insert_txt='',use_readline=True):
|
|||
|
||||
def keypress_confirm(prompt,default_yes=False,verbose=False,no_nl=False,complete_prompt=False):
|
||||
|
||||
q = ('(y/N)','(Y/n)')[bool(default_yes)]
|
||||
p = prompt if complete_prompt else f'{prompt} {q}: '
|
||||
nl = ('\n','\r{}\r'.format(' '*len(p)))[no_nl]
|
||||
if not complete_prompt:
|
||||
prompt = '{} {}: '.format( prompt, '(Y/n)' if default_yes else '(y/N)' )
|
||||
|
||||
nl = f'\r{" "*len(prompt)}\r' if no_nl else '\n'
|
||||
|
||||
if g.accept_defaults:
|
||||
msg(p)
|
||||
msg(prompt)
|
||||
return default_yes
|
||||
|
||||
from .term import get_char
|
||||
while True:
|
||||
reply = get_char(p,immed_chars='yYnN').strip('\n\r')
|
||||
reply = get_char(prompt,immed_chars='yYnN').strip('\n\r')
|
||||
if not reply:
|
||||
msg_r(nl)
|
||||
return True if default_yes else False
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue