trustedcoin: don't use assert in hooks, it crashes when using multiple windows. show message if wallet is restored from seed.

This commit is contained in:
ThomasV 2016-01-03 19:16:37 +01:00
parent 9ed987c2da
commit c2accd64cf
1 changed files with 21 additions and 11 deletions

View File

@ -50,10 +50,18 @@ class Plugin(TrustedCoinPlugin):
@hook
def on_new_window(self, window):
wallet = window.wallet
if wallet.storage.get('wallet_type') == '2fa':
if not isinstance(wallet, self.wallet_class):
return
if wallet.can_sign_without_server():
msg = ' '.join([
_('This wallet is was restored from seed, and it contains two master private keys.'),
_('Therefore, two-factor authentication is disabled.')
])
action = lambda: window.show_message(msg)
else:
action = partial(self.settings_dialog, window)
button = StatusBarButton(QIcon(":icons/trustedcoin.png"),
_("TrustedCoin"),
partial(self.settings_dialog, window))
_("TrustedCoin"), action)
window.statusBar().addPermanentWidget(button)
t = Thread(target=self.request_billing_info, args=(wallet,))
t.setDaemon(True)
@ -77,10 +85,11 @@ class Plugin(TrustedCoinPlugin):
@hook
def sign_tx(self, window, tx):
self.print_error("twofactor:sign_tx")
wallet = window.wallet
assert isinstance(wallet, self.wallet_class)
if not isinstance(wallet, self.wallet_class):
return
if not wallet.can_sign_without_server():
self.print_error("twofactor:sign_tx")
auth_code = None
if need_server(wallet, tx):
auth_code = self.auth_dialog(window)
@ -101,7 +110,8 @@ class Plugin(TrustedCoinPlugin):
@hook
def abort_send(self, window):
wallet = window.wallet
assert isinstance(wallet, self.wallet_class)
if not isinstance(wallet, self.wallet_class):
return
if not wallet.can_sign_without_server():
if wallet.billing_info is None:
# request billing info before forming the transaction