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:
parent
9ed987c2da
commit
c2accd64cf
|
@ -50,10 +50,18 @@ class Plugin(TrustedCoinPlugin):
|
||||||
@hook
|
@hook
|
||||||
def on_new_window(self, window):
|
def on_new_window(self, window):
|
||||||
wallet = window.wallet
|
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"),
|
button = StatusBarButton(QIcon(":icons/trustedcoin.png"),
|
||||||
_("TrustedCoin"),
|
_("TrustedCoin"), action)
|
||||||
partial(self.settings_dialog, window))
|
|
||||||
window.statusBar().addPermanentWidget(button)
|
window.statusBar().addPermanentWidget(button)
|
||||||
t = Thread(target=self.request_billing_info, args=(wallet,))
|
t = Thread(target=self.request_billing_info, args=(wallet,))
|
||||||
t.setDaemon(True)
|
t.setDaemon(True)
|
||||||
|
@ -77,10 +85,11 @@ class Plugin(TrustedCoinPlugin):
|
||||||
|
|
||||||
@hook
|
@hook
|
||||||
def sign_tx(self, window, tx):
|
def sign_tx(self, window, tx):
|
||||||
self.print_error("twofactor:sign_tx")
|
|
||||||
wallet = window.wallet
|
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 not wallet.can_sign_without_server():
|
||||||
|
self.print_error("twofactor:sign_tx")
|
||||||
auth_code = None
|
auth_code = None
|
||||||
if need_server(wallet, tx):
|
if need_server(wallet, tx):
|
||||||
auth_code = self.auth_dialog(window)
|
auth_code = self.auth_dialog(window)
|
||||||
|
@ -101,7 +110,8 @@ class Plugin(TrustedCoinPlugin):
|
||||||
@hook
|
@hook
|
||||||
def abort_send(self, window):
|
def abort_send(self, window):
|
||||||
wallet = window.wallet
|
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 not wallet.can_sign_without_server():
|
||||||
if wallet.billing_info is None:
|
if wallet.billing_info is None:
|
||||||
# request billing info before forming the transaction
|
# request billing info before forming the transaction
|
||||||
|
|
Loading…
Reference in New Issue