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

pull/985/head
Andrew Kozlik 4 years ago committed by Andrew Kozlik
parent dccf415e0b
commit c9814e50ba

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

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

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

Loading…
Cancel
Save