1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-07-30 18:38:27 +00:00

fixup! feat(core): add Zcash shielded transactions

This commit is contained in:
Tomas Krnak 2022-11-17 21:25:36 +07:00
parent 8384dc6e58
commit 6d1adddb28

View File

@ -11,7 +11,7 @@ from apps.common import address_type
from apps.common.coininfo import CoinInfo, by_name from apps.common.coininfo import CoinInfo, by_name
from apps.common.paths import HARDENED, address_n_to_str from apps.common.paths import HARDENED, address_n_to_str
from .orchard import keychain as z_keychain from .orchard.keychain import OrchardKeychain
from .unified import Typecode, encode_address from .unified import Typecode, encode_address
if TYPE_CHECKING: if TYPE_CHECKING:
@ -31,7 +31,7 @@ async def get_address(ctx: Context, msg: ZcashGetAddress) -> ZcashAddress:
if msg.z_address_n: if msg.z_address_n:
receivers = {} receivers = {}
receivers[Typecode.ORCHARD] = await get_raw_orchard_address(ctx, msg) receivers[Typecode.ORCHARD] = await get_raw_orchard_address(ctx, coin, msg)
if msg.t_address_n: if msg.t_address_n:
if msg.t_address_n[2] != msg.z_address_n[2]: if msg.t_address_n[2] != msg.z_address_n[2]:
@ -70,10 +70,10 @@ async def get_raw_transparent_address(
return sha256_ripemd160(node.public_key()).digest() return sha256_ripemd160(node.public_key()).digest()
@z_keychain.with_keychain
async def get_raw_orchard_address( async def get_raw_orchard_address(
ctx: Context, msg: ZcashGetAddress, keychain: z_keychain.OrchardKeychain ctx: Context, coin: CoinInfo, msg: ZcashGetAddress
) -> bytes: ) -> bytes:
"""Returns raw Zcash Orchard address.""" """Returns raw Zcash Orchard address."""
keychain = await OrchardKeychain.for_coin(ctx, coin)
fvk = keychain.derive(msg.z_address_n).full_viewing_key() fvk = keychain.derive(msg.z_address_n).full_viewing_key()
return fvk.address(msg.diversifier_index).to_bytes() return fvk.address(msg.diversifier_index).to_bytes()