コード例 #1
0
ファイル: common.py プロジェクト: tsusanka/python-trezor
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')
コード例 #2
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()
コード例 #3
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()
コード例 #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()
コード例 #5
0
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",
)

client.transport.session_end()
client.close()