def get_address_and_pubkey(main_ui, bip32_path): client = main_ui.hw_client if client: bip32_path.strip() if bip32_path.lower().find('m/') >= 0: # removing m/ prefix because of keepkey library bip32_path = bip32_path[2:] if main_ui.config.hw_type in (HWType.trezor, HWType.keepkey): if isinstance(bip32_path, str): # trezor/keepkey require bip32 path argument as an array of integers bip32_path = client.expand_path(bip32_path) return { 'address': client.get_address('Dash', bip32_path, False), 'publicKey': client.get_public_node(bip32_path).node.public_key } elif main_ui.config.hw_type == HWType.ledger_nano_s: import hw_intf_ledgernano as ledger if isinstance(bip32_path, list): # ledger requires bip32 path argument as a string bip32_path = bip32_path_n_to_string(bip32_path) return ledger.get_address_and_pubkey(client, bip32_path) else: raise Exception('Unknown hwardware wallet type: ' + main_ui.config.hw_type)
def get_address(hw_session: HwSessionInfo, bip32_path): client = hw_session.hw_client if client: if isinstance(bip32_path, str): bip32_path.strip() if bip32_path.lower().find('m/') >= 0: # removing m/ prefix because of keepkey library bip32_path = bip32_path[2:] if hw_session.app_config.hw_type in (HWType.trezor, HWType.keepkey): if isinstance(bip32_path, str): # trezor/keepkey require bip32 path argument as an array of integers bip32_path = client.expand_path(bip32_path) return client.get_address(hw_session.app_config.hw_coin_name, bip32_path, False) elif hw_session.app_config.hw_type == HWType.ledger_nano_s: import hw_intf_ledgernano as ledger if isinstance(bip32_path, list): # ledger requires bip32 path argument as a string bip32_path = bip32_path_n_to_string(bip32_path) adr_pubkey = ledger.get_address_and_pubkey(client, bip32_path) return adr_pubkey.get('address') else: raise Exception('Unknown hwardware wallet type: ' + hw_session.app_config.hw_type) else: raise Exception('HW client not open.')
def _get_address(ctrl, hw_session: HwSessionInfo, bip32_path: str, show_display: bool = False, message_to_display: str = None): if ctrl: ctrl.dlg_config_fun(dlg_title=DEFAULT_HW_BUSY_TITLE, show_progress_bar=False) if message_to_display: ctrl.display_msg_fun(message_to_display) else: ctrl.display_msg_fun('<b>Click the confirmation button on your hardware wallet to exit...</b>') client = hw_session.hw_client if client: if isinstance(bip32_path, str): bip32_path.strip() if bip32_path.lower().find('m/') >= 0: # removing m/ prefix because of keepkey library bip32_path = bip32_path[2:] if hw_session.app_config.hw_type == HWType.trezor: from trezorlib import btc from trezorlib import exceptions try: if isinstance(bip32_path, str): bip32_path = gewel_utils.bip32_path_string_to_n(bip32_path) ret = btc.get_address(client, hw_session.app_config.hw_coin_name, bip32_path, show_display) return ret except (CancelException, exceptions.Cancelled): raise CancelException() elif hw_session.app_config.hw_type == HWType.keepkey: from keepkeylib.client import CallException try: if isinstance(bip32_path, str): bip32_path = gewel_utils.bip32_path_string_to_n(bip32_path) return client.get_address(hw_session.app_config.hw_coin_name, bip32_path, show_display) except CallException as e: if isinstance(e.args, tuple) and len(e.args) >= 2 and isinstance(e.args[1], str) and \ e.args[1].find('cancel') >= 0: raise CancelException('Cancelled') elif hw_session.app_config.hw_type == HWType.ledger_nano_s: import hw_intf_ledgernano as ledger if isinstance(bip32_path, list): # ledger requires bip32 path argument as a string bip32_path = bip32_path_n_to_string(bip32_path) adr_pubkey = ledger.get_address_and_pubkey(client, bip32_path, show_display) return adr_pubkey.get('address') else: raise Exception('Unknown hardware wallet type: ' + hw_session.app_config.hw_type) else: raise Exception('HW client not open.')
def get_address_and_pubkey(hw_session: HwSessionInfo, bip32_path): client = hw_session.hw_client if client: if isinstance(bip32_path, str): bip32_path.strip() if bip32_path.lower().find('m/') >= 0: # removing m/ prefix because of keepkey library bip32_path = bip32_path[2:] if hw_session.app_config.hw_type == HWType.trezor: from trezorlib import btc if isinstance(bip32_path, str): bip32_path = fix_utils.bip32_path_string_to_n(bip32_path) return { 'address': btc.get_address(client, hw_session.app_config.hw_coin_name, bip32_path, False), 'publicKey': btc.get_public_node(client, bip32_path).node.public_key } elif hw_session.app_config.hw_type == HWType.keepkey: if isinstance(bip32_path, str): bip32_path = fix_utils.bip32_path_string_to_n(bip32_path) return { 'address': client.get_address(hw_session.app_config.hw_coin_name, bip32_path, False), 'publicKey': client.get_public_node(bip32_path).node.public_key } elif hw_session.app_config.hw_type == HWType.ledger_nano_s: import hw_intf_ledgernano as ledger if isinstance(bip32_path, list): # ledger requires bip32 path argument as a string bip32_path = bip32_path_n_to_string(bip32_path) return ledger.get_address_and_pubkey(client, bip32_path) else: raise Exception('Unknown hardware wallet type: ' + hw_session.app_config.hw_type)
def _get_address(ctrl, hw_session: HwSessionInfo, bip32_path: str, show_display: bool = False, message_to_display: str = None): if ctrl: ctrl.dlg_config_fun(dlg_title="Please confirm", show_progress_bar=False) if message_to_display: ctrl.display_msg_fun(message_to_display) else: ctrl.display_msg_fun('<b>Click the confirmation button on your hardware wallet to exit...</b>') client = hw_session.hw_client if client: if isinstance(bip32_path, str): bip32_path.strip() if bip32_path.lower().find('m/') >= 0: # removing m/ prefix because of keepkey library bip32_path = bip32_path[2:] if hw_session.app_config.hw_type == HWType.trezor: from trezorlib import btc if isinstance(bip32_path, str): bip32_path = dash_utils.bip32_path_string_to_n(bip32_path) return btc.get_address(client, hw_session.app_config.hw_coin_name, bip32_path, show_display) elif hw_session.app_config.hw_type == HWType.keepkey: if isinstance(bip32_path, str): bip32_path = dash_utils.bip32_path_string_to_n(bip32_path) return client.get_address(hw_session.app_config.hw_coin_name, bip32_path, show_display) elif hw_session.app_config.hw_type == HWType.ledger_nano_s: import hw_intf_ledgernano as ledger if isinstance(bip32_path, list): # ledger requires bip32 path argument as a string bip32_path = bip32_path_n_to_string(bip32_path) adr_pubkey = ledger.get_address_and_pubkey(client, bip32_path) return adr_pubkey.get('address') else: raise Exception('Unknown hardware wallet type: ' + hw_session.app_config.hw_type) else: raise Exception('HW client not open.')
def hw_get_address(client, address_n): return client.get_address('Dash', address_n, False)