electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 61aebd0f2dbf83b8e0f6c043036f8f7301b4a158
parent 428b63822b359d56d6ececabf406a43589545d24
Author: SomberNight <somber.night@protonmail.com>
Date:   Fri,  6 Dec 2019 19:45:55 +0100

(fix) qt coin selection: signatures for coins would persist in memory

Scenario: select some UTXOs in the 'Coins' tab. Create a tx and sign it.
Close the tx dialog without broadcasting/etc (cancel tx).
Signatures would remain for selected UTXOs.
Create new tx -> invalid sigs.

Diffstat:
Melectrum/gui/qt/utxo_list.py | 4+++-
Melectrum/transaction.py | 6++++++
Melectrum/wallet.py | 3+++
3 files changed, 12 insertions(+), 1 deletion(-)

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