Esempio n. 1
0
def main():
    parser = ArgumentParser()
    parser.add_argument("-m", dest="mnemonic", help="Set mnemonic", type=str)
    parser.add_argument("-p", dest="pin", help="Set pin", type=str)
    parser.add_argument("--passphrase", dest="passphrase", help="Enable passphrase", action="store_true")
    parser.add_argument("--no-passphrase", dest="passphrase", help="Enable passphrase", action="store_false")
    parser.set_defaults(passphrase=True)

    args = parser.parse_args()

    # Setup link
    wirelink = get_device()
    debuglink = wirelink.find_debug()

    client = TrezorClientDebugLink(wirelink)
    client.set_debuglink(debuglink)
    # Setup link: END

    client.wipe_device()
    client.transport.session_begin()

    client.load_device_by_mnemonic(
        mnemonic=args.mnemonic, pin=args.pin, passphrase_protection=args.passphrase, label='test')


    print(client.features)

    client.transport.session_end()
    client.close()
Esempio n. 2
0
    def setup_method(self, method):
        wirelink = conftest.get_device()
        debuglink = wirelink.find_debug()
        self.client = TrezorClientDebugLink(wirelink)
        self.client.set_debuglink(debuglink)
        self.client.set_tx_api(coins.tx_api["Bitcoin"])
        # self.client.set_buttonwait(3)

        device.wipe(self.client)
        self.client.transport.session_begin()
Esempio n. 3
0
    def setUp(self):
        transport = config.TRANSPORT(*config.TRANSPORT_ARGS,
                                     **config.TRANSPORT_KWARGS)
        if hasattr(config, 'DEBUG_TRANSPORT'):
            debug_transport = config.DEBUG_TRANSPORT(
                *config.DEBUG_TRANSPORT_ARGS, **config.DEBUG_TRANSPORT_KWARGS)
            self.client = TrezorClientDebugLink(transport)
            self.client.set_debuglink(debug_transport)
        else:
            self.client = TrezorClient(transport)
        self.client.set_tx_api(tx_api.TxApiBitcoin)
        # self.client.set_buttonwait(3)

        #                     1      2     3    4      5      6      7     8      9    10    11    12
        self.mnemonic12 = 'alcohol woman abuse must during monitor noble actual mixed trade anger aisle'
        self.mnemonic18 = 'owner little vague addict embark decide pink prosper true fork panda embody mixture exchange choose canoe electric jewel'
        self.mnemonic24 = 'dignity pass list indicate nasty swamp pool script soccer toe leaf photo multiply desk host tomato cradle drill spread actor shine dismiss champion exotic'
        self.mnemonic_all = ' '.join(['all'] * 12)

        self.pin4 = '1234'
        self.pin6 = '789456'
        self.pin8 = '45678978'

        self.client.wipe_device()

        print("Setup finished")
        print("--------------")
Esempio n. 4
0
def client():
    wirelink = get_device()
    debuglink = wirelink.find_debug()
    client = TrezorClientDebugLink(wirelink)
    client.set_debuglink(debuglink)
    client.set_tx_api(coins.tx_api['Bitcoin'])
    client.wipe_device()
    client.transport.session_begin()

    yield client

    client.transport.session_end()

    # XXX debuglink session must also be closed
    # client.close accomplishes that for now; going forward, there should
    # also be proper session handling for debuglink
    client.close()
Esempio n. 5
0
    def setup_method(self, method):
        wirelink, debuglink = get_transport()
        self.client = TrezorClientDebugLink(wirelink)
        self.client.set_debuglink(debuglink)
        self.client.set_tx_api(tx_api.TxApiBitcoin)
        # self.client.set_buttonwait(3)

        #                     1      2     3    4      5      6      7     8      9    10    11    12
        self.mnemonic12 = 'alcohol woman abuse must during monitor noble actual mixed trade anger aisle'
        self.mnemonic18 = 'owner little vague addict embark decide pink prosper true fork panda embody mixture exchange choose canoe electric jewel'
        self.mnemonic24 = 'dignity pass list indicate nasty swamp pool script soccer toe leaf photo multiply desk host tomato cradle drill spread actor shine dismiss champion exotic'
        self.mnemonic_all = ' '.join(['all'] * 12)

        self.pin4 = '1234'
        self.pin6 = '789456'
        self.pin8 = '45678978'

        self.client.wipe_device()
        self.client.transport.session_begin()
Esempio n. 6
0
def client():
    wirelink = get_device()
    debuglink = wirelink.find_debug()
    client = TrezorClientDebugLink(wirelink)
    client.set_debuglink(debuglink)
    client.set_tx_api(coins.tx_api['Bitcoin'])
    client.wipe_device()
    client.transport.session_begin()

    yield client

    client.transport.session_end()
Esempio n. 7
0
    def _connect(self):
        self.wirelink = get_transport(self.path)
        self.client = (TrezorClientDebugLink(self.wirelink)
                       if self.debug else TrezorClient(self.wirelink))

        if self.debug:
            try:
                self.debuglink = self.wirelink.find_debug()
                self.client.set_debuglink(self.debuglink)
            except Exception as e:
                pass
