mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-17 20:08:12 +00:00
chore(trezorlib): Support payment requests and GetNonce command.
This commit is contained in:
parent
0e58218f5f
commit
f6154b311e
1
python/.changelog.d/1430.added
Normal file
1
python/.changelog.d/1430.added
Normal file
@ -0,0 +1 @@
|
||||
Support payment requests and GetNonce command.
|
@ -255,6 +255,7 @@ def sign_tx(
|
||||
outputs: Sequence[messages.TxOutputType],
|
||||
details: Optional[messages.SignTx] = None,
|
||||
prev_txes: Optional["TxCacheType"] = None,
|
||||
payment_reqs: Sequence[messages.TxAckPaymentRequest] = (),
|
||||
preauthorized: bool = False,
|
||||
**kwargs: Any,
|
||||
) -> Tuple[Sequence[Optional[bytes]], bytes]:
|
||||
@ -354,8 +355,12 @@ def sign_tx(
|
||||
else:
|
||||
current_tx = this_tx
|
||||
|
||||
if res.request_type == R.TXPAYMENTREQ:
|
||||
assert res.details.request_index is not None
|
||||
msg = payment_reqs[res.details.request_index]
|
||||
res = client.call(msg)
|
||||
else:
|
||||
msg = messages.TransactionType()
|
||||
|
||||
if res.request_type == R.TXMETA:
|
||||
msg = copy_tx_meta(current_tx)
|
||||
elif res.request_type in (R.TXINPUT, R.TXORIGINPUT):
|
||||
@ -364,7 +369,9 @@ def sign_tx(
|
||||
elif res.request_type == R.TXOUTPUT:
|
||||
assert res.details.request_index is not None
|
||||
if res.details.tx_hash:
|
||||
msg.bin_outputs = [current_tx.bin_outputs[res.details.request_index]]
|
||||
msg.bin_outputs = [
|
||||
current_tx.bin_outputs[res.details.request_index]
|
||||
]
|
||||
else:
|
||||
msg.outputs = [current_tx.outputs[res.details.request_index]]
|
||||
elif res.request_type == R.TXORIGOUTPUT:
|
||||
|
@ -108,3 +108,8 @@ def decrypt_keyvalue(
|
||||
iv=iv,
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@expect(messages.Nonce, field="nonce", ret_type=bytes)
|
||||
def get_nonce(client: "TrezorClient"):
|
||||
return client.call(messages.GetNonce())
|
||||
|
Loading…
Reference in New Issue
Block a user