Пример #1
0
 def init_agent(self):
     """
     Initialize new agent instance
     :return:
     """
     t = self.init_trezor()
     return agent_lite.Agent(t)
Пример #2
0
 def init_agent(self, lite=True):
     """
     Initialize new agent instance
     :return:
     """
     t = self.init_trezor(lite=lite)
     return agent.Agent(t) if not lite else agent_lite.Agent(t)
Пример #3
0
    async def connect(self, path=None):
        """
        Connects to the trezor
        :return:
        """
        if self.args.trezor or self.args.trezor_path or path:
            from monero_glue.trezor import manager as tmanager

            self.trezor_proxy = tmanager.Trezor(
                path=path if path else self.args.trezor_path,
                debug=self.token_debug)

        else:
            self.trezor_proxy = TokenProxy()

        ntype = self.agent.network_type if self.agent else self.network_type
        self.agent = agent_lite.Agent(self.trezor_proxy, network_type=ntype)
Пример #4
0
    def reinit_trezor(self):
        self.deinit()
        path = self.get_trezor_path()
        self.creds = self.get_trezor_creds(0)
        self.trezor_proxy = tmanager.Trezor(path=path, debug=True)
        self.agent = agent_lite.Agent(self.trezor_proxy,
                                      network_type=monero.NetworkTypes.TESTNET)

        client = self.trezor_proxy.client
        client.transport.session_begin()
        client.wipe_device()
        client.load_device_by_mnemonic(
            mnemonic=self.get_trezor_mnemonics()[0],
            pin="",
            passphrase_protection=False,
            label="ph4test",
            language="english",
        )
        client.transport.session_end()
Пример #5
0
    def reinit_trezor(self):
        self.deinit()
        path = self.get_trezor_path()
        is_debug = not int(os.getenv('TREZOR_NDEBUG', 0))
        self.creds = self.get_trezor_creds(0)
        self.trezor_proxy = tmanager.Trezor(path=path, debug=is_debug)
        self.agent = agent_lite.Agent(self.trezor_proxy,
                                      network_type=monero.NetworkTypes.TESTNET)

        client = self.trezor_proxy.client
        if is_debug:
            client.open()
            device.wipe(client)
            debuglink.load_device_by_mnemonic(
                client=client,
                mnemonic=self.get_trezor_mnemonics()[0],
                pin="",
                passphrase_protection=False,
                label="ph4test",
                language="english",
            )
Пример #6
0
 def init_agent(self, creds=None):
     """
     Initialize new agent instance
     :return:
     """
     return agent_lite.Agent(self.init_trezor(creds=creds))
Пример #7
0
async def amain():
    parser = argparse.ArgumentParser(description="Trezor address loader")

    parser.add_argument("--trezor-path",
                        dest="trezor_path",
                        default=None,
                        help="Trezor device path")
    parser.add_argument("--trezor-idx",
                        dest="trezor_idx",
                        default=None,
                        help="Trezor path idx")
    parser.add_argument("--pin",
                        dest="pin",
                        default="",
                        help="Trezor PIN protection")
    parser.add_argument(
        "--passphrase",
        dest="passphrase",
        default=False,
        action="store_const",
        const=True,
        help="Enable passphrase",
    )
    parser.add_argument(
        "--debug",
        dest="debug",
        default=False,
        action="store_const",
        const=True,
        help="Debug",
    )
    parser.add_argument(
        "--debug-link",
        dest="debug_link",
        default=False,
        action="store_const",
        const=True,
        help=
        "Debug link with Trezor. May skip some dialogs (e.g., passphrase entry)",
    )
    args = parser.parse_args()

    try:
        if args.debug:
            coloredlogs.install(level=logging.DEBUG, use_chroot=False)
        else:
            coloredlogs.install(level=logging.INFO, use_chroot=False)
    except Exception as e:
        pass

    debug_mode = args.debug_link
    if args.trezor_path:
        path = args.trezor_path
    elif args.trezor_idx:
        path = "bridge:web01" if args.trezor_idx == "usb" else "udp:127.0.0.1:21324"
    else:
        path = os.environ.get("TREZOR_PATH", "bridge:web01")

    wirelink = get_transport(path)
    client = (TrezorClientDebugLink(wirelink)
              if debug_mode else TrezorClient(wirelink, ui=ui.ClickUI()))

    # client.transport.session_begin()
    trezor_proxy = tmanager.Trezor(path=path, debug=args.debug_link)
    network_type = NetworkTypes.MAINNET
    agent = agent_lite.Agent(trezor_proxy, network_type=network_type)
    res = await agent.get_address()
    print(res)

    # client.transport.session_end()
    client.close()
    sys.exit(0)