Esempio n. 1
0
class TrezorTest(unittest.TestCase):
    def setUp(self):
        self.debug_transport = config.DEBUG_TRANSPORT(*config.DEBUG_TRANSPORT_ARGS, **config.DEBUG_TRANSPORT_KWARGS)
        self.transport = config.TRANSPORT(*config.TRANSPORT_ARGS, **config.TRANSPORT_KWARGS)
        self.client = TrezorClient(self.transport, DebugLink(self.debug_transport), debug=True)
        # self.client = TrezorClient(self.transport, debug=False)

        self.mnemonic1 = 'alcohol woman abuse must during monitor noble actual mixed trade anger aisle'
        self.mnemonic2 = 'owner little vague addict embark decide pink prosper true fork panda embody mixture exchange choose canoe electric jewel'
        self.pin1 = '1234'
        self.pin2 = '43211'

        self.client.setup_debuglink(button=True, pin_correct=True)
        
        self.client.wipe_device()
        self.client.load_device_by_mnemonic(
            mnemonic=self.mnemonic1,
            pin=self.pin1,
            passphrase_protection=False,
            label='test',
            language='english',
        )

        # self.client.apply_settings(label='unit testing', coin_shortcut='BTC', language='english')

        print "Setup finished"
        print "--------------"
        
    def tearDown(self):
        self.debug_transport.close()
        self.transport.close()
Esempio n. 2
0
def main():
    args = parse_args(Commands)

    if args.cmd == 'list':
        devices = list_usb()
        if args.json:
            print json.dumps(devices)
        else:
            for dev in devices:
                if dev[1] != None:
                    print "%s - debuglink enabled" % dev[0]
                else:
                    print dev[0]
        return

    if args.debug:
        if args.debuglink_transport == 'usb' and args.debuglink_path == '':
            debuglink_transport = get_transport('usb', args.path, debug_link=True)
        else:
            debuglink_transport = get_transport(args.debuglink_transport,
                                        args.debuglink_path, debug_link=True)
        debuglink = DebugLink(debuglink_transport)    
    else:
        debuglink = None

    transport = get_transport(args.transport, args.path)
    client = TrezorClient(transport, pin_func=qt_pin_func, debuglink=debuglink)
    client.setup_debuglink(button=True, pin_correct=True)
    cmds = Commands(client)
    
    res = args.func(cmds, args)
    
    if args.json:
        print json.dumps(res, sort_keys=True, indent=4)
    else:
        print res