def __init__(self,mode='r'): TrackingWallet.__init__(self,mode=mode) check_or_create_dir(self.data_dir) try: self.orig_data = get_data_from_file(self.tw_file,quiet=True) self.data = json.loads(self.orig_data) except: try: os.stat(self.tw_file) except: self.orig_data = '' self.data = {'coin':g.coin,'accounts':{},'tokens':{}} else: die(2,"File '{}' exists but does not contain valid json data".format(self.tw_file)) else: self.upgrade_wallet_maybe() m = 'Tracking wallet coin ({}) does not match current coin ({})!' assert self.data['coin'] == g.coin,m.format(self.data['coin'],g.coin) if not 'tokens' in self.data: self.data['tokens'] = {} def conv_types(ad): for v in ad.values(): v['mmid'] = TwMMGenID(v['mmid'],on_fail='raise') v['comment'] = TwComment(v['comment'],on_fail='raise') conv_types(self.data['accounts']) for v in self.data['tokens'].values(): conv_types(v)
def __init__(self, mode='r'): TrackingWallet.__init__(self, mode=mode) check_or_create_dir(self.data_dir) try: self.orig_data = get_data_from_file(self.tw_file, quiet=True) self.data = json.loads(self.orig_data) except: try: os.stat(self.tw_file) except: self.orig_data = '' self.data = {'coin': g.coin, 'accounts': {}, 'tokens': {}} else: die( 2, "File '{}' exists but does not contain valid json data". format(self.tw_file)) else: self.upgrade_wallet_maybe() m = 'Tracking wallet coin ({}) does not match current coin ({})!' assert self.data['coin'] == g.coin, m.format( self.data['coin'], g.coin) if not 'tokens' in self.data: self.data['tokens'] = {} def conv_types(ad): for v in ad.values(): v['mmid'] = TwMMGenID(v['mmid'], on_fail='raise') v['comment'] = TwComment(v['comment'], on_fail='raise') conv_types(self.data['accounts']) for v in self.data['tokens'].values(): conv_types(v)
def __init__(self, mode='r', no_rpc=False): TrackingWallet.__init__(self, mode=mode) for v in self.data['tokens'].values(): self.conv_types(v) if g.token and not is_coin_addr(g.token): ret = self.sym2addr(g.token, no_rpc=no_rpc) if ret: g.token = ret