fixup! feat(core): add Zcash shielded transactions

pull/2472/head
Tomas Krnak 2 years ago
parent 7a67e9a8ad
commit 92560d0ce3

@ -11,6 +11,7 @@ from trezor.ui.layouts.tt import Confirm, interact, raise_if_cancelled
from trezor.utils import chunks, chunks_intersperse, ensure from trezor.utils import chunks, chunks_intersperse, ensure
from apps.bitcoin.sign_tx.helpers import UiConfirm from apps.bitcoin.sign_tx.helpers import UiConfirm
from apps.common import paths
if TYPE_CHECKING: if TYPE_CHECKING:
from typing import Awaitable, Any from typing import Awaitable, Any
@ -21,6 +22,14 @@ if TYPE_CHECKING:
from trezor.ui.layouts.common import LayoutType from trezor.ui.layouts.common import LayoutType
class UiConfirmForeignPath(UiConfirm):
def __init__(self, path: paths.Bip32Path):
self.path = path
def confirm_dialog(self, ctx: Context) -> Awaitable[Any]:
return paths.show_path_warning(ctx, self.path)
class ConfirmOrchardInputsCountOverThreshold(UiConfirm): class ConfirmOrchardInputsCountOverThreshold(UiConfirm):
def __init__(self, orchard_inputs_count): def __init__(self, orchard_inputs_count):
self.orchard_inputs_count = orchard_inputs_count self.orchard_inputs_count = orchard_inputs_count

@ -9,16 +9,17 @@ from trezor.messages import TxRequest, ZcashAck, ZcashOrchardInput, ZcashOrchard
from trezor.wire import DataError from trezor.wire import DataError
from apps.bitcoin.sign_tx import helpers from apps.bitcoin.sign_tx import helpers
from core.src.apps.common.paths import PathSchema
from .. import unified from .. import unified
from ..hasher import ZcashHasher from ..hasher import ZcashHasher
from ..layout import ConfirmOrchardInputsCountOverThreshold from ..layout import ConfirmOrchardInputsCountOverThreshold, UiConfirmForeignPath
from .accumulator import MessageAccumulator from .accumulator import MessageAccumulator
from .crypto import builder, redpallas from .crypto import builder, redpallas
from .crypto.address import Address from .crypto.address import Address
from .crypto.note import Note from .crypto.note import Note
from .debug import watch_gc_async from .debug import watch_gc_async
from .keychain import OrchardKeychain from .keychain import PATTERN_ZIP32, OrchardKeychain
from .random import BundleShieldingRng from .random import BundleShieldingRng
if TYPE_CHECKING: if TYPE_CHECKING:
@ -71,6 +72,10 @@ class OrchardSigner:
async def process_inputs(self) -> None: async def process_inputs(self) -> None:
await self.check_orchard_inputs_count() await self.check_orchard_inputs_count()
if not PathSchema.parse(PATTERN_ZIP32, self.coin.slip44).match(
self.params.address_n
):
await confirm_foreign_path(self.params.address_n)
for i in range(self.params.inputs_count): for i in range(self.params.inputs_count):
txi = await self.get_input(i) txi = await self.get_input(i)
self.msg_acc.xor_message(txi, i) # add message to the accumulator self.msg_acc.xor_message(txi, i) # add message to the accumulator
@ -270,3 +275,7 @@ def pad(items: list[int | None], target_length: int) -> None:
def output_is_internal(txo: ZcashOrchardOutput) -> bool: def output_is_internal(txo: ZcashOrchardOutput) -> bool:
return txo.address is None return txo.address is None
def confirm_foreign_path(path: Bip32Path) -> Awaitable[Any]: # type: ignore [awaitable-is-generator]
yield UiConfirmForeignPath(path)

Loading…
Cancel
Save