txcreate,txbump: add 'fee_estimate_mode' option
This commit is contained in:
parent
3db1c423ef
commit
9c0157e0e9
5 changed files with 36 additions and 5 deletions
|
|
@ -198,6 +198,9 @@ class g(object):
|
|||
'MMGEN_DISABLE_COLOR',
|
||||
'MMGEN_DISABLE_MSWIN_PW_WARNING',
|
||||
)
|
||||
opt_values = { # first value is used as default
|
||||
'fee_estimate_mode': ('nocase_str', ('conservative','economical')),
|
||||
}
|
||||
|
||||
min_screen_width = 80
|
||||
minconf = 1
|
||||
|
|
|
|||
|
|
@ -37,6 +37,8 @@ opts_data = {
|
|||
-C, --tx-confs= c Desired number of confirmations (default: {g.tx_confs})
|
||||
-d, --outdir= d Specify an alternate directory 'd' for output
|
||||
-D, --contract-data=D Path to hex-encoded contract data (ETH only)
|
||||
-E, --fee-estimate-mode=M Specify the network fee estimate mode. Choices:
|
||||
'{fec}'. Default: '{fe}'
|
||||
-f, --tx-fee= f Transaction fee, as a decimal {cu} amount or as
|
||||
{fu} (an integer followed by {fl}).
|
||||
See FEE SPECIFICATION below. If omitted, fee will be
|
||||
|
|
@ -63,6 +65,8 @@ opts_data = {
|
|||
fu=help_notes('rel_fee_desc'),
|
||||
fl=help_notes('fee_spec_letters'),
|
||||
cu=g.coin,
|
||||
fec="','".join(g.opt_values['fee_estimate_mode'][1]),
|
||||
fe=g.opt_values['fee_estimate_mode'][1][0],
|
||||
g=g),
|
||||
'notes': lambda s: s.format(
|
||||
help_notes('txcreate'),
|
||||
|
|
|
|||
|
|
@ -41,6 +41,8 @@ opts_data = {
|
|||
-d, --outdir= d Specify an alternate directory 'd' for output
|
||||
-D, --contract-data= D Path to hex-encoded contract data (ETH only)
|
||||
-e, --echo-passphrase Print passphrase to screen when typing it
|
||||
-E, --fee-estimate-mode=M Specify the network fee estimate mode. Choices:
|
||||
'{fec}'. Default: '{fe}'
|
||||
-f, --tx-fee= f Transaction fee, as a decimal {cu} amount or as
|
||||
{fu} (an integer followed by {fl}).
|
||||
See FEE SPECIFICATION below. If omitted, fee will be
|
||||
|
|
@ -97,6 +99,8 @@ column below:
|
|||
fu=help_notes('rel_fee_desc'),
|
||||
fl=help_notes('fee_spec_letters'),
|
||||
ss=g.subseeds,ss_max=SubSeedIdxRange.max_idx,
|
||||
fec="','".join(g.opt_values['fee_estimate_mode'][1]),
|
||||
fe=g.opt_values['fee_estimate_mode'][1][0],
|
||||
kg=g.key_generator,
|
||||
cu=g.coin),
|
||||
'notes': lambda s: s.format(
|
||||
|
|
|
|||
|
|
@ -332,6 +332,10 @@ def init(opts_data,add_opts=[],opt_filter=None,parse_only=False):
|
|||
if not check_opts(uopts):
|
||||
die(1,'Options checking failed')
|
||||
|
||||
# Check user-set opts against g.opt_values, setting opt if unset:
|
||||
if not check_opts2(uopts):
|
||||
die(1,'Options checking failed')
|
||||
|
||||
if hasattr(g,'cfg_options_changed'):
|
||||
ymsg("Warning: config file options have changed! See '{}' for details".format(g.cfg_file+'.sample'))
|
||||
from mmgen.util import my_raw_input
|
||||
|
|
@ -366,7 +370,23 @@ def opt_is_tx_fee(val,desc):
|
|||
return True
|
||||
return False
|
||||
|
||||
def check_opts(usr_opts): # Returns false if any check fails
|
||||
def check_opts2(usr_opts): # Returns false if any check fails
|
||||
|
||||
for key in [e for e in opt.__dict__ if not e.startswith('__')]:
|
||||
if key in g.opt_values:
|
||||
val = getattr(opt,key)
|
||||
d = g.opt_values[key]
|
||||
if d[0] == 'nocase_str':
|
||||
if val == None:
|
||||
setattr(opt,key,d[1][0])
|
||||
elif val.lower() not in d[1]:
|
||||
m = "{!r}: invalid parameter for option --{} (valid choices: '{}')"
|
||||
msg(m.format(val,key.replace('_','-'),"', '".join(d[1])))
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
def check_opts(usr_opts): # Returns false if any check fails
|
||||
|
||||
def opt_splits(val,sep,n,desc):
|
||||
sepword = 'comma' if sep == ',' else 'colon' if sep == ':' else "'{}'".format(sep)
|
||||
|
|
|
|||
|
|
@ -534,7 +534,7 @@ Selected non-{pnm} inputs: {{}}""".strip().format(pnm=g.proj_name,pnl=g.proj_nam
|
|||
|
||||
def get_rel_fee_from_network(self):
|
||||
try:
|
||||
ret = g.rpch.estimatesmartfee(opt.tx_confs)
|
||||
ret = g.rpch.estimatesmartfee(opt.tx_confs,opt.fee_estimate_mode.upper())
|
||||
fee_per_kb = ret['feerate'] if 'feerate' in ret else -2
|
||||
fe_type = 'estimatesmartfee'
|
||||
except:
|
||||
|
|
@ -607,10 +607,10 @@ Selected non-{pnm} inputs: {{}}""".strip().format(pnm=g.proj_name,pnl=g.proj_nam
|
|||
if tx_fee:
|
||||
abs_fee = self.convert_and_check_fee(tx_fee,desc)
|
||||
if abs_fee:
|
||||
adj_disp = ' (after {}X adjustment)'.format(opt.tx_fee_adj)
|
||||
p = '{} TX fee{}: {}{} {} ({} {})\n'.format(
|
||||
desc,
|
||||
adj_disp if opt.tx_fee_adj != 1 and desc == 'Network-estimated' else '',
|
||||
('',' (after {}X adjustment)'.format(opt.tx_fee_adj))[
|
||||
opt.tx_fee_adj != 1 and desc.startswith('Network-estimated')],
|
||||
('','≈')[self.fee_is_approximate],
|
||||
abs_fee.hl(),
|
||||
g.coin,
|
||||
|
|
@ -628,7 +628,7 @@ Selected non-{pnm} inputs: {{}}""".strip().format(pnm=g.proj_name,pnl=g.proj_nam
|
|||
desc = 'User-selected'
|
||||
start_fee = opt.tx_fee
|
||||
else:
|
||||
desc = 'Network-estimated'
|
||||
desc = 'Network-estimated (mode: {})'.format(opt.fee_estimate_mode.upper())
|
||||
fee_per_kb,fe_type = self.get_rel_fee_from_network()
|
||||
|
||||
if fee_per_kb < 0:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue