move tracking wallet modules to tw and base_proto/{name}/tw
This commit is contained in:
parent
152901143c
commit
0fef35f567
36 changed files with 113 additions and 107 deletions
|
|
@ -20,7 +20,7 @@
|
|||
addrdata.py: MMGen AddrData and related classes
|
||||
"""
|
||||
|
||||
from .util import vmsg,base_proto_subclass,fmt,die
|
||||
from .util import vmsg,base_proto_tw_subclass,fmt,die
|
||||
from .base_obj import AsyncInit
|
||||
from .obj import MMGenObject,MMGenDict,get_obj
|
||||
from .addr import MMGenID,AddrListID
|
||||
|
|
@ -69,11 +69,11 @@ class AddrData(MMGenObject):
|
|||
class TwAddrData(AddrData,metaclass=AsyncInit):
|
||||
|
||||
def __new__(cls,proto,*args,**kwargs):
|
||||
return MMGenObject.__new__(base_proto_subclass(cls,proto,'tw'))
|
||||
return MMGenObject.__new__(base_proto_tw_subclass(cls,proto,'common'))
|
||||
|
||||
async def __init__(self,proto,wallet=None):
|
||||
from .rpc import rpc_init
|
||||
from .tw import TwLabel
|
||||
from .tw.common import TwLabel
|
||||
from .globalvars import g
|
||||
from .seed import SeedID
|
||||
self.proto = proto
|
||||
|
|
|
|||
0
mmgen/base_proto/bitcoin/tw/__init__.py
Executable file
0
mmgen/base_proto/bitcoin/tw/__init__.py
Executable file
|
|
@ -12,12 +12,12 @@
|
|||
base_proto.bitcoin.twaddrs: Bitcoin base protocol tracking wallet address list class
|
||||
"""
|
||||
|
||||
from ...twaddrs import TwAddrList
|
||||
from ...util import msg,die
|
||||
from ...obj import MMGenList
|
||||
from ...addr import CoinAddr
|
||||
from ...rpc import rpc_init
|
||||
from ...tw import get_tw_label
|
||||
from ....util import msg,die
|
||||
from ....obj import MMGenList
|
||||
from ....addr import CoinAddr
|
||||
from ....rpc import rpc_init
|
||||
from ....tw.addrs import TwAddrList
|
||||
from ....tw.common import get_tw_label
|
||||
|
||||
class BitcoinTwAddrList(TwAddrList):
|
||||
|
||||
|
|
@ -12,8 +12,8 @@
|
|||
base_proto.bitcoin.twbal: Bitcoin base protocol tracking wallet balance class
|
||||
"""
|
||||
|
||||
from ...twbal import TwGetBalance
|
||||
from ...tw import get_tw_label
|
||||
from ....tw.bal import TwGetBalance
|
||||
from ....tw.common import get_tw_label
|
||||
|
||||
class BitcoinTwGetBalance(TwGetBalance):
|
||||
|
||||
|
|
@ -12,8 +12,8 @@
|
|||
base_proto.bitcoin.tw: Bitcoin base protocol tracking wallet dependency classes
|
||||
"""
|
||||
|
||||
from ...addrdata import TwAddrData
|
||||
from ...util import vmsg
|
||||
from ....addrdata import TwAddrData
|
||||
from ....util import vmsg
|
||||
|
||||
class BitcoinTwAddrData(TwAddrData):
|
||||
|
||||
|
|
@ -12,8 +12,8 @@
|
|||
base_proto.bitcoin.twctl: Bitcoin base protocol tracking wallet control class
|
||||
"""
|
||||
|
||||
from ...twctl import TrackingWallet
|
||||
from ...util import rmsg,write_mode
|
||||
from ....tw.ctl import TrackingWallet
|
||||
from ....util import rmsg,write_mode
|
||||
|
||||
class BitcoinTrackingWallet(TrackingWallet):
|
||||
|
||||
|
|
@ -12,8 +12,8 @@
|
|||
base_proto.bitcoin.twuo: Bitcoin base protocol tracking wallet unspent outputs class
|
||||
"""
|
||||
|
||||
from ...twuo import TwUnspentOutputs
|
||||
from ...addr import CoinAddr
|
||||
from ....tw.unspent import TwUnspentOutputs
|
||||
from ....addr import CoinAddr
|
||||
|
||||
class BitcoinTwUnspentOutputs(TwUnspentOutputs):
|
||||
|
||||
0
mmgen/base_proto/ethereum/tw/__init__.py
Executable file
0
mmgen/base_proto/ethereum/tw/__init__.py
Executable file
|
|
@ -20,7 +20,7 @@
|
|||
base_proto.ethereum.twaddrs: Ethereum tracking wallet address list class
|
||||
"""
|
||||
|
||||
from ...twaddrs import TwAddrList
|
||||
from ....tw.addrs import TwAddrList
|
||||
|
||||
class EthereumTwAddrList(TwAddrList):
|
||||
|
||||
|
|
@ -28,9 +28,9 @@ class EthereumTwAddrList(TwAddrList):
|
|||
|
||||
async def __init__(self,proto,usr_addr_list,minconf,showempty,showbtcaddrs,all_labels,wallet=None):
|
||||
|
||||
from ...tw import TwLabel
|
||||
from ...twctl import TrackingWallet
|
||||
from ...addr import CoinAddr
|
||||
from ....tw.common import TwLabel
|
||||
from ....tw.ctl import TrackingWallet
|
||||
from ....addr import CoinAddr
|
||||
|
||||
self.proto = proto
|
||||
self.wallet = wallet or await TrackingWallet(self.proto,mode='w')
|
||||
|
|
@ -20,8 +20,8 @@
|
|||
base_proto.ethereum.twbal: Ethereum tracking wallet getbalance class
|
||||
"""
|
||||
|
||||
from ...twctl import TrackingWallet
|
||||
from ...twbal import TwGetBalance
|
||||
from ....tw.ctl import TrackingWallet
|
||||
from ....tw.bal import TwGetBalance
|
||||
|
||||
class EthereumTwGetBalance(TwGetBalance):
|
||||
|
||||
|
|
@ -20,8 +20,8 @@
|
|||
base_proto.ethereum.tw: Ethereum tracking wallet dependency classes
|
||||
"""
|
||||
|
||||
from ...addrdata import TwAddrData
|
||||
from ...util import vmsg
|
||||
from ....addrdata import TwAddrData
|
||||
from ....util import vmsg
|
||||
|
||||
class EthereumTwAddrData(TwAddrData):
|
||||
|
||||
|
|
@ -33,8 +33,8 @@ class EthereumTwAddrData(TwAddrData):
|
|||
}
|
||||
|
||||
async def get_tw_data(self,wallet=None):
|
||||
from ...twctl import TrackingWallet
|
||||
from ...util import vmsg
|
||||
from ....tw.ctl import TrackingWallet
|
||||
from ....util import vmsg
|
||||
vmsg('Getting address data from tracking wallet')
|
||||
tw = (wallet or await TrackingWallet(self.proto)).mmid_ordered_dict
|
||||
# emulate the output of RPC 'listaccounts' and 'getaddressesbyaccount'
|
||||
|
|
@ -20,11 +20,11 @@
|
|||
base_proto.ethereum.twctl: Ethereum tracking wallet control class
|
||||
"""
|
||||
|
||||
from ...util import msg,ymsg,write_mode,die
|
||||
from ...twctl import TrackingWallet
|
||||
from ...addr import is_coin_addr,is_mmgen_id
|
||||
from ...amt import ETHAmt
|
||||
from .contract import Token,TokenResolve
|
||||
from ....util import msg,ymsg,write_mode,die
|
||||
from ....tw.ctl import TrackingWallet
|
||||
from ....addr import is_coin_addr,is_mmgen_id
|
||||
from ....amt import ETHAmt
|
||||
from ..contract import Token,TokenResolve
|
||||
|
||||
class EthereumTrackingWallet(TrackingWallet):
|
||||
|
||||
|
|
@ -167,7 +167,7 @@ class EthereumTokenTrackingWallet(EthereumTrackingWallet):
|
|||
if not is_coin_addr(proto,token_addr):
|
||||
die( 'UnrecognizedTokenSymbol', f'Specified token {proto.tokensym!r} could not be resolved!' )
|
||||
|
||||
from ...addr import TokenAddr
|
||||
from ....addr import TokenAddr
|
||||
self.token = TokenAddr(proto,token_addr)
|
||||
|
||||
if self.token not in self.data['tokens']:
|
||||
|
|
@ -20,8 +20,8 @@
|
|||
base_proto.ethereum.twuo: Ethereum tracking wallet unspent outputs class
|
||||
"""
|
||||
|
||||
from ...tw import TwLabel
|
||||
from ...twuo import TwUnspentOutputs
|
||||
from ....tw.common import TwLabel
|
||||
from ....tw.unspent import TwUnspentOutputs
|
||||
|
||||
# No unspent outputs with Ethereum, but naming must be consistent
|
||||
class EthereumTwUnspentOutputs(TwUnspentOutputs):
|
||||
|
|
@ -53,9 +53,9 @@ Actions: [q]uit view, [p]rint to file, pager [v]iew, [w]ide view,
|
|||
display_hdr_fs_fs = display_fs_fs
|
||||
|
||||
async def __init__(self,proto,*args,**kwargs):
|
||||
from ...globalvars import g
|
||||
from ....globalvars import g
|
||||
if g.cached_balances:
|
||||
from ...color import yellow
|
||||
from ....color import yellow
|
||||
self.hdr_fmt += '\n' + yellow('WARNING: Using cached balances. These may be out of date!')
|
||||
await super().__init__(proto,*args,**kwargs)
|
||||
|
||||
|
|
@ -20,7 +20,7 @@ from ....opts import opt
|
|||
from ....obj import Int,ETHNonce,MMGenTxID,Str
|
||||
from ....amt import ETHAmt
|
||||
from ....util import msg,line_input,is_int,is_hex_str,make_chksum_6
|
||||
from ....twctl import TrackingWallet
|
||||
from ....tw.ctl import TrackingWallet
|
||||
from ....addr import is_mmgen_id,is_coin_addr
|
||||
from ..contract import Token
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ import time
|
|||
|
||||
from .common import *
|
||||
from .addrlist import AddrList,KeyAddrList
|
||||
from .tw import TwLabel
|
||||
from .tw.common import TwLabel
|
||||
|
||||
ai_msgs = lambda k: {
|
||||
'rescan': """
|
||||
|
|
@ -158,9 +158,9 @@ def make_args_list(tw,al,batch,rescan):
|
|||
yield (tw,e.addr,TwLabel(proto,label),rescan,fs,msg_args)
|
||||
|
||||
async def main():
|
||||
from .twctl import TrackingWallet
|
||||
from .tw.ctl import TrackingWallet
|
||||
if opt.token_addr:
|
||||
proto.tokensym = 'foo' # hack to trigger 'Token' in base_proto_subclass()
|
||||
proto.tokensym = 'foo' # hack to trigger 'Token' in base_proto_tw_subclass()
|
||||
|
||||
tw = await TrackingWallet(
|
||||
proto = proto,
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ async def main():
|
|||
kl = get_keylist(orig_tx.proto,opt)
|
||||
sign_and_send = bool(seed_files or kl or kal)
|
||||
|
||||
from .twctl import TrackingWallet
|
||||
from .tw.ctl import TrackingWallet
|
||||
tx = await BumpTX(
|
||||
data = orig_tx.__dict__,
|
||||
send = sign_and_send,
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ async def main():
|
|||
proto = init_proto_from_opts(need_amt=True)
|
||||
|
||||
from .tx import NewTX
|
||||
from .twctl import TrackingWallet
|
||||
from .tw.ctl import TrackingWallet
|
||||
tx1 = await NewTX(proto=proto)
|
||||
|
||||
from .rpc import rpc_init
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ from .txsign import *
|
|||
seed_files = get_seed_files(opt,cmd_args)
|
||||
|
||||
async def main():
|
||||
from .twctl import TrackingWallet
|
||||
from .tw.ctl import TrackingWallet
|
||||
|
||||
from .protocol import init_proto_from_opts
|
||||
proto = init_proto_from_opts(need_amt=True)
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ tool/rpc.py: JSON/RPC routines for the 'mmgen-tool' utility
|
|||
"""
|
||||
|
||||
from .common import tool_cmd_base,options_annot_str
|
||||
from ..tw import TwCommon
|
||||
from ..tw.common import TwCommon
|
||||
|
||||
class tool_cmd(tool_cmd_base):
|
||||
"tracking wallet commands using the JSON-RPC interface"
|
||||
|
|
@ -37,7 +37,7 @@ class tool_cmd(tool_cmd_base):
|
|||
|
||||
async def getbalance(self,minconf=1,quiet=False,pager=False):
|
||||
"list confirmed/unconfirmed, spendable/unspendable balances in tracking wallet"
|
||||
from ..twbal import TwGetBalance
|
||||
from ..tw.bal import TwGetBalance
|
||||
return (await TwGetBalance(self.proto,minconf,quiet)).format()
|
||||
|
||||
async def listaddress(self,
|
||||
|
|
@ -89,7 +89,7 @@ class tool_cmd(tool_cmd_base):
|
|||
from ..addrlist import AddrIdxList
|
||||
usr_addr_list = [MMGenID(self.proto,f'{a[0]}:{i}') for i in AddrIdxList(a[1])]
|
||||
|
||||
from ..twaddrs import TwAddrList
|
||||
from ..tw.addrs import TwAddrList
|
||||
al = await TwAddrList( self.proto, usr_addr_list, minconf, showempty, showbtcaddrs, all_labels )
|
||||
if not al:
|
||||
from ..util import die
|
||||
|
|
@ -107,7 +107,7 @@ class tool_cmd(tool_cmd_base):
|
|||
wide_show_confs = True ):
|
||||
"view tracking wallet"
|
||||
|
||||
from ..twuo import TwUnspentOutputs
|
||||
from ..tw.unspent import TwUnspentOutputs
|
||||
twuo = await TwUnspentOutputs(self.proto,minconf=minconf)
|
||||
await twuo.get_unspent_data(reverse_sort=reverse)
|
||||
twuo.age_fmt = age_fmt
|
||||
|
|
@ -121,7 +121,7 @@ class tool_cmd(tool_cmd_base):
|
|||
|
||||
async def add_label(self,mmgen_or_coin_addr:str,label:str):
|
||||
"add descriptive label for address in tracking wallet"
|
||||
from ..twctl import TrackingWallet
|
||||
from ..tw.ctl import TrackingWallet
|
||||
await (await TrackingWallet(self.proto,mode='w')).add_label( mmgen_or_coin_addr, label, on_fail='raise' )
|
||||
return True
|
||||
|
||||
|
|
@ -132,7 +132,7 @@ class tool_cmd(tool_cmd_base):
|
|||
|
||||
async def remove_address(self,mmgen_or_coin_addr:str):
|
||||
"remove an address from tracking wallet"
|
||||
from ..twctl import TrackingWallet
|
||||
from ..tw.ctl import TrackingWallet
|
||||
ret = await (await TrackingWallet(self.proto,mode='w')).remove_address(mmgen_or_coin_addr) # returns None on failure
|
||||
if ret:
|
||||
from ..util import msg
|
||||
|
|
|
|||
0
mmgen/tw/__init__.py
Executable file
0
mmgen/tw/__init__.py
Executable file
|
|
@ -20,17 +20,17 @@
|
|||
twaddrs: Tracking wallet listaddresses class for the MMGen suite
|
||||
"""
|
||||
|
||||
from .color import green
|
||||
from .util import msg,die,base_proto_subclass
|
||||
from .base_obj import AsyncInit
|
||||
from .obj import MMGenDict,TwComment
|
||||
from .addr import CoinAddr,MMGenID
|
||||
from .tw import TwCommon
|
||||
from ..color import green
|
||||
from ..util import msg,die,base_proto_tw_subclass
|
||||
from ..base_obj import AsyncInit
|
||||
from ..obj import MMGenDict,TwComment
|
||||
from ..addr import CoinAddr,MMGenID
|
||||
from .common import TwCommon
|
||||
|
||||
class TwAddrList(MMGenDict,TwCommon,metaclass=AsyncInit):
|
||||
|
||||
def __new__(cls,proto,*args,**kwargs):
|
||||
return MMGenDict.__new__(base_proto_subclass(cls,proto,'twaddrs'),*args,**kwargs)
|
||||
return MMGenDict.__new__(base_proto_tw_subclass(cls,proto,'addrs'),*args,**kwargs)
|
||||
|
||||
def raw_list(self):
|
||||
return [((k if k.type == 'mmgen' else 'Non-MMGen'),self[k]['addr'],self[k]['amt']) for k in self]
|
||||
|
|
@ -20,16 +20,16 @@
|
|||
twbal: Tracking wallet getbalance class for the MMGen suite
|
||||
"""
|
||||
|
||||
from .color import red,green
|
||||
from .util import base_proto_subclass
|
||||
from .base_obj import AsyncInit
|
||||
from .objmethods import MMGenObject
|
||||
from .rpc import rpc_init
|
||||
from ..color import red,green
|
||||
from ..util import base_proto_tw_subclass
|
||||
from ..base_obj import AsyncInit
|
||||
from ..objmethods import MMGenObject
|
||||
from ..rpc import rpc_init
|
||||
|
||||
class TwGetBalance(MMGenObject,metaclass=AsyncInit):
|
||||
|
||||
def __new__(cls,proto,*args,**kwargs):
|
||||
return MMGenObject.__new__(base_proto_subclass(cls,proto,'twbal'))
|
||||
return MMGenObject.__new__(base_proto_tw_subclass(cls,proto,'bal'))
|
||||
|
||||
async def __init__(self,proto,minconf,quiet):
|
||||
|
||||
|
|
@ -22,9 +22,9 @@ tw: Tracking wallet dependency classes and helper functions
|
|||
|
||||
import time
|
||||
|
||||
from .objmethods import Hilite,InitErrors,MMGenObject
|
||||
from .obj import TwComment
|
||||
from .addr import MMGenID
|
||||
from ..objmethods import Hilite,InitErrors,MMGenObject
|
||||
from ..obj import TwComment
|
||||
from ..addr import MMGenID
|
||||
|
||||
# mixin class for TwUnspentOutputs,TwAddrList:
|
||||
class TwCommon:
|
||||
|
|
@ -20,14 +20,14 @@
|
|||
twctl: Tracking wallet control class for the MMGen suite
|
||||
"""
|
||||
|
||||
from .globalvars import g
|
||||
from .util import msg,dmsg,write_mode,base_proto_subclass,die
|
||||
from .base_obj import AsyncInit
|
||||
from .objmethods import MMGenObject
|
||||
from .obj import TwComment,get_obj
|
||||
from .addr import CoinAddr,is_mmgen_id,is_coin_addr
|
||||
from .rpc import rpc_init
|
||||
from .tw import TwMMGenID,TwLabel
|
||||
from ..globalvars import g
|
||||
from ..util import msg,dmsg,write_mode,base_proto_tw_subclass,die
|
||||
from ..base_obj import AsyncInit
|
||||
from ..objmethods import MMGenObject
|
||||
from ..obj import TwComment,get_obj
|
||||
from ..addr import CoinAddr,is_mmgen_id,is_coin_addr
|
||||
from ..rpc import rpc_init
|
||||
from .common import TwMMGenID,TwLabel
|
||||
|
||||
class TrackingWallet(MMGenObject,metaclass=AsyncInit):
|
||||
|
||||
|
|
@ -38,7 +38,7 @@ class TrackingWallet(MMGenObject,metaclass=AsyncInit):
|
|||
importing = False
|
||||
|
||||
def __new__(cls,proto,*args,**kwargs):
|
||||
return MMGenObject.__new__(base_proto_subclass(cls,proto,'twctl'))
|
||||
return MMGenObject.__new__(base_proto_tw_subclass(cls,proto,'ctl'))
|
||||
|
||||
async def __init__(self,proto,mode='r',token_addr=None):
|
||||
|
||||
|
|
@ -81,7 +81,7 @@ class TrackingWallet(MMGenObject,metaclass=AsyncInit):
|
|||
))
|
||||
self.tw_fn = os.path.join(tw_dir,'tracking-wallet.json')
|
||||
|
||||
from .fileutil import check_or_create_dir,get_data_from_file
|
||||
from ..fileutil import check_or_create_dir,get_data_from_file
|
||||
check_or_create_dir(tw_dir)
|
||||
|
||||
try:
|
||||
|
|
@ -185,7 +185,7 @@ class TrackingWallet(MMGenObject,metaclass=AsyncInit):
|
|||
|
||||
@write_mode
|
||||
def write_changed(self,data):
|
||||
from .fileutil import write_data_to_file
|
||||
from ..fileutil import write_data_to_file
|
||||
write_data_to_file(
|
||||
self.tw_fn,
|
||||
data,
|
||||
|
|
@ -216,7 +216,7 @@ class TrackingWallet(MMGenObject,metaclass=AsyncInit):
|
|||
msg('Data is unchanged\n')
|
||||
|
||||
async def is_in_wallet(self,addr):
|
||||
from .twaddrs import TwAddrList
|
||||
from .addrs import TwAddrList
|
||||
return addr in (await TwAddrList(self.proto,[],0,True,True,True,wallet=self)).coinaddr_list()
|
||||
|
||||
# returns on failure
|
||||
|
|
@ -230,7 +230,7 @@ class TrackingWallet(MMGenObject,metaclass=AsyncInit):
|
|||
mmaddr = TwMMGenID(self.proto,arg1)
|
||||
|
||||
if mmaddr and not coinaddr:
|
||||
from .addrdata import TwAddrData
|
||||
from ..addrdata import TwAddrData
|
||||
coinaddr = (await TwAddrData(self.proto)).mmaddr2coinaddr(mmaddr)
|
||||
|
||||
try:
|
||||
|
|
@ -245,7 +245,7 @@ class TrackingWallet(MMGenObject,metaclass=AsyncInit):
|
|||
# Allow for the possibility that BTC addr of MMGen addr was entered.
|
||||
# Do reverse lookup, so that MMGen addr will not be marked as non-MMGen.
|
||||
if not mmaddr:
|
||||
from .addrdata import TwAddrData
|
||||
from ..addrdata import TwAddrData
|
||||
mmaddr = (await TwAddrData(proto=self.proto)).coinaddr2mmaddr(coinaddr)
|
||||
|
||||
if not mmaddr:
|
||||
|
|
@ -23,9 +23,9 @@ twuo: Tracking wallet unspent outputs class for the MMGen suite
|
|||
import time
|
||||
from collections import namedtuple
|
||||
|
||||
from .globalvars import g
|
||||
from .color import red,yellow,green
|
||||
from .util import (
|
||||
from ..globalvars import g
|
||||
from ..color import red,yellow,green
|
||||
from ..util import (
|
||||
msg,
|
||||
msg_r,
|
||||
die,
|
||||
|
|
@ -36,19 +36,19 @@ from .util import (
|
|||
keypress_confirm,
|
||||
line_input,
|
||||
do_pager,
|
||||
base_proto_subclass
|
||||
base_proto_tw_subclass
|
||||
)
|
||||
from .base_obj import AsyncInit
|
||||
from .objmethods import MMGenObject
|
||||
from .obj import ImmutableAttr,ListItemAttr,MMGenListItem,TwComment,get_obj,HexStr,CoinTxID
|
||||
from .addr import CoinAddr,MMGenID,AddrIdx
|
||||
from .rpc import rpc_init
|
||||
from .tw import TwCommon,TwMMGenID,get_tw_label
|
||||
from ..base_obj import AsyncInit
|
||||
from ..objmethods import MMGenObject
|
||||
from ..obj import ImmutableAttr,ListItemAttr,MMGenListItem,TwComment,get_obj,HexStr,CoinTxID
|
||||
from ..addr import CoinAddr,MMGenID,AddrIdx
|
||||
from ..rpc import rpc_init
|
||||
from .common import TwCommon,TwMMGenID,get_tw_label
|
||||
|
||||
class TwUnspentOutputs(MMGenObject,TwCommon,metaclass=AsyncInit):
|
||||
|
||||
def __new__(cls,proto,*args,**kwargs):
|
||||
return MMGenObject.__new__(base_proto_subclass(cls,proto,'twuo'))
|
||||
return MMGenObject.__new__(base_proto_tw_subclass(cls,proto,'unspent'))
|
||||
|
||||
txid_w = 64
|
||||
age_fmts_date_dependent = ('days','date','date_time')
|
||||
|
|
@ -95,7 +95,7 @@ class TwUnspentOutputs(MMGenObject,TwCommon,metaclass=AsyncInit):
|
|||
self.disp_prec = self.get_display_precision()
|
||||
self.rpc = await rpc_init(proto)
|
||||
|
||||
from .twctl import TrackingWallet
|
||||
from .ctl import TrackingWallet
|
||||
self.wallet = await TrackingWallet(proto,mode='w')
|
||||
|
||||
@property
|
||||
|
|
@ -174,7 +174,7 @@ class TwUnspentOutputs(MMGenObject,TwCommon,metaclass=AsyncInit):
|
|||
return ret
|
||||
|
||||
def set_term_columns(self):
|
||||
from .term import get_terminal_size
|
||||
from ..term import get_terminal_size
|
||||
while True:
|
||||
self.cols = g.terminal_width or get_terminal_size().width
|
||||
if self.cols >= g.min_screen_width:
|
||||
|
|
@ -387,10 +387,10 @@ class TwUnspentOutputs(MMGenObject,TwCommon,metaclass=AsyncInit):
|
|||
return n
|
||||
|
||||
async def view_and_sort(self,tx):
|
||||
from .term import get_char
|
||||
from ..term import get_char
|
||||
prompt = self.prompt.strip() + '\b'
|
||||
no_output,oneshot_msg = False,None
|
||||
from .opts import opt
|
||||
from ..opts import opt
|
||||
CUR_HOME,ERASE_ALL = '\033[H','\033[0J'
|
||||
CUR_RIGHT = lambda n: f'\033[{n}C'
|
||||
|
||||
|
|
@ -464,7 +464,7 @@ class TwUnspentOutputs(MMGenObject,TwCommon,metaclass=AsyncInit):
|
|||
self.proto.dcoin,
|
||||
','.join(self.sort_info(include_group=False)).lower() )
|
||||
msg('')
|
||||
from .fileutil import write_data_to_file
|
||||
from ..fileutil import write_data_to_file
|
||||
try:
|
||||
write_data_to_file(
|
||||
of,
|
||||
|
|
@ -71,7 +71,7 @@ async def _get_obj_async( _clsname, _modname, *args, **kwargs ):
|
|||
# No tracking wallet required for the Unsigned and Signed(data=unsigned.__dict__) classes used
|
||||
# during signing.
|
||||
if proto and proto.tokensym and clsname in ('New','OnlineSigned'):
|
||||
from ..twctl import TrackingWallet
|
||||
from ..tw.ctl import TrackingWallet
|
||||
kwargs['tw'] = await TrackingWallet(proto)
|
||||
|
||||
return _base_proto_subclass( clsname, modname, proto )(*args,**kwargs)
|
||||
|
|
|
|||
|
|
@ -332,7 +332,7 @@ class New(Base):
|
|||
|
||||
assert isinstance( locktime, (int,type(None)) ), 'locktime must be of type int'
|
||||
|
||||
from ..twuo import TwUnspentOutputs
|
||||
from ..tw.unspent import TwUnspentOutputs
|
||||
|
||||
if opt.comment_file:
|
||||
self.add_comment(opt.comment_file)
|
||||
|
|
|
|||
|
|
@ -643,11 +643,11 @@ def get_subclasses(cls,names=False):
|
|||
yield j
|
||||
return tuple((c.__name__ for c in gen(cls)) if names else gen(cls))
|
||||
|
||||
def base_proto_subclass(cls,proto,modname):
|
||||
def base_proto_tw_subclass(cls,proto,modname):
|
||||
"""
|
||||
magic module loading and class selection
|
||||
"""
|
||||
modname = f'mmgen.base_proto.{proto.base_proto.lower()}.{modname}'
|
||||
modname = f'mmgen.base_proto.{proto.base_proto.lower()}.tw.{modname}'
|
||||
clsname = (
|
||||
proto.mod_clsname
|
||||
+ ('Token' if proto.tokensym else '')
|
||||
|
|
|
|||
|
|
@ -44,16 +44,19 @@ packages =
|
|||
mmgen.base_proto
|
||||
mmgen.base_proto.bitcoin
|
||||
mmgen.base_proto.bitcoin.tx
|
||||
mmgen.base_proto.bitcoin.tw
|
||||
mmgen.base_proto.ethereum
|
||||
mmgen.base_proto.ethereum.pyethereum
|
||||
mmgen.base_proto.ethereum.rlp
|
||||
mmgen.base_proto.ethereum.rlp.sedes
|
||||
mmgen.base_proto.ethereum.tx
|
||||
mmgen.base_proto.ethereum.tw
|
||||
mmgen.base_proto.monero
|
||||
mmgen.proto
|
||||
mmgen.share
|
||||
mmgen.tool
|
||||
mmgen.tx
|
||||
mmgen.tw
|
||||
mmgen.wallet
|
||||
|
||||
scripts =
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ from mmgen.common import *
|
|||
from mmgen.addrlist import *
|
||||
from mmgen.passwdlist import *
|
||||
from mmgen.tx.base import Base
|
||||
from mmgen.base_proto.bitcoin.twuo import BitcoinTwUnspentOutputs
|
||||
from mmgen.base_proto.bitcoin.tw.unspent import BitcoinTwUnspentOutputs
|
||||
|
||||
opts_data = {
|
||||
'sets': [
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ from mmgen.seedsplit import *
|
|||
from mmgen.protocol import *
|
||||
from mmgen.addr import *
|
||||
from mmgen.tx import *
|
||||
from mmgen.twuo import *
|
||||
from mmgen.tw.unspent import *
|
||||
from mmgen.key import *
|
||||
from ..include.common import getrand
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ from mmgen.seedsplit import *
|
|||
from mmgen.addr import *
|
||||
from mmgen.addrlist import *
|
||||
from mmgen.addrdata import *
|
||||
from mmgen.tw import *
|
||||
from mmgen.tw.common import *
|
||||
from mmgen.amt import *
|
||||
from mmgen.key import *
|
||||
from mmgen.rpc import IPPort
|
||||
|
|
|
|||
|
|
@ -41,17 +41,20 @@ def overlay_setup(repo_root):
|
|||
'mmgen.base_proto',
|
||||
'mmgen.base_proto.bitcoin',
|
||||
'mmgen.base_proto.bitcoin.tx',
|
||||
'mmgen.base_proto.bitcoin.tw',
|
||||
'mmgen.base_proto.ethereum',
|
||||
'mmgen.base_proto.ethereum.pyethereum',
|
||||
'mmgen.base_proto.ethereum.rlp',
|
||||
'mmgen.base_proto.ethereum.rlp.sedes',
|
||||
'mmgen.base_proto.ethereum.tx',
|
||||
'mmgen.base_proto.ethereum.tw',
|
||||
'mmgen.base_proto.monero',
|
||||
'mmgen.data',
|
||||
'mmgen.proto',
|
||||
'mmgen.share',
|
||||
'mmgen.tool',
|
||||
'mmgen.tx',
|
||||
'mmgen.tw',
|
||||
'mmgen.wallet' ):
|
||||
process_srcdir(d)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
import os
|
||||
from .twuo_orig import *
|
||||
from .unspent_orig import *
|
||||
|
||||
if os.getenv('MMGEN_BOGUS_WALLET_DATA'):
|
||||
|
||||
async def fake_get_unspent_rpc(foo):
|
||||
from decimal import Decimal
|
||||
import json
|
||||
from mmgen.fileutil import get_data_from_file
|
||||
from ....fileutil import get_data_from_file
|
||||
return json.loads(get_data_from_file(os.getenv('MMGEN_BOGUS_WALLET_DATA')),parse_float=Decimal)
|
||||
|
||||
BitcoinTwUnspentOutputs.get_unspent_rpc = fake_get_unspent_rpc
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
import os
|
||||
from .tw_orig import *
|
||||
from .common_orig import *
|
||||
|
||||
if os.getenv('MMGEN_TEST_SUITE_DETERMINISTIC'):
|
||||
def _time_gen():
|
||||
|
|
@ -478,7 +478,7 @@ class TestSuiteMain(TestSuiteBase,TestSuiteShared):
|
|||
cmd_args = self._make_txcreate_cmdline(tx_data)
|
||||
|
||||
if cmdline_inputs:
|
||||
from mmgen.tw import TwLabel
|
||||
from mmgen.tw.common import TwLabel
|
||||
cmd_args = [
|
||||
'--inputs={},{},{},{},{},{}'.format(
|
||||
TwLabel(self.proto,dfake[0][self.lbl_id]).mmid,dfake[1]['address'],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue