Browse Source

fix sweeping for 2fa wallets

3.0.x
SomberNight 7 years ago
parent
commit
ec99304ae1
  1. 13
      gui/qt/main_window.py
  2. 3
      lib/wallet.py
  3. 6
      plugins/trustedcoin/trustedcoin.py

13
gui/qt/main_window.py

@ -1190,7 +1190,9 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
_type, addr = self.get_payto_or_dummy() _type, addr = self.get_payto_or_dummy()
outputs = [(_type, addr, amount)] outputs = [(_type, addr, amount)]
try: 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 self.not_enough_funds = False
except NotEnoughFunds: except NotEnoughFunds:
self.not_enough_funds = True self.not_enough_funds = True
@ -1339,7 +1341,9 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
return return
outputs, fee, tx_desc, coins = r outputs, fee, tx_desc, coins = r
try: 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: except NotEnoughFunds:
self.show_message(_("Insufficient funds")) self.show_message(_("Insufficient funds"))
return return
@ -1407,8 +1411,6 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
'''Sign the transaction in a separate thread. When done, calls '''Sign the transaction in a separate thread. When done, calls
the callback with a success code of True or False. 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): def on_signed(result):
callback(True) callback(True)
@ -1417,8 +1419,11 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError):
callback(False) callback(False)
if self.tx_external_keypairs: if self.tx_external_keypairs:
# can sign directly
task = partial(Transaction.sign, tx, self.tx_external_keypairs) task = partial(Transaction.sign, tx, self.tx_external_keypairs)
else: else:
# call hook to see if plugin needs gui interaction
run_hook('sign_tx', self, tx)
task = partial(self.wallet.sign_transaction, tx, password) task = partial(self.wallet.sign_transaction, tx, password)
WaitingDialog(self, _('Signing transaction...'), task, WaitingDialog(self, _('Signing transaction...'), task,
on_signed, on_failed) on_signed, on_failed)

3
lib/wallet.py

@ -860,7 +860,8 @@ class Abstract_Wallet(PrintError):
def dust_threshold(self): def dust_threshold(self):
return dust_threshold(self.network) 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 # check outputs
i_max = None i_max = None
for i, o in enumerate(outputs): for i, o in enumerate(outputs):

6
plugins/trustedcoin/trustedcoin.py

@ -248,11 +248,11 @@ class Wallet_2fa(Multisig_Wallet):
assert price <= 100000 * n assert price <= 100000 * n
return price return price
def make_unsigned_transaction(self, coins, outputs, config, def make_unsigned_transaction(self, coins, outputs, config, fixed_fee=None,
fixed_fee=None, change_addr=None): change_addr=None, is_sweep=False):
mk_tx = lambda o: Multisig_Wallet.make_unsigned_transaction( mk_tx = lambda o: Multisig_Wallet.make_unsigned_transaction(
self, coins, o, config, fixed_fee, change_addr) 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: if fee:
address = self.billing_info['billing_address'] address = self.billing_info['billing_address']
fee_output = (TYPE_ADDRESS, address, fee) fee_output = (TYPE_ADDRESS, address, fee)

Loading…
Cancel
Save