fix #2353: show error when sweeping dust
This commit is contained in:
parent
b8e2c67b54
commit
50587c7a24
|
@ -2306,9 +2306,10 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
|
||||||
if not d.exec_():
|
if not d.exec_():
|
||||||
return
|
return
|
||||||
|
|
||||||
tx = self.wallet.sweep(get_pk(), self.network, self.config, get_address(), None)
|
try:
|
||||||
if not tx:
|
tx = self.wallet.sweep(get_pk(), self.network, self.config, get_address(), None)
|
||||||
self.show_message(_('No inputs found. (Note that inputs need to be confirmed)'))
|
except BaseException as e:
|
||||||
|
self.show_message(str(e))
|
||||||
return
|
return
|
||||||
self.warn_if_watching_only()
|
self.warn_if_watching_only()
|
||||||
self.show_transaction(tx)
|
self.show_transaction(tx)
|
||||||
|
|
|
@ -892,7 +892,7 @@ class Abstract_Wallet(PrintError):
|
||||||
keypairs[pubkey] = privkey
|
keypairs[pubkey] = privkey
|
||||||
|
|
||||||
if not inputs:
|
if not inputs:
|
||||||
return
|
raise BaseException(_('No inputs found. (Note that inputs need to be confirmed)'))
|
||||||
|
|
||||||
total = sum(i.get('value') for i in inputs)
|
total = sum(i.get('value') for i in inputs)
|
||||||
if fee is None:
|
if fee is None:
|
||||||
|
@ -900,6 +900,12 @@ class Abstract_Wallet(PrintError):
|
||||||
tx = Transaction.from_io(inputs, outputs)
|
tx = Transaction.from_io(inputs, outputs)
|
||||||
fee = self.estimate_fee(config, tx.estimated_size())
|
fee = self.estimate_fee(config, tx.estimated_size())
|
||||||
|
|
||||||
|
if total - fee < 0:
|
||||||
|
raise BaseException(_('Not enough funds on address.') + '\nTotal: %d satoshis\nFee: %d\nDust Threshold: %d'%(total, fee))
|
||||||
|
|
||||||
|
if total - fee < self.dust_threshold():
|
||||||
|
raise BaseException(_('Not enough funds on address.') + '\nTotal: %d satoshis\nFee: %d\nDust Threshold: %d'%(total, fee, self.dust_threshold()))
|
||||||
|
|
||||||
outputs = [(TYPE_ADDRESS, recipient, total - fee)]
|
outputs = [(TYPE_ADDRESS, recipient, total - fee)]
|
||||||
tx = Transaction.from_io(inputs, outputs)
|
tx = Transaction.from_io(inputs, outputs)
|
||||||
tx.sign(keypairs)
|
tx.sign(keypairs)
|
||||||
|
|
Loading…
Reference in New Issue