1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-22 06:18:07 +00:00

core/sign_tx: Set decred_script_version to 0 by default for decred coins.

This commit is contained in:
Andrew Kozlik 2020-05-05 10:37:53 +02:00 committed by Andrew Kozlik
parent dccf415e0b
commit c9814e50ba
3 changed files with 12 additions and 12 deletions

View File

@ -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",

View File

@ -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.",
)

View File

@ -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)