1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-22 22:38:08 +00:00

core/bitcoin: Support preauthorization in GetOwnershipProof message.

This commit is contained in:
Andrew Kozlik 2020-07-23 17:04:16 +02:00 committed by Andrew Kozlik
parent c772de9d3c
commit 00258f2d4d

View File

@ -14,7 +14,9 @@ from .keychain import with_keychain
from .ownership import generate_proof, get_identifier
if False:
from typing import Optional
from apps.common.keychain import Keychain
from .authorization import CoinJoinAuthorization
# Maximum number of characters per line in monospace font.
_MAX_MONO_LINE = 18
@ -22,17 +24,25 @@ _MAX_MONO_LINE = 18
@with_keychain
async def get_ownership_proof(
ctx, msg: GetOwnershipProof, keychain: Keychain, coin: coininfo.CoinInfo
ctx,
msg: GetOwnershipProof,
keychain: Keychain,
coin: coininfo.CoinInfo,
authorization: Optional[CoinJoinAuthorization] = None,
) -> OwnershipProof:
await validate_path(
ctx,
addresses.validate_full_path,
keychain,
msg.address_n,
coin.curve_name,
coin=coin,
script_type=msg.script_type,
)
if authorization:
if not authorization.check_get_ownership_proof(msg):
raise wire.ProcessError("Unauthorized operation")
else:
await validate_path(
ctx,
addresses.validate_full_path,
keychain,
msg.address_n,
coin.curve_name,
coin=coin,
script_type=msg.script_type,
)
if msg.script_type not in common.INTERNAL_INPUT_SCRIPT_TYPES:
raise wire.DataError("Invalid script type")
@ -57,7 +67,7 @@ async def get_ownership_proof(
msg.ownership_ids = [ownership_id]
# In order to set the "user confirmation" bit in the proof, the user must actually confirm.
if msg.user_confirmation:
if msg.user_confirmation and not authorization:
text = Text("Proof of ownership", ui.ICON_CONFIG)
text.normal("Do you want to create a")
if not msg.commitment_data: