From 7653efb4155a67df22988089d16b4a07c1534c60 Mon Sep 17 00:00:00 2001 From: Andrew Kozlik Date: Wed, 27 Oct 2021 15:52:31 +0200 Subject: [PATCH] chore(core): Disable Taproot for altcoins. --- core/src/apps/bitcoin/get_ownership_id.py | 4 ++++ core/src/apps/bitcoin/get_ownership_proof.py | 4 ++++ core/src/apps/bitcoin/sign_tx/helpers.py | 6 ++++++ 3 files changed, 14 insertions(+) diff --git a/core/src/apps/bitcoin/get_ownership_id.py b/core/src/apps/bitcoin/get_ownership_id.py index 479dbd05f..d95ea931e 100644 --- a/core/src/apps/bitcoin/get_ownership_id.py +++ b/core/src/apps/bitcoin/get_ownership_id.py @@ -1,4 +1,5 @@ from trezor import wire +from trezor.enums import InputScriptType from trezor.messages import GetOwnershipId, OwnershipId from apps.common.paths import validate_path @@ -29,6 +30,9 @@ async def get_ownership_id( if msg.script_type in common.SEGWIT_INPUT_SCRIPT_TYPES and not coin.segwit: raise wire.DataError("Segwit not enabled on this coin") + if msg.script_type == InputScriptType.SPENDTAPROOT and not coin.taproot: + raise wire.DataError("Taproot not enabled on this coin") + node = keychain.derive(msg.address_n) address = addresses.get_address(msg.script_type, coin, node, msg.multisig) script_pubkey = scripts.output_derive_script(address, coin) diff --git a/core/src/apps/bitcoin/get_ownership_proof.py b/core/src/apps/bitcoin/get_ownership_proof.py index a451d4974..7d44c1166 100644 --- a/core/src/apps/bitcoin/get_ownership_proof.py +++ b/core/src/apps/bitcoin/get_ownership_proof.py @@ -1,4 +1,5 @@ from trezor import ui, wire +from trezor.enums import InputScriptType from trezor.messages import GetOwnershipProof, OwnershipProof from trezor.ui.layouts import confirm_action, confirm_blob @@ -42,6 +43,9 @@ async def get_ownership_proof( if msg.script_type in common.SEGWIT_INPUT_SCRIPT_TYPES and not coin.segwit: raise wire.DataError("Segwit not enabled on this coin") + if msg.script_type == InputScriptType.SPENDTAPROOT and not coin.taproot: + raise wire.DataError("Taproot not enabled on this coin") + node = keychain.derive(msg.address_n) address = addresses.get_address(msg.script_type, coin, node, msg.multisig) script_pubkey = scripts.output_derive_script(address, coin) diff --git a/core/src/apps/bitcoin/sign_tx/helpers.py b/core/src/apps/bitcoin/sign_tx/helpers.py index 8ef82d195..84ec7d871 100644 --- a/core/src/apps/bitcoin/sign_tx/helpers.py +++ b/core/src/apps/bitcoin/sign_tx/helpers.py @@ -412,6 +412,9 @@ def sanitize_tx_input(txi: TxInput, coin: CoinInfo) -> TxInput: if not coin.segwit: raise wire.DataError("Segwit not enabled on this coin.") + if txi.script_type == InputScriptType.SPENDTAPROOT and not coin.taproot: + raise wire.DataError("Taproot not enabled on this coin") + if txi.commitment_data and not txi.ownership_proof: raise wire.DataError("commitment_data field provided but not expected.") @@ -448,6 +451,9 @@ def sanitize_tx_output(txo: TxOutput, coin: CoinInfo) -> TxOutput: if not coin.segwit: raise wire.DataError("Segwit not enabled on this coin.") + if txo.script_type == OutputScriptType.PAYTOTAPROOT and not coin.taproot: + raise wire.DataError("Taproot not enabled on this coin") + if txo.script_type == OutputScriptType.PAYTOOPRETURN: # op_return output if txo.op_return_data is None: