mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-05-02 23:19:08 +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,8 +24,16 @@ _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:
|
||||||
|
if authorization:
|
||||||
|
if not authorization.check_get_ownership_proof(msg):
|
||||||
|
raise wire.ProcessError("Unauthorized operation")
|
||||||
|
else:
|
||||||
await validate_path(
|
await validate_path(
|
||||||
ctx,
|
ctx,
|
||||||
addresses.validate_full_path,
|
addresses.validate_full_path,
|
||||||
@ -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