1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-17 21:22:10 +00:00

python: Support preauthorized operations in trezorlib.

This commit is contained in:
Andrew Kozlik 2020-07-16 19:17:43 +02:00 committed by Andrew Kozlik
parent 84c1324290
commit 85cf79169c

View File

@ -118,7 +118,13 @@ def get_ownership_proof(
user_confirmation=False,
ownership_ids=None,
commitment_data=None,
preauthorized=False,
):
if preauthorized:
res = client.call(messages.DoPreauthorized())
if not isinstance(res, messages.PreauthorizedRequest):
raise exceptions.TrezorException("Unexpected message")
res = client.call(
messages.GetOwnershipProof(
address_n=n,
@ -130,6 +136,7 @@ def get_ownership_proof(
commitment_data=commitment_data,
)
)
if not isinstance(res, messages.OwnershipProof):
raise exceptions.TrezorException("Unexpected message")
@ -165,7 +172,15 @@ def verify_message(client, coin_name, address, signature, message):
@session
def sign_tx(client, coin_name, inputs, outputs, details=None, prev_txes=None):
def sign_tx(
client,
coin_name,
inputs,
outputs,
details=None,
prev_txes=None,
preauthorized=False,
):
this_tx = messages.TransactionType(inputs=inputs, outputs=outputs)
if details is None:
@ -177,6 +192,11 @@ def sign_tx(client, coin_name, inputs, outputs, details=None, prev_txes=None):
signtx.inputs_count = len(inputs)
signtx.outputs_count = len(outputs)
if preauthorized:
res = client.call(messages.DoPreauthorized())
if not isinstance(res, messages.PreauthorizedRequest):
raise exceptions.TrezorException("Unexpected message")
res = client.call(signtx)
# Prepare structure for signatures