URI: 
       tMerge pull request #3380 from SomberNight/sweep_to_use_send_tab - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
   DIR commit f0eb5536814bc821c93c9c09613dddf58bea7f5f
   DIR parent 683495b3257b3391561148f5fd69b3be737a4eac
  HTML Author: ThomasV <thomasv@electrum.org>
       Date:   Thu, 30 Nov 2017 13:42:33 +0100
       
       Merge pull request #3380 from SomberNight/sweep_to_use_send_tab
       
       use the send tab when sweeping (qt gui)
       Diffstat:
         M gui/qt/main_window.py               |      19 +++++++++++++++----
         M gui/qt/transaction_dialog.py        |       4 +++-
         M lib/wallet.py                       |       7 ++++++-
       
       3 files changed, 24 insertions(+), 6 deletions(-)
       ---
   DIR diff --git a/gui/qt/main_window.py b/gui/qt/main_window.py
       t@@ -118,6 +118,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
                self.require_fee_update = False
                self.tx_notifications = []
                self.tl_windows = []
       +        self.tx_external_keypairs = {}
        
                self.create_status_bar()
                self.need_update = threading.Event()
       t@@ -1414,7 +1415,10 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
                    self.on_error(exc_info)
                    callback(False)
        
       -        task = partial(self.wallet.sign_transaction, tx, password)
       +        if self.tx_external_keypairs:
       +            task = partial(Transaction.sign, tx, self.tx_external_keypairs)
       +        else:
       +            task = partial(self.wallet.sign_transaction, tx, password)
                WaitingDialog(self, _('Signing transaction...'), task,
                              on_signed, on_failed)
        
       t@@ -1557,6 +1561,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
                    e.setFrozen(False)
                self.set_pay_from([])
                self.rbf_checkbox.setChecked(False)
       +        self.tx_external_keypairs = {}
                self.update_status()
                run_hook('do_clear', self)
        
       t@@ -2364,14 +2369,20 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
                address_e.textChanged.connect(on_address)
                if not d.exec_():
                    return
       -        from electrum.wallet import sweep
       +        from electrum.wallet import sweep_preparations
                try:
       -            tx = sweep(get_pk(), self.network, self.config, get_address(), None)
       +            self.do_clear()
       +            coins, keypairs = sweep_preparations(get_pk(), self.network)
       +            self.tx_external_keypairs = keypairs
       +            self.spend_coins(coins)
       +            self.payto_e.setText(get_address())
       +            self.spend_max()
       +            self.payto_e.setFrozen(True)
       +            self.amount_e.setFrozen(True)
                except BaseException as e:
                    self.show_message(str(e))
                    return
                self.warn_if_watching_only()
       -        self.show_transaction(tx)
        
            def _do_import(self, title, msg, func):
                text = text_dialog(self, title, msg + ' :', _('Import'))
   DIR diff --git a/gui/qt/transaction_dialog.py b/gui/qt/transaction_dialog.py
       t@@ -178,7 +178,9 @@ class TxDialog(QDialog, MessageBoxMixin):
                tx_hash, status, label, can_broadcast, can_rbf, amount, fee, height, conf, timestamp, exp_n = self.wallet.get_tx_info(self.tx)
                size = self.tx.estimated_size()
                self.broadcast_button.setEnabled(can_broadcast)
       -        self.sign_button.setEnabled(self.wallet.can_sign(self.tx))
       +        can_sign = not self.tx.is_complete() and \
       +            (self.wallet.can_sign(self.tx) or bool(self.main_window.tx_external_keypairs))
       +        self.sign_button.setEnabled(can_sign)
                self.tx_hash_e.setText(tx_hash or _('Unknown'))
                if desc is None:
                    self.tx_desc.hide()
   DIR diff --git a/lib/wallet.py b/lib/wallet.py
       t@@ -101,7 +101,7 @@ def append_utxos_to_inputs(inputs, network, pubkey, txin_type, imax):
                item['num_sig'] = 1
                inputs.append(item)
        
       -def sweep(privkeys, network, config, recipient, fee=None, imax=100):
       +def sweep_preparations(privkeys, network, imax=100):
        
            def find_utxos_for_privkey(txin_type, privkey, compressed):
                pubkey = bitcoin.public_key_from_private_key(privkey, compressed)
       t@@ -123,6 +123,11 @@ def sweep(privkeys, network, config, recipient, fee=None, imax=100):
                    find_utxos_for_privkey('p2pk', privkey, compressed)
            if not inputs:
                raise BaseException(_('No inputs found. (Note that inputs need to be confirmed)'))
       +    return inputs, keypairs
       +
       +
       +def sweep(privkeys, network, config, recipient, fee=None, imax=100):
       +    inputs, keypairs = sweep_preparations(privkeys, network, imax)
            total = sum(i.get('value') for i in inputs)
            if fee is None:
                outputs = [(TYPE_ADDRESS, recipient, total)]