mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-01 20:08:26 +00:00
wip
This commit is contained in:
parent
9927f74338
commit
0696fd5435
@ -94,6 +94,7 @@ class Session:
|
||||
|
||||
|
||||
class SessionV1(Session):
|
||||
derive_cardano: bool = False
|
||||
@classmethod
|
||||
def new(
|
||||
cls, client: TrezorClient, passphrase: str = "", derive_cardano: bool = False
|
||||
@ -109,7 +110,8 @@ class SessionV1(Session):
|
||||
session.pin_callback = client.pin_callback
|
||||
session.passphrase_callback = _callback_passphrase
|
||||
session.passphrase = passphrase
|
||||
session._init_session(derive_cardano=derive_cardano)
|
||||
session.derive_cardano = derive_cardano
|
||||
session._init_session()
|
||||
return session
|
||||
|
||||
def _write(self, msg: t.Any) -> None:
|
||||
@ -122,10 +124,18 @@ class SessionV1(Session):
|
||||
assert isinstance(self.client.protocol, ProtocolV1)
|
||||
return self.client.protocol.read()
|
||||
|
||||
def _init_session(self, derive_cardano: bool = False):
|
||||
self.call_raw(
|
||||
messages.Initialize(session_id=self.id, derive_cardano=derive_cardano)
|
||||
def _init_session(self):
|
||||
if self.id == b"":
|
||||
session_id = None
|
||||
else:
|
||||
session_id = self.id
|
||||
resp: messages.Features = self.call_raw(
|
||||
messages.Initialize(
|
||||
session_id=session_id, derive_cardano=self.derive_cardano
|
||||
)
|
||||
)
|
||||
self._id = resp.session_id
|
||||
|
||||
|
||||
def _callback_button(session: Session, msg: t.Any) -> t.Any:
|
||||
print("Please confirm action on your Trezor device.") # TODO how to handle UI?
|
||||
|
@ -794,6 +794,8 @@ def test_get_address(session: Session):
|
||||
def test_multisession_authorization(client: Client):
|
||||
# Authorize CoinJoin with www.example1.com in session 1.
|
||||
session1 = client.get_session()
|
||||
session_id_1 = session1.id
|
||||
|
||||
btc.authorize_coinjoin(
|
||||
session1,
|
||||
coordinator="www.example1.com",
|
||||
@ -805,6 +807,7 @@ def test_multisession_authorization(client: Client):
|
||||
script_type=messages.InputScriptType.SPENDTAPROOT,
|
||||
)
|
||||
session2 = client.get_session()
|
||||
session_id_2 = session2.id
|
||||
# Open a second session.
|
||||
# session_id1 = session.session_id
|
||||
# TODO client.init_device(new_session=True)
|
||||
|
Loading…
Reference in New Issue
Block a user