qt: fix sweeping
closes https://github.com/spesmilo/electrum/issues/8340
regression from 2f6d60c715
This commit is contained in:
@@ -1050,8 +1050,8 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger, QtEventListener):
|
|||||||
from .channel_details import ChannelDetailsDialog
|
from .channel_details import ChannelDetailsDialog
|
||||||
ChannelDetailsDialog(self, chan).show()
|
ChannelDetailsDialog(self, chan).show()
|
||||||
|
|
||||||
def show_transaction(self, tx: Transaction):
|
def show_transaction(self, tx: Transaction, *, external_keypairs=None):
|
||||||
show_transaction(tx, parent=self)
|
show_transaction(tx, parent=self, external_keypairs=external_keypairs)
|
||||||
|
|
||||||
def show_lightning_transaction(self, tx_item):
|
def show_lightning_transaction(self, tx_item):
|
||||||
from .lightning_tx_dialog import LightningTxDialog
|
from .lightning_tx_dialog import LightningTxDialog
|
||||||
@@ -1174,7 +1174,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger, QtEventListener):
|
|||||||
invoice = self.wallet.get_invoice(key)
|
invoice = self.wallet.get_invoice(key)
|
||||||
if invoice and invoice.is_lightning() and invoice.get_address():
|
if invoice and invoice.is_lightning() and invoice.get_address():
|
||||||
if self.question(_('Payment failed') + '\n\n' + reason + '\n\n'+ 'Fallback to onchain payment?'):
|
if self.question(_('Payment failed') + '\n\n' + reason + '\n\n'+ 'Fallback to onchain payment?'):
|
||||||
self.send_tab.pay_onchain_dialog(self.get_coins(), invoice.get_outputs())
|
self.send_tab.pay_onchain_dialog(invoice.get_outputs())
|
||||||
else:
|
else:
|
||||||
self.show_error(_('Payment failed') + '\n\n' + reason)
|
self.show_error(_('Payment failed') + '\n\n' + reason)
|
||||||
|
|
||||||
@@ -2387,6 +2387,9 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger, QtEventListener):
|
|||||||
|
|
||||||
|
|
||||||
def sweep_key_dialog(self):
|
def sweep_key_dialog(self):
|
||||||
|
if not self.network:
|
||||||
|
self.show_error(_("You are offline."))
|
||||||
|
return
|
||||||
d = WindowModalDialog(self, title=_('Sweep private keys'))
|
d = WindowModalDialog(self, title=_('Sweep private keys'))
|
||||||
d.setMinimumSize(600, 300)
|
d.setMinimumSize(600, 300)
|
||||||
vbox = QVBoxLayout(d)
|
vbox = QVBoxLayout(d)
|
||||||
@@ -2450,7 +2453,8 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger, QtEventListener):
|
|||||||
coins, keypairs = result
|
coins, keypairs = result
|
||||||
outputs = [PartialTxOutput.from_address_and_value(addr, value='!')]
|
outputs = [PartialTxOutput.from_address_and_value(addr, value='!')]
|
||||||
self.warn_if_watching_only()
|
self.warn_if_watching_only()
|
||||||
self.send_tab.pay_onchain_dialog(coins, outputs, external_keypairs=keypairs)
|
self.send_tab.pay_onchain_dialog(
|
||||||
|
outputs, external_keypairs=keypairs, get_coins=lambda *args, **kwargs: coins)
|
||||||
def on_failure(exc_info):
|
def on_failure(exc_info):
|
||||||
self.on_error(exc_info)
|
self.on_error(exc_info)
|
||||||
msg = _('Preparing sweep transaction...')
|
msg = _('Preparing sweep transaction...')
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
from typing import Optional, TYPE_CHECKING, Sequence, List
|
from typing import Optional, TYPE_CHECKING, Sequence, List, Callable, Any
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
from PyQt5.QtCore import pyqtSignal, QPoint
|
from PyQt5.QtCore import pyqtSignal, QPoint
|
||||||
@@ -238,14 +238,18 @@ class SendTab(QWidget, MessageBoxMixin, Logger):
|
|||||||
self,
|
self,
|
||||||
outputs: List[PartialTxOutput], *,
|
outputs: List[PartialTxOutput], *,
|
||||||
nonlocal_only=False,
|
nonlocal_only=False,
|
||||||
external_keypairs=None) -> None:
|
external_keypairs=None,
|
||||||
|
get_coins: Callable[..., Sequence[PartialTxInput]] = None,
|
||||||
|
) -> None:
|
||||||
# trustedcoin requires this
|
# trustedcoin requires this
|
||||||
if run_hook('abort_send', self):
|
if run_hook('abort_send', self):
|
||||||
return
|
return
|
||||||
is_sweep = bool(external_keypairs)
|
is_sweep = bool(external_keypairs)
|
||||||
# we call get_coins inside make_tx, so that inputs can be changed dynamically
|
# we call get_coins inside make_tx, so that inputs can be changed dynamically
|
||||||
|
if get_coins is None:
|
||||||
|
get_coins = self.window.get_coins
|
||||||
make_tx = lambda fee_est, *, confirmed_only=False: self.wallet.make_unsigned_transaction(
|
make_tx = lambda fee_est, *, confirmed_only=False: self.wallet.make_unsigned_transaction(
|
||||||
coins=self.window.get_coins(nonlocal_only=nonlocal_only, confirmed_only=confirmed_only),
|
coins=get_coins(nonlocal_only=nonlocal_only, confirmed_only=confirmed_only),
|
||||||
outputs=outputs,
|
outputs=outputs,
|
||||||
fee=fee_est,
|
fee=fee_est,
|
||||||
is_sweep=is_sweep)
|
is_sweep=is_sweep)
|
||||||
@@ -266,7 +270,7 @@ class SendTab(QWidget, MessageBoxMixin, Logger):
|
|||||||
return
|
return
|
||||||
is_preview = conf_dlg.is_preview
|
is_preview = conf_dlg.is_preview
|
||||||
if is_preview:
|
if is_preview:
|
||||||
self.window.show_transaction(tx)
|
self.window.show_transaction(tx, external_keypairs=external_keypairs)
|
||||||
return
|
return
|
||||||
self.save_pending_invoice()
|
self.save_pending_invoice()
|
||||||
def sign_done(success):
|
def sign_done(success):
|
||||||
|
|||||||
@@ -372,10 +372,15 @@ class TxInOutWidget(QWidget):
|
|||||||
menu.exec_(global_pos)
|
menu.exec_(global_pos)
|
||||||
|
|
||||||
|
|
||||||
|
def show_transaction(
|
||||||
def show_transaction(tx: Transaction, *, parent: 'ElectrumWindow', prompt_if_unsaved=False):
|
tx: Transaction,
|
||||||
|
*,
|
||||||
|
parent: 'ElectrumWindow',
|
||||||
|
prompt_if_unsaved: bool = False,
|
||||||
|
external_keypairs=None,
|
||||||
|
):
|
||||||
try:
|
try:
|
||||||
d = TxDialog(tx, parent=parent, prompt_if_unsaved=prompt_if_unsaved)
|
d = TxDialog(tx, parent=parent, prompt_if_unsaved=prompt_if_unsaved, external_keypairs=external_keypairs)
|
||||||
except SerializationError as e:
|
except SerializationError as e:
|
||||||
_logger.exception('unable to deserialize the transaction')
|
_logger.exception('unable to deserialize the transaction')
|
||||||
parent.show_critical(_("Electrum was unable to deserialize the transaction:") + "\n" + str(e))
|
parent.show_critical(_("Electrum was unable to deserialize the transaction:") + "\n" + str(e))
|
||||||
@@ -383,13 +388,11 @@ def show_transaction(tx: Transaction, *, parent: 'ElectrumWindow', prompt_if_uns
|
|||||||
d.show()
|
d.show()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class TxDialog(QDialog, MessageBoxMixin):
|
class TxDialog(QDialog, MessageBoxMixin):
|
||||||
|
|
||||||
throttled_update_sig = pyqtSignal() # emit from thread to do update in main thread
|
throttled_update_sig = pyqtSignal() # emit from thread to do update in main thread
|
||||||
|
|
||||||
def __init__(self, tx: Transaction, *, parent: 'ElectrumWindow', prompt_if_unsaved, external_keypairs=None):
|
def __init__(self, tx: Transaction, *, parent: 'ElectrumWindow', prompt_if_unsaved: bool, external_keypairs=None):
|
||||||
'''Transactions in the wallet will show their description.
|
'''Transactions in the wallet will show their description.
|
||||||
Pass desc to give a description for txs not yet in the wallet.
|
Pass desc to give a description for txs not yet in the wallet.
|
||||||
'''
|
'''
|
||||||
|
|||||||
Reference in New Issue
Block a user