use estimatesmartfee if the daemon supports it
This commit is contained in:
parent
d457259fcf
commit
6aca0f2986
3 changed files with 25 additions and 7 deletions
|
|
@ -168,6 +168,7 @@ class CoinDaemonRPCConnection(object):
|
|||
'decoderawtransaction',
|
||||
'disconnectnode',
|
||||
'estimatefee',
|
||||
'estimatesmartfee',
|
||||
'getaddressesbyaccount',
|
||||
'getbalance',
|
||||
'getblock',
|
||||
|
|
|
|||
19
mmgen/tx.py
19
mmgen/tx.py
|
|
@ -1049,16 +1049,25 @@ class MMGenTX(MMGenObject):
|
|||
start_fee = opt.tx_fee
|
||||
else:
|
||||
desc = 'Network-estimated'
|
||||
ret = g.rpch.estimatefee(opt.tx_confs)
|
||||
if ret == -1:
|
||||
try:
|
||||
ret = g.rpch.estimatesmartfee(opt.tx_confs,on_fail='raise')
|
||||
except:
|
||||
fetype = 'estimatefee'
|
||||
fee_per_kb = g.rpch.estimatefee(opt.tx_confs)
|
||||
else:
|
||||
fetype = 'estimatesmartfee'
|
||||
fee_per_kb = ret['feerate'] if 'feerate' in ret else -2
|
||||
|
||||
if fee_per_kb < 0:
|
||||
if not have_estimate_fail:
|
||||
msg('Network fee estimation for {} confirmations failed'.format(opt.tx_confs))
|
||||
msg('Network fee estimation for {} confirmations failed ({})'.format(opt.tx_confs,fetype))
|
||||
have_estimate_fail.append(True)
|
||||
start_fee = None
|
||||
else:
|
||||
start_fee = g.proto.coin_amt(ret) * opt.tx_fee_adj * self.estimate_size() / 1024
|
||||
start_fee = g.proto.coin_amt(fee_per_kb) * opt.tx_fee_adj * self.estimate_size() / 1024
|
||||
if opt.verbose:
|
||||
msg('{} fee ({} confs): {} {}/kB'.format(desc,opt.tx_confs,ret,g.coin))
|
||||
msg('{} fee for {} confirmations: {} {}/kB'.format(
|
||||
fetype.upper(),opt.tx_confs,fee_per_kb,g.coin))
|
||||
msg('TX size (estimated): {}'.format(self.estimate_size()))
|
||||
|
||||
return self.get_usr_fee_interactive(start_fee,desc=desc)
|
||||
|
|
|
|||
12
test/test.py
12
test/test.py
|
|
@ -685,6 +685,7 @@ cmd_group['regtest'] = (
|
|||
('regtest_alice_chk_label3', 'the label'),
|
||||
('regtest_alice_remove_label1','removing a label'),
|
||||
('regtest_alice_chk_label4', 'the label'),
|
||||
('regtest_alice_send_estimatefee','tx creation with no fee on command line'),
|
||||
('regtest_stop', 'stopping regtest daemon'),
|
||||
)
|
||||
|
||||
|
|
@ -2326,13 +2327,16 @@ class MMGenTestSuite(object):
|
|||
bad_locktime=False):
|
||||
os.environ['MMGEN_BOGUS_SEND'] = ''
|
||||
t = MMGenExpect(name,'mmgen-txdo',
|
||||
['-d',cfg['tmpdir'],'-B','--'+user,'--tx-fee='+fee]
|
||||
+ extra_args + ([],[wf])[bool(wf)] + outputs_cl)
|
||||
['-d',cfg['tmpdir'],'-B','--'+user] +
|
||||
(['--tx-fee='+fee] if fee else []) +
|
||||
extra_args + ([],[wf])[bool(wf)] + outputs_cl)
|
||||
os.environ['MMGEN_BOGUS_SEND'] = '1'
|
||||
|
||||
t.expect(r"'q'=quit view, .*?:.",'M',regex=True) # sort by mmid
|
||||
t.expect(r"'q'=quit view, .*?:.",'q',regex=True)
|
||||
t.expect('outputs to spend: ',outputs_prompt+'\n')
|
||||
if not fee:
|
||||
t.expect('Enter transaction fee: ','{}\n'.format(tx_fee))
|
||||
t.expect('OK? (Y/n): ','y') # fee OK?
|
||||
t.expect('OK? (Y/n): ','y') # change OK?
|
||||
if do_label:
|
||||
|
|
@ -2389,6 +2393,10 @@ class MMGenTestSuite(object):
|
|||
fn = os.path.join(cfg['tmpdir'],'non-mmgen.keys')
|
||||
return self.regtest_user_txdo(name,'bob',rtFee[3],outputs_cl,'3-9',extra_args=['--keys-from-file='+fn])
|
||||
|
||||
def regtest_alice_send_estimatefee(self,name):
|
||||
outputs_cl = self.create_tx_outputs('bob',(('L',1,''),)) # bob_sid:L:1
|
||||
return self.regtest_user_txdo(name,'alice',None,outputs_cl,'1') # fee=None
|
||||
|
||||
def regtest_user_txbump(self,name,user,txfile,fee,red_op,no_send=False):
|
||||
if not g.proto.cap('rbf'):
|
||||
msg('Skipping RBF'); return True
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue