trustedcoin: fix continuation of 2fa wallet file with keystore-only encryption
This commit is contained in:
@@ -64,6 +64,7 @@ from electrum.simple_config import SimpleConfig
|
||||
from electrum.storage import WalletStorage
|
||||
from electrum.wizard import WizardViewState
|
||||
from electrum.keystore import load_keystore
|
||||
from electrum.bip32 import is_xprv
|
||||
|
||||
from .util import read_QIcon, ColorScheme, custom_message_box, MessageBoxMixin, WWLabel
|
||||
from .main_window import ElectrumWindow
|
||||
@@ -454,6 +455,8 @@ class ElectrumGui(BaseElectrumGui, Logger):
|
||||
xprv = k1.get_master_private_key(d['password'])
|
||||
else:
|
||||
xprv = db.get('x1')['xprv']
|
||||
if not is_xprv(xprv):
|
||||
xprv = k1
|
||||
_wiz_data_updates = {
|
||||
'wallet_name': wallet_file,
|
||||
'xprv1': xprv,
|
||||
|
||||
@@ -75,6 +75,9 @@ class Plugin(TrustedCoinPlugin):
|
||||
'trustedcoin_tos': {
|
||||
'gui': '../../../../plugins/trustedcoin/qml/Terms',
|
||||
},
|
||||
'trustedcoin_keystore_unlock': {
|
||||
# TODO when QML can import external wallet files
|
||||
},
|
||||
'trustedcoin_show_confirm_otp': {
|
||||
'gui': '../../../../plugins/trustedcoin/qml/ShowConfirmOTP',
|
||||
}
|
||||
|
||||
@@ -35,13 +35,13 @@ from PyQt5.QtWidgets import (QTextEdit, QVBoxLayout, QLabel, QGridLayout, QHBoxL
|
||||
|
||||
from electrum.i18n import _
|
||||
from electrum.plugin import hook
|
||||
from electrum.util import is_valid_email
|
||||
from electrum.util import is_valid_email, InvalidPassword
|
||||
from electrum.logging import Logger, get_logger
|
||||
from electrum import keystore
|
||||
|
||||
from electrum.gui.qt.util import (read_QIcon, WindowModalDialog, WaitingDialog, OkButton,
|
||||
CancelButton, Buttons, icon_path, WWLabel, CloseButton, ColorScheme,
|
||||
ChoiceWidget)
|
||||
ChoiceWidget, PasswordLineEdit, char_width_in_lineedit)
|
||||
from electrum.gui.qt.qrcodewidget import QRCodeWidget
|
||||
from electrum.gui.qt.amountedit import AmountEdit
|
||||
from electrum.gui.qt.main_window import StatusBarButton
|
||||
@@ -261,6 +261,10 @@ class Plugin(TrustedCoinPlugin):
|
||||
'gui': WCTerms,
|
||||
'params': {'icon': icon_path('trustedcoin-wizard.png')},
|
||||
},
|
||||
'trustedcoin_keystore_unlock': {
|
||||
'gui': WCKeystorePassword,
|
||||
'params': {'icon': icon_path('trustedcoin-wizard.png')},
|
||||
},
|
||||
'trustedcoin_show_confirm_otp': {
|
||||
'gui': WCShowConfirmOTP,
|
||||
'params': {'icon': icon_path('trustedcoin-wizard.png')},
|
||||
@@ -600,3 +604,41 @@ class WCContinueOnline(WizardComponent):
|
||||
|
||||
def apply(self):
|
||||
self.wizard_data['trustedcoin_go_online'] = self.cb_online.isChecked()
|
||||
|
||||
|
||||
class WCKeystorePassword(WizardComponent):
|
||||
def __init__(self, parent, wizard):
|
||||
WizardComponent.__init__(self, parent, wizard, title=_('Unlock Keystore'))
|
||||
|
||||
def on_ready(self):
|
||||
self.layout().addStretch(1)
|
||||
|
||||
hbox2 = QHBoxLayout()
|
||||
hbox2.addStretch(1)
|
||||
self.pw_e = PasswordLineEdit('', self)
|
||||
self.pw_e.setFixedWidth(17 * char_width_in_lineedit())
|
||||
self.pw_e.textEdited.connect(self.on_text)
|
||||
pw_label = QLabel(_('Password') + ':')
|
||||
hbox2.addWidget(pw_label)
|
||||
hbox2.addWidget(self.pw_e)
|
||||
hbox2.addStretch(1)
|
||||
self.layout().addLayout(hbox2)
|
||||
|
||||
self.layout().addStretch(1)
|
||||
|
||||
self._valid = False
|
||||
|
||||
self.ks = self.wizard_data['xprv1']
|
||||
|
||||
def on_text(self):
|
||||
try:
|
||||
self.ks.check_password(self.pw_e.text())
|
||||
except InvalidPassword:
|
||||
self.valid = False
|
||||
return
|
||||
self.valid = True
|
||||
|
||||
def apply(self):
|
||||
if self.valid:
|
||||
self.wizard_data['xprv1'] = self.ks.get_master_private_key(self.pw_e.text())
|
||||
self.wizard_data['password'] = self.pw_e.text()
|
||||
|
||||
@@ -33,7 +33,7 @@ from urllib.parse import quote
|
||||
from aiohttp import ClientResponse
|
||||
|
||||
from electrum import ecc, constants, keystore, version, bip32, bitcoin
|
||||
from electrum.bip32 import BIP32Node, xpub_type
|
||||
from electrum.bip32 import BIP32Node, xpub_type, is_xprv
|
||||
from electrum.crypto import sha256
|
||||
from electrum.transaction import PartialTxOutput, PartialTxInput, PartialTransaction, Transaction
|
||||
from electrum.mnemonic import Mnemonic, seed_type, is_any_2fa_seed_type
|
||||
@@ -618,6 +618,10 @@ class TrustedCoinPlugin(BasePlugin):
|
||||
'last': lambda d: wizard.is_single_password() and d['trustedcoin_keepordisable'] == 'disable'
|
||||
},
|
||||
'trustedcoin_tos': {
|
||||
'next': lambda d: 'trustedcoin_show_confirm_otp' if is_xprv(d['xprv1'])
|
||||
else 'trustedcoin_keystore_unlock'
|
||||
},
|
||||
'trustedcoin_keystore_unlock': {
|
||||
'next': 'trustedcoin_show_confirm_otp'
|
||||
},
|
||||
'trustedcoin_show_confirm_otp': {
|
||||
|
||||
Reference in New Issue
Block a user