diff --git a/electrum_gui/android/console.py b/electrum_gui/android/console.py index 94c9e6d7bc90..305a42b2f902 100755 --- a/electrum_gui/android/console.py +++ b/electrum_gui/android/console.py @@ -320,7 +320,7 @@ def update_status(self): out["tokens"] = contracts_balance_info out["sum_fiat"] = f"{self.daemon.fx.ccy_amount_str(sum_fiat, True)} {self.ccy}" out["coin_asset"] = self._fill_balance_info_with_coin(sum_fiat, coin) - out["name"] = self.wallet.identity + out["id"] = self.wallet.identity elif ( self.network and self.network.is_connected() @@ -343,7 +343,7 @@ def update_status(self): out["tokens"] = [] out["sum_fiat"] = fiat_str out["coin_asset"] = out["balance"] - out["name"] = self.wallet.identity + out["id"] = self.wallet.identity if u: out["unconfirmed"] = self.format_amount(u, is_diff=True).strip() @@ -3299,7 +3299,7 @@ def create( # noqa self.wallet_context.set_backup_info(wallet.keystore.xpub) ret = { "seed": seed if new_seed else "", - "wallet_info": [{"coin_type": coin, "name": wallet.identity, "exist": 0}], + "wallet_info": [{"coin_type": coin, "id": wallet.identity, "exist": 0}], "derived_info": [], } return json.dumps(ret) @@ -3465,8 +3465,8 @@ def filter_wallet(self): { "coin": coin, "blance": balance, - "name": str(wallets[index]), - "label": wallets[index].get_name(), + "id": wallets[index].identity, + "name": wallets[index].get_name(), "exist": "1" if self.daemon.get_wallet(self._wallet_path(wallets[index].identity)) is not None else "0", @@ -3482,8 +3482,8 @@ def filter_wallet(self): { "coin": coin, "blance": balance, - "name": str(wallet), - "label": wallet.get_name(), + "id": wallet.identity, + "name": wallet.get_name(), "exist": "1" if self.daemon.get_wallet(self._wallet_path(wallet.identity)) is not None else "0", @@ -3586,9 +3586,9 @@ def filter_wallet_with_account_is_zero(self): exist = 1 if self.daemon.get_wallet(self._wallet_path(wallet_id)) is not None else 0 wallet_info = { 'coin_type': coin, - 'name': wallet.identity, + 'id': wallet.identity, 'exist': exist, - 'label': wallet.get_name(), + 'name': wallet.get_name(), } wallet_list.append(wallet_info) except BaseException as e: @@ -3819,18 +3819,18 @@ def get_all_wallet_balance(self): "btc_asset":"", "wallet_info": [ { - "name": "", + "id": "", "coin":"" - "label": "", + "name": "", "sum_fiat": "1,333.55", "wallets": [ {"coin": "btc", "address":"", "balance": "", "fiat": "", "icon":""} ] }, { - "name": "", + "id": "", "coin":"" - "label": "", + "name": "", "sum_fiat": "", "wallets": [ { "coin": "btc", "address":"", "balance": "", "fiat": "", "icon":""}, @@ -3845,7 +3845,7 @@ def get_all_wallet_balance(self): all_balance = Decimal("0") all_wallet_info = [] for wallet in self.daemon.get_wallets().values(): - wallet_info = {"name": wallet.identity, "label": wallet.get_name()} + wallet_info = {"name": wallet.get_name(), "id": wallet.identity} coin = wallet.coin wallet_info["coin"] = coin chain_affinity = _get_chain_affinity(coin) @@ -3881,7 +3881,7 @@ def get_all_wallet_balance(self): ) # sort no-zero balance wallet by fiat currency in reverse order zero_balance_wallets = (i for i in all_wallet_info if i["sum_fiat"] <= 0) - zero_balance_wallets_dict = {i["name"]: i for i in zero_balance_wallets} + zero_balance_wallets_dict = {i["id"]: i for i in zero_balance_wallets} sorted_wallet_labels = (i[0] for i in self.wallet_context.get_stored_wallets_types()) zero_balance_wallets = [ @@ -4176,14 +4176,14 @@ def update_wallet_name(self, old_name, new_name): except BaseException as e: raise e - def switch_wallet(self, name): + def switch_wallet(self, id): """ Switching to a specific wallet - :param name: name as string + :param id: id as string :return: json like { + "id": "", "name": "", - "label": "", "wallets": [ {"coin": "usdt", "address": ""}, ... @@ -4191,16 +4191,16 @@ def switch_wallet(self, name): } """ self._assert_daemon_running() - if name is None: + if id is None: raise FailedToSwitchWallet() - self.wallet = self.daemon.get_wallet(self._wallet_path(name)) + self.wallet = self.daemon.get_wallet(self._wallet_path(id)) # self.wallet.use_change = self.config.get("use_change", False) chain_affinity = _get_chain_affinity(self.wallet.coin) if chain_affinity == "eth": contract_info = self.wallet.get_contract_symbols_with_address() - info = {"name": name, "label": self.wallet.get_name(), "wallets": contract_info} + info = {"id": id, "name": self.wallet.get_name(), "wallets": contract_info} elif chain_affinity == "btc": if not isinstance(self.wallet, Imported_Wallet): self.wallet.set_key_pool_size() @@ -4208,8 +4208,8 @@ def switch_wallet(self, name): util.trigger_callback("wallet_updated", self.wallet) info = { - "name": name, - "label": self.wallet.get_name(), + "id": id, + "name": self.wallet.get_name(), "wallets": [], } if self.label_flag and self.wallet.wallet_type != "standard": @@ -4226,6 +4226,7 @@ def get_wallet_balance(self): "all_balance": "", "coin_asset":"", "coin":"", + "id":"", "name":"", "wallets": [ {"coin": "eth", "address": "", "balance": "", "fiat": "", "icon":""}, @@ -4235,7 +4236,7 @@ def get_wallet_balance(self): """ self._assert_wallet_isvalid() coin = self.wallet.coin - info = {"name": self.wallet.identity, "label": self.wallet.get_name(), "coin": coin} + info = {"id": self.wallet.identity, "name": self.wallet.get_name(), "coin": coin} chain_affinity = _get_chain_affinity(coin) if chain_affinity == "eth": main_balance_info, contracts_balance_info, sum_fiat = self._get_eth_wallet_all_balance(self.wallet) @@ -4272,14 +4273,14 @@ def get_wallet_balance(self): raise UnsupportedCurrencyCoin() return json.dumps(info, cls=DecimalEncoder) - def select_wallet(self, name): # TODO: Will be deleted later + def select_wallet(self, id): # TODO: Will be deleted later """ Select wallet by name :param name: name as string :return: json like { + "id": "", "name": "", - "label": "", "wallets": [ {"coin": "eth", "balance": "", "fiat": ""}, {"coin": "usdt", "balance": "", "fiat": ""} @@ -4287,10 +4288,10 @@ def select_wallet(self, name): # TODO: Will be deleted later } """ self._assert_daemon_running() - if name is None: + if id is None: self.wallet = None else: - self.wallet = self.daemon.get_wallet(self._wallet_path(name)) + self.wallet = self.daemon.get_wallet(self._wallet_path(id)) self.wallet.use_change = self.config.get("use_change", False) coin = self.wallet.coin @@ -4300,8 +4301,8 @@ def select_wallet(self, name): # TODO: Will be deleted later self.wallet, with_sum_fiat=False ) info = { - "name": name, - "label": self.wallet.get_name(), + "id": id, + "name": self.wallet.get_name(), "wallets": [main_balance_info] + contracts_balance_info, } return json.dumps(info, cls=DecimalEncoder) @@ -4314,8 +4315,8 @@ def select_wallet(self, name): # TODO: Will be deleted later fiat_str = f"{self.daemon.fx.ccy_amount_str(fiat, True)} {self.ccy}" info = { "balance": self.format_amount(balance) + " (%s)" % fiat_str, # fixme deprecated field - "name": name, - "label": self.wallet.get_name(), + "id": id, + "name": self.wallet.get_name(), "wallets": [{"coin": "btc", "balance": self.format_amount(balance), "fiat": fiat_str}], } if self.label_flag and self.wallet.wallet_type != "standard": @@ -4397,7 +4398,7 @@ def list_wallets(self, type_=None): """ List available wallets :param type: None/hw/hd/btc/eth/bsc/heco/okt - :return: json like "[{"wallet_key":{'type':"", "addr":"", "name":"", "label":"", "device_id": ""}}, ...]" + :return: json like "[{"wallet_key":{'type':"", "addr":"", "id":"", "name":"", "device_id": ""}}, ...]" exp: all_list = testcommond.list_wallets() hd_list = testcommond.list_wallets(type='hd') @@ -4428,8 +4429,8 @@ def list_wallets(self, type_=None): wallet_id: { "type": wallet_type, "addr": wallet.get_addresses()[0], - "name": wallet.identity, - "label": wallet.get_name(), + "id": wallet.identity, + "name": wallet.get_name(), "device_id": device_id, } }