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,
|
UnknownBaseUnit, DECIMAL_POINT_DEFAULT, UserFacingException,
|
||||||
get_new_wallet_name, send_exception_to_crash_reporter,
|
get_new_wallet_name, send_exception_to_crash_reporter,
|
||||||
InvalidBitcoinURI, maybe_extract_bolt11_invoice, NotEnoughFunds,
|
InvalidBitcoinURI, maybe_extract_bolt11_invoice, NotEnoughFunds,
|
||||||
NoDynamicFeeEstimates)
|
NoDynamicFeeEstimates, MultipleSpendMaxTxOutputs)
|
||||||
from electrum.util import PR_TYPE_ONCHAIN, PR_TYPE_LN
|
from electrum.util import PR_TYPE_ONCHAIN, PR_TYPE_LN
|
||||||
from electrum.transaction import (Transaction, PartialTxInput,
|
from electrum.transaction import (Transaction, PartialTxInput,
|
||||||
PartialTransaction, PartialTxOutput)
|
PartialTransaction, PartialTxOutput)
|
||||||
@@ -1317,7 +1317,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
tx = make_tx(None)
|
tx = make_tx(None)
|
||||||
except (NotEnoughFunds, NoDynamicFeeEstimates) as e:
|
except (NotEnoughFunds, NoDynamicFeeEstimates, MultipleSpendMaxTxOutputs) as e:
|
||||||
self.max_button.setChecked(False)
|
self.max_button.setChecked(False)
|
||||||
self.show_error(str(e))
|
self.show_error(str(e))
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -155,6 +155,11 @@ class NoDynamicFeeEstimates(Exception):
|
|||||||
return _('Dynamic fee estimates not available')
|
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):
|
class InvalidPassword(Exception):
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return _("Incorrect password")
|
return _("Incorrect password")
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ from .bip32 import BIP32Node
|
|||||||
from .crypto import sha256
|
from .crypto import sha256
|
||||||
from .util import (NotEnoughFunds, UserCancelled, profiler,
|
from .util import (NotEnoughFunds, UserCancelled, profiler,
|
||||||
format_satoshis, format_fee_satoshis, NoDynamicFeeEstimates,
|
format_satoshis, format_fee_satoshis, NoDynamicFeeEstimates,
|
||||||
WalletFileException, BitcoinException,
|
WalletFileException, BitcoinException, MultipleSpendMaxTxOutputs,
|
||||||
InvalidPassword, format_time, timestamp_to_datetime, Satoshis,
|
InvalidPassword, format_time, timestamp_to_datetime, Satoshis,
|
||||||
Fiat, bfh, bh2u, TxMinedInfo, quantize_feerate, create_bip21_uri, OrderedDictWithIndex)
|
Fiat, bfh, bh2u, TxMinedInfo, quantize_feerate, create_bip21_uri, OrderedDictWithIndex)
|
||||||
from .util import PR_TYPE_ONCHAIN, PR_TYPE_LN
|
from .util import PR_TYPE_ONCHAIN, PR_TYPE_LN
|
||||||
@@ -993,7 +993,7 @@ class Abstract_Wallet(AddressSynchronizer, ABC):
|
|||||||
for i, o in enumerate(outputs):
|
for i, o in enumerate(outputs):
|
||||||
if o.value == '!':
|
if o.value == '!':
|
||||||
if i_max is not None:
|
if i_max is not None:
|
||||||
raise Exception("More than one output set to spend max")
|
raise MultipleSpendMaxTxOutputs()
|
||||||
i_max = i
|
i_max = i
|
||||||
|
|
||||||
if fee is None and self.config.fee_per_kb() is None:
|
if fee is None and self.config.fee_per_kb() is None:
|
||||||
|
|||||||
Reference in New Issue
Block a user