Browse Source

(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.
hard-fail-on-bad-server-string
SomberNight 5 years ago
parent
commit
61aebd0f2d
No known key found for this signature in database GPG Key ID: B33B5F232C6271E9
  1. 4
      electrum/gui/qt/utxo_list.py
  2. 6
      electrum/transaction.py
  3. 3
      electrum/wallet.py

4
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:

6
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):

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

Loading…
Cancel
Save