diff --git a/core/src/apps/wallet/sign_tx/decred.py b/core/src/apps/wallet/sign_tx/decred.py index be8f311a72..da746fbcba 100644 --- a/core/src/apps/wallet/sign_tx/decred.py +++ b/core/src/apps/wallet/sign_tx/decred.py @@ -61,7 +61,7 @@ class Decred(Bitcoin): async def confirm_output( self, i: int, txo: TxOutputType, txo_bin: TxOutputBinType ) -> None: - if txo.decred_script_version is not None and txo.decred_script_version != 0: + if txo.decred_script_version != 0: raise SigningError( FailureType.ActionCancelled, "Cannot send to output with script version != 0", @@ -141,10 +141,7 @@ class Decred(Bitcoin): await helpers.request_tx_finish(self.tx_req) def check_prevtx_output(self, txo_bin: TxOutputBinType) -> None: - if ( - txo_bin.decred_script_version is not None - and txo_bin.decred_script_version != 0 - ): + if txo_bin.decred_script_version != 0: raise SigningError( FailureType.ProcessError, "Cannot use utxo that has script_version != 0", diff --git a/core/src/apps/wallet/sign_tx/helpers.py b/core/src/apps/wallet/sign_tx/helpers.py index 520f09867a..0b0072f607 100644 --- a/core/src/apps/wallet/sign_tx/helpers.py +++ b/core/src/apps/wallet/sign_tx/helpers.py @@ -307,8 +307,12 @@ def sanitize_tx_binoutput(tx: TransactionType, coin: CoinInfo) -> TxOutputBinTyp def _sanitize_decred( tx: Union[TxInputType, TxOutputType, TxOutputBinType], coin: CoinInfo ) -> None: - if not coin.decred and tx.decred_script_version is not None: - raise SigningError( - FailureType.DataError, - "Decred details provided but Decred coin not specified.", - ) + if coin.decred: + if tx.decred_script_version is None: + tx.decred_script_version = 0 + else: + if tx.decred_script_version is not None: + raise SigningError( + FailureType.DataError, + "Decred details provided but Decred coin not specified.", + ) diff --git a/core/src/apps/wallet/sign_tx/writers.py b/core/src/apps/wallet/sign_tx/writers.py index 938fa7d302..fc1386f8e1 100644 --- a/core/src/apps/wallet/sign_tx/writers.py +++ b/core/src/apps/wallet/sign_tx/writers.py @@ -71,8 +71,7 @@ def write_tx_output(w: Writer, o: TxOutputBinType) -> None: def write_tx_output_decred(w: Writer, o: TxOutputBinType) -> None: write_uint64(w, o.amount) - if o.decred_script_version is not None: - write_uint16(w, o.decred_script_version) + write_uint16(w, o.decred_script_version) write_bytes_prefixed(w, o.script_pubkey)