mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-02-17 01:52:02 +00:00
core/bitcoin: Support preauthorization in GetOwnershipProof message.
This commit is contained in:
parent
c772de9d3c
commit
00258f2d4d
@ -14,7 +14,9 @@ from .keychain import with_keychain
|
|||||||
from .ownership import generate_proof, get_identifier
|
from .ownership import generate_proof, get_identifier
|
||||||
|
|
||||||
if False:
|
if False:
|
||||||
|
from typing import Optional
|
||||||
from apps.common.keychain import Keychain
|
from apps.common.keychain import Keychain
|
||||||
|
from .authorization import CoinJoinAuthorization
|
||||||
|
|
||||||
# Maximum number of characters per line in monospace font.
|
# Maximum number of characters per line in monospace font.
|
||||||
_MAX_MONO_LINE = 18
|
_MAX_MONO_LINE = 18
|
||||||
@ -22,17 +24,25 @@ _MAX_MONO_LINE = 18
|
|||||||
|
|
||||||
@with_keychain
|
@with_keychain
|
||||||
async def get_ownership_proof(
|
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:
|
) -> OwnershipProof:
|
||||||
await validate_path(
|
if authorization:
|
||||||
ctx,
|
if not authorization.check_get_ownership_proof(msg):
|
||||||
addresses.validate_full_path,
|
raise wire.ProcessError("Unauthorized operation")
|
||||||
keychain,
|
else:
|
||||||
msg.address_n,
|
await validate_path(
|
||||||
coin.curve_name,
|
ctx,
|
||||||
coin=coin,
|
addresses.validate_full_path,
|
||||||
script_type=msg.script_type,
|
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:
|
if msg.script_type not in common.INTERNAL_INPUT_SCRIPT_TYPES:
|
||||||
raise wire.DataError("Invalid script type")
|
raise wire.DataError("Invalid script type")
|
||||||
@ -57,7 +67,7 @@ async def get_ownership_proof(
|
|||||||
msg.ownership_ids = [ownership_id]
|
msg.ownership_ids = [ownership_id]
|
||||||
|
|
||||||
# In order to set the "user confirmation" bit in the proof, the user must actually confirm.
|
# 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 = Text("Proof of ownership", ui.ICON_CONFIG)
|
||||||
text.normal("Do you want to create a")
|
text.normal("Do you want to create a")
|
||||||
if not msg.commitment_data:
|
if not msg.commitment_data:
|
||||||
|
Loading…
Reference in New Issue
Block a user