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.')