Browse Source

qt paytoedit: properly handle multiple max ('!') outputs

master
SomberNight 6 years ago
parent
commit
6d270364c6
No known key found for this signature in database
GPG Key ID: B33B5F232C6271E9
  1. 4
      electrum/gui/qt/main_window.py
  2. 5
      electrum/util.py
  3. 4
      electrum/wallet.py

4
electrum/gui/qt/main_window.py

@ -61,7 +61,7 @@ from electrum.util import (format_time, format_satoshis, format_fee_satoshis,
UnknownBaseUnit, DECIMAL_POINT_DEFAULT, UserFacingException,
get_new_wallet_name, send_exception_to_crash_reporter,
InvalidBitcoinURI, maybe_extract_bolt11_invoice, NotEnoughFunds,
NoDynamicFeeEstimates)
NoDynamicFeeEstimates, MultipleSpendMaxTxOutputs)
from electrum.util import PR_TYPE_ONCHAIN, PR_TYPE_LN
from electrum.transaction import (Transaction, PartialTxInput,
PartialTransaction, PartialTxOutput)
@ -1317,7 +1317,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
try:
tx = make_tx(None)
except (NotEnoughFunds, NoDynamicFeeEstimates) as e:
except (NotEnoughFunds, NoDynamicFeeEstimates, MultipleSpendMaxTxOutputs) as e:
self.max_button.setChecked(False)
self.show_error(str(e))
return

5
electrum/util.py

@ -155,6 +155,11 @@ class NoDynamicFeeEstimates(Exception):
return _('Dynamic fee estimates not available')
class MultipleSpendMaxTxOutputs(Exception):
def __str__(self):
return _('At most one output can be set to spend max')
class InvalidPassword(Exception):
def __str__(self):
return _("Incorrect password")

4
electrum/wallet.py

@ -48,7 +48,7 @@ from .bip32 import BIP32Node
from .crypto import sha256
from .util import (NotEnoughFunds, UserCancelled, profiler,
format_satoshis, format_fee_satoshis, NoDynamicFeeEstimates,
WalletFileException, BitcoinException,
WalletFileException, BitcoinException, MultipleSpendMaxTxOutputs,
InvalidPassword, format_time, timestamp_to_datetime, Satoshis,
Fiat, bfh, bh2u, TxMinedInfo, quantize_feerate, create_bip21_uri, OrderedDictWithIndex)
from .util import PR_TYPE_ONCHAIN, PR_TYPE_LN
@ -993,7 +993,7 @@ class Abstract_Wallet(AddressSynchronizer, ABC):
for i, o in enumerate(outputs):
if o.value == '!':
if i_max is not None:
raise Exception("More than one output set to spend max")
raise MultipleSpendMaxTxOutputs()
i_max = i
if fee is None and self.config.fee_per_kb() is None:

Loading…
Cancel
Save