Esempio n. 8
0
class TrezorTest:
    # fmt: off
    #                1      2     3    4      5      6      7     8      9    10    11    12
    mnemonic12 = "alcohol woman abuse must during monitor noble actual mixed trade anger aisle"
    mnemonic18 = "owner little vague addict embark decide pink prosper true fork panda embody mixture exchange choose canoe electric jewel"
    mnemonic24 = "dignity pass list indicate nasty swamp pool script soccer toe leaf photo multiply desk host tomato cradle drill spread actor shine dismiss champion exotic"
    mnemonic_all = " ".join(["all"] * 12)
    # fmt: on

    pin4 = "1234"
    pin6 = "789456"
    pin8 = "45678978"

    def setup_method(self, method):
        wirelink = conftest.get_device()
        debuglink = wirelink.find_debug()
        self.client = TrezorClientDebugLink(wirelink)
        self.client.set_debuglink(debuglink)
        self.client.set_tx_api(coins.tx_api["Bitcoin"])
        # self.client.set_buttonwait(3)

        device.wipe(self.client)
        self.client.transport.session_begin()

    def teardown_method(self, method):
        self.client.transport.session_end()
        self.client.close()

    def _setup_mnemonic(self, mnemonic=None, pin="", passphrase=False):
        if mnemonic is None:
            mnemonic = TrezorTest.mnemonic12
        debuglink.load_device_by_mnemonic(
            self.client,
            mnemonic=mnemonic,
            pin=pin,
            passphrase_protection=passphrase,
            label="test",
            language="english",
        )

    def setup_mnemonic_allallall(self):
        self._setup_mnemonic(mnemonic=TrezorTest.mnemonic_all)

    def setup_mnemonic_nopin_nopassphrase(self):
        self._setup_mnemonic()

    def setup_mnemonic_nopin_passphrase(self):
        self._setup_mnemonic(passphrase=True)

    def setup_mnemonic_pin_nopassphrase(self):
        self._setup_mnemonic(pin=TrezorTest.pin4)

    def setup_mnemonic_pin_passphrase(self):
        self._setup_mnemonic(pin=TrezorTest.pin4, passphrase=True)
Esempio n. 9
0
class TrezorTest:
    def setup_method(self, method):
        wirelink = get_device()
        debuglink = wirelink.find_debug()
        self.client = TrezorClientDebugLink(wirelink)
        self.client.set_debuglink(debuglink)
        self.client.set_tx_api(coins.tx_api['Bitcoin'])
        # self.client.set_buttonwait(3)

        #                     1      2     3    4      5      6      7     8      9    10    11    12
        self.mnemonic12 = 'alcohol woman abuse must during monitor noble actual mixed trade anger aisle'
        self.mnemonic18 = 'owner little vague addict embark decide pink prosper true fork panda embody mixture exchange choose canoe electric jewel'
        self.mnemonic24 = 'dignity pass list indicate nasty swamp pool script soccer toe leaf photo multiply desk host tomato cradle drill spread actor shine dismiss champion exotic'
        self.mnemonic_all = ' '.join(['all'] * 12)

        self.pin4 = '1234'
        self.pin6 = '789456'
        self.pin8 = '45678978'

        self.client.wipe_device()
        self.client.transport.session_begin()

    def teardown_method(self, method):
        self.client.transport.session_end()
        self.client.close()

    def setup_mnemonic_allallall(self):
        self.client.load_device_by_mnemonic(mnemonic=self.mnemonic_all,
                                            pin='',
                                            passphrase_protection=False,
                                            label='test',
                                            language='english')

    def setup_mnemonic_nopin_nopassphrase(self):
        self.client.load_device_by_mnemonic(mnemonic=self.mnemonic12,
                                            pin='',
                                            passphrase_protection=False,
                                            label='test',
                                            language='english')

    def setup_mnemonic_nopin_passphrase(self):
        self.client.load_device_by_mnemonic(mnemonic=self.mnemonic12,
                                            pin='',
                                            passphrase_protection=True,
                                            label='test',
                                            language='english')

    def setup_mnemonic_pin_nopassphrase(self):
        self.client.load_device_by_mnemonic(mnemonic=self.mnemonic12,
                                            pin=self.pin4,
                                            passphrase_protection=False,
                                            label='test',
                                            language='english')

    def setup_mnemonic_pin_passphrase(self):
        self.client.load_device_by_mnemonic(mnemonic=self.mnemonic12,
                                            pin=self.pin4,
                                            passphrase_protection=True,
                                            label='test',
                                            language='english')
Esempio n. 10
0
)
mnemonic24 = "permit universe parent weapon amused modify essay borrow tobacco budget walnut " "lunch consider gallery ride amazing frog forget treat market chapter velvet useless topple"

debug_mode = args.debug
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")

mnemonic = mnemonic24 if args.mnemonic == 1 else mnemonic12


wirelink = get_transport(path)
client = TrezorClientDebugLink(wirelink) if debug_mode else TrezorClient(wirelink)
if debug_mode:
    debuglink = wirelink.find_debug()
    client.set_debuglink(debuglink)

client.transport.session_begin()

client.wipe_device()
client.load_device_by_mnemonic(
    mnemonic=mnemonic,
    pin="",
    passphrase_protection=False,
    label="ph4test",
    language="english",
)