Skip to content

Commit

Permalink
fix sweeping for 2fa wallets
Browse files Browse the repository at this point in the history
  • Loading branch information
SomberNight committed Dec 11, 2017
1 parent 4e4a774 commit ec99304
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
13 changes: 9 additions & 4 deletions gui/qt/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -1190,7 +1190,9 @@ def do_update_fee(self):
_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
Expand Down Expand Up @@ -1339,7 +1341,9 @@ def do_send(self, preview = False):
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
Expand Down Expand Up @@ -1407,8 +1411,6 @@ def sign_tx_with_password(self, tx, callback, password):
'''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)
Expand All @@ -1417,8 +1419,11 @@ def on_failed(exc_info):
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)
Expand Down
3 changes: 2 additions & 1 deletion lib/wallet.py
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,8 @@ def relayfee(self):
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):
Expand Down
6 changes: 3 additions & 3 deletions plugins/trustedcoin/trustedcoin.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,11 +248,11 @@ def extra_fee(self, config):
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)
Expand Down

0 comments on commit ec99304

Please sign in to comment.