mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-02-18 10:32:02 +00:00
Added TrezorClientDebug which prints wire messages to stdout
This commit is contained in:
parent
6e90d5763e
commit
2a3e5ace6b
4
cmd.py
4
cmd.py
@ -5,7 +5,7 @@ import argparse
|
|||||||
import json
|
import json
|
||||||
import base64
|
import base64
|
||||||
|
|
||||||
from trezorlib.client import TrezorClient
|
from trezorlib.client import TrezorClientDebug
|
||||||
from trezorlib.api_blockchain import BlockchainApi
|
from trezorlib.api_blockchain import BlockchainApi
|
||||||
from trezorlib.protobuf_json import pb2json
|
from trezorlib.protobuf_json import pb2json
|
||||||
|
|
||||||
@ -319,7 +319,7 @@ def main():
|
|||||||
return
|
return
|
||||||
|
|
||||||
transport = get_transport(args.transport, args.path)
|
transport = get_transport(args.transport, args.path)
|
||||||
client = TrezorClient(transport)
|
client = TrezorClientDebug(transport)
|
||||||
client.set_tx_func(BlockchainApi().get_tx)
|
client.set_tx_func(BlockchainApi().get_tx)
|
||||||
cmds = Commands(client)
|
cmds = Commands(client)
|
||||||
|
|
||||||
|
@ -63,13 +63,9 @@ class BaseClient(object):
|
|||||||
|
|
||||||
def call_raw(self, msg):
|
def call_raw(self, msg):
|
||||||
try:
|
try:
|
||||||
print "SENDING", pprint(msg)
|
|
||||||
self.transport.session_begin()
|
self.transport.session_begin()
|
||||||
|
|
||||||
self.transport.write(msg)
|
self.transport.write(msg)
|
||||||
resp = self.transport.read_blocking()
|
resp = self.transport.read_blocking()
|
||||||
print "RECEIVED", pprint(resp)
|
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
self.transport.session_end()
|
self.transport.session_end()
|
||||||
|
|
||||||
@ -105,6 +101,13 @@ class BaseClient(object):
|
|||||||
def close(self):
|
def close(self):
|
||||||
self.transport.close()
|
self.transport.close()
|
||||||
|
|
||||||
|
class DebugWireMixin(object):
|
||||||
|
def call_raw(self, msg):
|
||||||
|
print "SENDING", pprint(msg)
|
||||||
|
resp = super(DebugWireMixin, self).call_raw(msg)
|
||||||
|
print "RECEIVED", pprint(resp)
|
||||||
|
return resp
|
||||||
|
|
||||||
class TextUIMixin(object):
|
class TextUIMixin(object):
|
||||||
# This class demonstrates easy test-based UI
|
# This class demonstrates easy test-based UI
|
||||||
# integration between the device and wallet.
|
# integration between the device and wallet.
|
||||||
@ -179,9 +182,7 @@ class DebugLinkMixin(object):
|
|||||||
return resp
|
return resp
|
||||||
|
|
||||||
def call(self, msg):
|
def call(self, msg):
|
||||||
print "SENDING", pprint(msg)
|
|
||||||
ret = super(DebugLinkMixin, self).call(msg)
|
ret = super(DebugLinkMixin, self).call(msg)
|
||||||
print "RECEIVED", pprint(ret)
|
|
||||||
|
|
||||||
if self.expected_responses != None and len(self.expected_responses):
|
if self.expected_responses != None and len(self.expected_responses):
|
||||||
raise Exception("Some of expected responses didn't come from device: %s" % \
|
raise Exception("Some of expected responses didn't come from device: %s" % \
|
||||||
@ -501,7 +502,10 @@ class ProtocolMixin(object):
|
|||||||
class TrezorClient(ProtocolMixin, TextUIMixin, BaseClient):
|
class TrezorClient(ProtocolMixin, TextUIMixin, BaseClient):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
class TrezorDebugClient(ProtocolMixin, DebugLinkMixin, BaseClient):
|
class TrezorClientDebug(ProtocolMixin, TextUIMixin, DebugWireMixin, BaseClient):
|
||||||
|
pass
|
||||||
|
|
||||||
|
class TrezorDebugClient(ProtocolMixin, DebugLinkMixin, DebugWireMixin, BaseClient):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
'''
|
'''
|
||||||
|
Loading…
Reference in New Issue
Block a user