From ec99304ae142f998ff87934756f81e211545dda8 Mon Sep 17 00:00:00 2001 From: SomberNight Date: Mon, 11 Dec 2017 17:37:10 +0100 Subject: [PATCH] fix sweeping for 2fa wallets --- gui/qt/main_window.py | 13 +++++++++---- lib/wallet.py | 3 ++- plugins/trustedcoin/trustedcoin.py | 6 +++--- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/gui/qt/main_window.py b/gui/qt/main_window.py index 51c9f0e0..cc61ebee 100644 --- a/gui/qt/main_window.py +++ b/gui/qt/main_window.py @@ -1190,7 +1190,9 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError): _type, addr = self.get_payto_or_dummy() outputs = [(_type, addr, amount)] try: - tx = self.wallet.make_unsigned_transaction(self.get_coins(), outputs, self.config, fee) + is_sweep = bool(self.tx_external_keypairs) + tx = self.wallet.make_unsigned_transaction( + self.get_coins(), outputs, self.config, fee, is_sweep=is_sweep) self.not_enough_funds = False except NotEnoughFunds: self.not_enough_funds = True @@ -1339,7 +1341,9 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError): return outputs, fee, tx_desc, coins = r try: - tx = self.wallet.make_unsigned_transaction(coins, outputs, self.config, fee) + is_sweep = bool(self.tx_external_keypairs) + tx = self.wallet.make_unsigned_transaction( + coins, outputs, self.config, fee, is_sweep=is_sweep) except NotEnoughFunds: self.show_message(_("Insufficient funds")) return @@ -1407,8 +1411,6 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError): '''Sign the transaction in a separate thread. When done, calls the callback with a success code of True or False. ''' - # call hook to see if plugin needs gui interaction - run_hook('sign_tx', self, tx) def on_signed(result): callback(True) @@ -1417,8 +1419,11 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError): callback(False) if self.tx_external_keypairs: + # can sign directly task = partial(Transaction.sign, tx, self.tx_external_keypairs) else: + # call hook to see if plugin needs gui interaction + run_hook('sign_tx', self, tx) task = partial(self.wallet.sign_transaction, tx, password) WaitingDialog(self, _('Signing transaction...'), task, on_signed, on_failed) diff --git a/lib/wallet.py b/lib/wallet.py index 497af1ef..401d7ec6 100644 --- a/lib/wallet.py +++ b/lib/wallet.py @@ -860,7 +860,8 @@ class Abstract_Wallet(PrintError): def dust_threshold(self): return dust_threshold(self.network) - def make_unsigned_transaction(self, inputs, outputs, config, fixed_fee=None, change_addr=None): + def make_unsigned_transaction(self, inputs, outputs, config, fixed_fee=None, + change_addr=None, is_sweep=False): # check outputs i_max = None for i, o in enumerate(outputs): diff --git a/plugins/trustedcoin/trustedcoin.py b/plugins/trustedcoin/trustedcoin.py index 7cd2976b..20c6d1d3 100644 --- a/plugins/trustedcoin/trustedcoin.py +++ b/plugins/trustedcoin/trustedcoin.py @@ -248,11 +248,11 @@ class Wallet_2fa(Multisig_Wallet): assert price <= 100000 * n return price - def make_unsigned_transaction(self, coins, outputs, config, - fixed_fee=None, change_addr=None): + def make_unsigned_transaction(self, coins, outputs, config, fixed_fee=None, + change_addr=None, is_sweep=False): mk_tx = lambda o: Multisig_Wallet.make_unsigned_transaction( self, coins, o, config, fixed_fee, change_addr) - fee = self.extra_fee(config) + fee = self.extra_fee(config) if not is_sweep else 0 if fee: address = self.billing_info['billing_address'] fee_output = (TYPE_ADDRESS, address, fee)