diff --git a/electrum/gui/qt/utxo_list.py b/electrum/gui/qt/utxo_list.py index 610bd527c..bc57860ef 100644 --- a/electrum/gui/qt/utxo_list.py +++ b/electrum/gui/qt/utxo_list.py @@ -25,6 +25,7 @@ from typing import Optional, List, Dict, Sequence, Set from enum import IntEnum +import copy from PyQt5.QtCore import Qt from PyQt5.QtGui import QStandardItemModel, QStandardItem, QFont @@ -140,7 +141,8 @@ class UTXOList(MyTreeView): def get_spend_list(self) -> Optional[Sequence[PartialTxInput]]: if self._spend_set is None: return None - return [self.utxo_dict[x] for x in self._spend_set] + utxos = [self.utxo_dict[x] for x in self._spend_set] + return copy.deepcopy(utxos) # copy so that side-effects don't affect utxo_dict def _maybe_reset_spend_list(self, current_wallet_utxos: Sequence[PartialTxInput]) -> None: if self._spend_set is None: diff --git a/electrum/transaction.py b/electrum/transaction.py index 17aafe1ff..d361c0afe 100644 --- a/electrum/transaction.py +++ b/electrum/transaction.py @@ -1344,6 +1344,12 @@ class PartialTxInput(TxInput, PSBTSection): self._is_p2sh_segwit = calc_if_p2sh_segwit_now() return self._is_p2sh_segwit + def already_has_some_signatures(self) -> bool: + """Returns whether progress has been made towards completing this input.""" + return (self.part_sigs + or self.script_sig is not None + or self.witness is not None) + class PartialTxOutput(TxOutput, PSBTSection): def __init__(self, *args, **kwargs): diff --git a/electrum/wallet.py b/electrum/wallet.py index a8047798f..cc4fc5a04 100644 --- a/electrum/wallet.py +++ b/electrum/wallet.py @@ -978,6 +978,9 @@ class Abstract_Wallet(AddressSynchronizer): outputs: List[PartialTxOutput], fee=None, change_addr: str = None, is_sweep=False) -> PartialTransaction: + if any([c.already_has_some_signatures() for c in coins]): + raise Exception("Some inputs already contain signatures!") + # prevent side-effect with '!' outputs = copy.deepcopy(outputs)