tx.new, tw.ctl: minor Ethereum fixes
This commit is contained in:
parent
8c3c5858f5
commit
a73cb53ddc
7 changed files with 21 additions and 11 deletions
|
|
@ -67,7 +67,8 @@ class CoinAmt(Decimal,Hilite,InitErrors): # abstract class
|
|||
def to_unit(self,unit,show_decimal=False):
|
||||
ret = Decimal(self) // getattr(self,unit)
|
||||
if show_decimal and ret < 1:
|
||||
return f'{ret:.8f}'.rstrip('0')
|
||||
ret = f'{ret:.8f}'.rstrip('0')
|
||||
return ret + '0' if ret.endswith('.') else ret
|
||||
return int(ret)
|
||||
|
||||
@classmethod
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
May 2024
|
||||
June 2024
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
14.1.dev33
|
||||
14.1.dev34
|
||||
|
|
|
|||
|
|
@ -14,7 +14,8 @@ proto.btc.tx.new: Bitcoin new transaction class
|
|||
|
||||
from ....tx import new as TxBase
|
||||
from ....obj import MMGenTxID
|
||||
from ....util import msg,fmt,make_chksum_6,die
|
||||
from ....util import msg, fmt, make_chksum_6, die, suf
|
||||
from ....color import pink
|
||||
from .base import Base
|
||||
|
||||
class New(Base,TxBase.New):
|
||||
|
|
@ -29,6 +30,13 @@ class New(Base,TxBase.New):
|
|||
self.cfg._util.vmsg(f'Relay fee: {kb_fee} {self.coin}/kB, for transaction: {ret} {self.coin}')
|
||||
return ret
|
||||
|
||||
@property
|
||||
def network_estimated_fee_label(self):
|
||||
return 'Network-estimated ({}, {} conf{})'.format(
|
||||
self.cfg.fee_estimate_mode.upper(),
|
||||
pink(str(self.cfg.fee_estimate_confs)),
|
||||
suf(self.cfg.fee_estimate_confs))
|
||||
|
||||
async def get_rel_fee_from_network(self):
|
||||
try:
|
||||
ret = await self.rpc.call(
|
||||
|
|
|
|||
|
|
@ -109,6 +109,10 @@ class New(Base,TxBase.New):
|
|||
else:
|
||||
return [int(reply)]
|
||||
|
||||
@property
|
||||
def network_estimated_fee_label(self):
|
||||
return 'Network-estimated'
|
||||
|
||||
# get rel_fee (gas price) from network, return in native wei
|
||||
async def get_rel_fee_from_network(self):
|
||||
return Int(await self.rpc.call('eth_gasPrice'),16),'eth_gasPrice' # ==> rel_fee,fe_type
|
||||
|
|
|
|||
|
|
@ -73,15 +73,15 @@ class TwCtl(MMGenObject,metaclass=AsyncInit):
|
|||
self.importing = True
|
||||
mode = 'w'
|
||||
|
||||
if not no_rpc:
|
||||
self.rpc = await rpc_init(cfg, proto, ignore_wallet=rpc_ignore_wallet)
|
||||
|
||||
self.cfg = cfg
|
||||
self.proto = proto
|
||||
self.mode = mode
|
||||
self.desc = self.base_desc = f'{self.proto.name} tracking wallet'
|
||||
self.cur_balances = {} # cache balances to prevent repeated lookups per program invocation
|
||||
|
||||
if not no_rpc:
|
||||
self.rpc = await rpc_init(cfg, proto, ignore_wallet=rpc_ignore_wallet)
|
||||
|
||||
if self.use_tw_file:
|
||||
if self.proto.coin == 'BTC':
|
||||
self.tw_dir = Path(self.cfg.data_dir)
|
||||
|
|
|
|||
|
|
@ -159,10 +159,7 @@ class New(Base):
|
|||
desc = 'User-selected'
|
||||
start_fee = self.cfg.fee
|
||||
else:
|
||||
desc = 'Network-estimated ({}, {} conf{})'.format(
|
||||
self.cfg.fee_estimate_mode.upper(),
|
||||
pink(str(self.cfg.fee_estimate_confs)),
|
||||
suf(self.cfg.fee_estimate_confs) )
|
||||
desc = self.network_estimated_fee_label
|
||||
fee_per_kb,fe_type = await self.get_rel_fee_from_network()
|
||||
|
||||
if fee_per_kb < 0:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue