qt paytoedit: properly handle multiple max ('!') outputs
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user