Пример #1
0
    def start(self):
        # Start the Keepkey emulator
        self.emulator_proc = subprocess.Popen(['./' + os.path.basename(self.emulator_path)], cwd=os.path.dirname(self.emulator_path), stdout=subprocess.DEVNULL)
        # Wait for emulator to be up
        # From https://github.com/trezor/trezor-mcu/blob/master/script/wait_for_emulator.py
        sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        sock.connect(('127.0.0.1', 21324))
        sock.settimeout(0)
        while True:
            try:
                sock.sendall(b"PINGPING")
                r = sock.recv(8)
                if r == b"PONGPONG":
                    break
            except Exception:
                time.sleep(0.05)

        # Setup the emulator
        for dev in enumerate_devices():
            # Find the udp transport, that's the emulator
            if isinstance(dev, UdpTransport):
                wirelink = dev
                break
        client = TrezorClientDebugLink(wirelink)
        client.init_device()
        device.wipe(client)
        load_device_by_mnemonic(client=client, mnemonic='alcohol woman abuse must during monitor noble actual mixed trade anger aisle', pin='', passphrase_protection=False, label='test') # From Trezor device tests
        return client
Пример #2
0
    def start(self):
        self.emulator_log = open('trezor-{}-emulator.stdout'.format(self.model), 'a')
        # Start the Trezor emulator
        self.emulator_proc = subprocess.Popen(['./' + os.path.basename(self.emulator_path)], cwd=os.path.dirname(self.emulator_path), stdout=self.emulator_log, env={'SDL_VIDEODRIVER': 'dummy', 'PYOPT': '0'}, shell=True, preexec_fn=os.setsid)
        # Wait for emulator to be up
        # From https://github.com/trezor/trezor-firmware/blob/master/legacy/script/wait_for_emulator.py
        sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        sock.connect(('127.0.0.1', 21324))
        sock.settimeout(0)
        while True:
            try:
                sock.sendall(b"PINGPING")
                r = sock.recv(8)
                if r == b"PONGPONG":
                    break
            except Exception:
                time.sleep(0.05)

        # Setup the emulator
        for dev in enumerate_devices():
            # Find the udp transport, that's the emulator
            if isinstance(dev, UdpTransport):
                wirelink = dev
                break
        client = TrezorClientDebugLink(wirelink)
        client.init_device()
        device.wipe(client)
        load_device_by_mnemonic(client=client, mnemonic='alcohol woman abuse must during monitor noble actual mixed trade anger aisle', pin='', passphrase_protection=False, label='test') # From Trezor device tests
        atexit.register(self.stop)
        return client
Пример #3
0
    def start(self):
        super().start()
        self.keepkey_log = open('keepkey-emulator.stdout', 'a')
        # Start the Keepkey emulator
        self.emulator_proc = subprocess.Popen(
            ['./' + os.path.basename(self.emulator_path)],
            cwd=os.path.dirname(self.emulator_path),
            stdout=self.keepkey_log)
        # Wait for emulator to be up
        # From https://github.com/trezor/trezor-firmware/blob/master/legacy/script/wait_for_emulator.py
        sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        sock.connect(('127.0.0.1', 11044))
        sock.settimeout(0)
        while True:
            try:
                sock.sendall(b"PINGPING")
                r = sock.recv(8)
                if r == b"PONGPONG":
                    break
            except Exception:
                time.sleep(0.05)

        # Setup the emulator
        model = TrezorModel(
            name="K1-14M",
            minimum_version=(0, 0, 0),
            vendors=("keepkey.com"),
            usb_ids=(),  # unused
            default_mapping=DEFAULT_MAPPING,
        )
        model.default_mapping.register(KeepkeyFeatures)
        model.default_mapping.register(KeepkeyResetDevice)
        model.default_mapping.register(KeepkeyDebugLinkState)
        wirelink = UdpTransport.enumerate("127.0.0.1:11044")[0]
        client = TrezorClientDebugLink(wirelink, model=model)
        client.init_device()
        device.wipe(client)
        load_device_by_mnemonic(
            client=client,
            mnemonic=
            'alcohol woman abuse must during monitor noble actual mixed trade anger aisle',
            pin='',
            passphrase_protection=False,
            label='test')  # From Trezor device tests
        atexit.register(self.stop)
        return client
Пример #4
0
    def start(self):
        self.keepkey_log = open('keepkey-emulator.stdout', 'a')
        # Start the Keepkey emulator
        self.emulator_proc = subprocess.Popen(
            ['./' + os.path.basename(self.emulator_path)],
            cwd=os.path.dirname(self.emulator_path),
            stdout=self.keepkey_log)
        # Wait for emulator to be up
        # From https://github.com/trezor/trezor-firmware/blob/master/legacy/script/wait_for_emulator.py
        sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        sock.connect(('127.0.0.1', 21324))
        sock.settimeout(0)
        while True:
            try:
                sock.sendall(b"PINGPING")
                r = sock.recv(8)
                if r == b"PONGPONG":
                    break
            except Exception:
                time.sleep(0.05)

        # Setup the emulator
        wirelink = UdpTransport.enumerate()[0]
        client = TrezorClientDebugLink(wirelink)
        client.vendors = ("keepkey.com")
        client.minimum_versions = {"K1-14AM": (0, 0, 0)}
        client.map_type_to_class_override[
            KeepkeyFeatures.MESSAGE_WIRE_TYPE] = KeepkeyFeatures
        client.map_type_to_class_override[
            KeepkeyResetDevice.MESSAGE_WIRE_TYPE] = KeepkeyResetDevice
        client.debug.map_type_to_class_override[
            KeepkeyDebugLinkState.MESSAGE_WIRE_TYPE] = KeepkeyDebugLinkState
        client.init_device()
        device.wipe(client)
        load_device_by_mnemonic(
            client=client,
            mnemonic=
            'alcohol woman abuse must during monitor noble actual mixed trade anger aisle',
            pin='',
            passphrase_protection=False,
            label='test')  # From Trezor device tests
        atexit.register(self.stop)
        return client