Skip to content

Commit ec99304

Browse files
committed
fix sweeping for 2fa wallets
1 parent 4e4a774 commit ec99304

3 files changed

Lines changed: 14 additions & 8 deletions

File tree

gui/qt/main_window.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,7 +1190,9 @@ def do_update_fee(self):
11901190
_type, addr = self.get_payto_or_dummy()
11911191
outputs = [(_type, addr, amount)]
11921192
try:
1193-
tx = self.wallet.make_unsigned_transaction(self.get_coins(), outputs, self.config, fee)
1193+
is_sweep = bool(self.tx_external_keypairs)
1194+
tx = self.wallet.make_unsigned_transaction(
1195+
self.get_coins(), outputs, self.config, fee, is_sweep=is_sweep)
11941196
self.not_enough_funds = False
11951197
except NotEnoughFunds:
11961198
self.not_enough_funds = True
@@ -1339,7 +1341,9 @@ def do_send(self, preview = False):
13391341
return
13401342
outputs, fee, tx_desc, coins = r
13411343
try:
1342-
tx = self.wallet.make_unsigned_transaction(coins, outputs, self.config, fee)
1344+
is_sweep = bool(self.tx_external_keypairs)
1345+
tx = self.wallet.make_unsigned_transaction(
1346+
coins, outputs, self.config, fee, is_sweep=is_sweep)
13431347
except NotEnoughFunds:
13441348
self.show_message(_("Insufficient funds"))
13451349
return
@@ -1407,8 +1411,6 @@ def sign_tx_with_password(self, tx, callback, password):
14071411
'''Sign the transaction in a separate thread. When done, calls
14081412
the callback with a success code of True or False.
14091413
'''
1410-
# call hook to see if plugin needs gui interaction
1411-
run_hook('sign_tx', self, tx)
14121414

14131415
def on_signed(result):
14141416
callback(True)
@@ -1417,8 +1419,11 @@ def on_failed(exc_info):
14171419
callback(False)
14181420

14191421
if self.tx_external_keypairs:
1422+
# can sign directly
14201423
task = partial(Transaction.sign, tx, self.tx_external_keypairs)
14211424
else:
1425+
# call hook to see if plugin needs gui interaction
1426+
run_hook('sign_tx', self, tx)
14221427
task = partial(self.wallet.sign_transaction, tx, password)
14231428
WaitingDialog(self, _('Signing transaction...'), task,
14241429
on_signed, on_failed)

lib/wallet.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -860,7 +860,8 @@ def relayfee(self):
860860
def dust_threshold(self):
861861
return dust_threshold(self.network)
862862

863-
def make_unsigned_transaction(self, inputs, outputs, config, fixed_fee=None, change_addr=None):
863+
def make_unsigned_transaction(self, inputs, outputs, config, fixed_fee=None,
864+
change_addr=None, is_sweep=False):
864865
# check outputs
865866
i_max = None
866867
for i, o in enumerate(outputs):

plugins/trustedcoin/trustedcoin.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -248,11 +248,11 @@ def extra_fee(self, config):
248248
assert price <= 100000 * n
249249
return price
250250

251-
def make_unsigned_transaction(self, coins, outputs, config,
252-
fixed_fee=None, change_addr=None):
251+
def make_unsigned_transaction(self, coins, outputs, config, fixed_fee=None,
252+
change_addr=None, is_sweep=False):
253253
mk_tx = lambda o: Multisig_Wallet.make_unsigned_transaction(
254254
self, coins, o, config, fixed_fee, change_addr)
255-
fee = self.extra_fee(config)
255+
fee = self.extra_fee(config) if not is_sweep else 0
256256
if fee:
257257
address = self.billing_info['billing_address']
258258
fee_output = (TYPE_ADDRESS, address, fee)

0 commit comments

Comments
 (0)