mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-09-01 09:45:18 +00:00
Passphrase-related fixes
Move normalize code to one place on the wallet Passphrases don't have password strength meter
This commit is contained in:
parent
4fe01cb8d3
commit
f3e6bf0280
4 changed files with 16 additions and 12 deletions
|
@ -100,9 +100,12 @@ class PasswordDialog(WindowModalDialog):
|
||||||
vbox.addLayout(grid)
|
vbox.addLayout(grid)
|
||||||
|
|
||||||
# Password Strength Label
|
# Password Strength Label
|
||||||
self.pw_strength = QLabel()
|
if kind != self.PW_PASSPHRASE:
|
||||||
grid.addWidget(self.pw_strength, 3, 0, 1, 2)
|
self.pw_strength = QLabel()
|
||||||
self.new_pw.textChanged.connect(self.pw_changed)
|
grid.addWidget(self.pw_strength, 3, 0, 1, 2)
|
||||||
|
self.new_pw.textChanged.connect(self.pw_changed)
|
||||||
|
|
||||||
|
self.new_pw.textChanged.connect(self.check_OKButton)
|
||||||
self.conf_pw.textChanged.connect(self.check_OKButton)
|
self.conf_pw.textChanged.connect(self.check_OKButton)
|
||||||
|
|
||||||
self.OKButton = OkButton(self)
|
self.OKButton = OkButton(self)
|
||||||
|
@ -121,7 +124,6 @@ class PasswordDialog(WindowModalDialog):
|
||||||
else:
|
else:
|
||||||
label = ""
|
label = ""
|
||||||
self.pw_strength.setText(label)
|
self.pw_strength.setText(label)
|
||||||
self.check_OKButton()
|
|
||||||
|
|
||||||
def check_OKButton(self):
|
def check_OKButton(self):
|
||||||
self.OKButton.setEnabled(self.new_pw.text() == self.conf_pw.text())
|
self.OKButton.setEnabled(self.new_pw.text() == self.conf_pw.text())
|
||||||
|
|
|
@ -1738,13 +1738,17 @@ class BIP44_Wallet(BIP32_HD_Wallet):
|
||||||
acc_id, (change, address_index) = self.get_address_index(address)
|
acc_id, (change, address_index) = self.get_address_index(address)
|
||||||
return self.address_derivation(acc_id, change, address_index)
|
return self.address_derivation(acc_id, change, address_index)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def normalize_passphrase(passphrase):
|
||||||
|
return normalize('NFKD', unicode(passphrase or ''))
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def mnemonic_to_seed(mnemonic, passphrase):
|
def mnemonic_to_seed(mnemonic, passphrase):
|
||||||
# See BIP39
|
# See BIP39
|
||||||
import pbkdf2, hashlib, hmac
|
import pbkdf2, hashlib, hmac
|
||||||
PBKDF2_ROUNDS = 2048
|
PBKDF2_ROUNDS = 2048
|
||||||
mnemonic = normalize('NFKD', ' '.join(mnemonic.split()))
|
mnemonic = normalize('NFKD', ' '.join(mnemonic.split()))
|
||||||
passphrase = normalize('NFKD', passphrase)
|
passphrase = BIP44_Wallet.normalize_passphrase(passphrase)
|
||||||
return pbkdf2.PBKDF2(mnemonic, 'mnemonic' + passphrase,
|
return pbkdf2.PBKDF2(mnemonic, 'mnemonic' + passphrase,
|
||||||
iterations = PBKDF2_ROUNDS, macmodule = hmac,
|
iterations = PBKDF2_ROUNDS, macmodule = hmac,
|
||||||
digestmodule = hashlib.sha512).read(64)
|
digestmodule = hashlib.sha512).read(64)
|
||||||
|
|
|
@ -3,7 +3,6 @@ import time
|
||||||
|
|
||||||
from binascii import unhexlify
|
from binascii import unhexlify
|
||||||
from struct import pack
|
from struct import pack
|
||||||
from unicodedata import normalize
|
|
||||||
|
|
||||||
from electrum.account import BIP32_Account
|
from electrum.account import BIP32_Account
|
||||||
from electrum.bitcoin import (bc_address_to_hash_160, xpub_from_pubkey,
|
from electrum.bitcoin import (bc_address_to_hash_160, xpub_from_pubkey,
|
||||||
|
@ -154,8 +153,10 @@ class TrezorCompatiblePlugin(BasePlugin):
|
||||||
|
|
||||||
@hook
|
@hook
|
||||||
def timer_actions(self):
|
def timer_actions(self):
|
||||||
|
# Scan connected devices every second. The test for libraries
|
||||||
|
# available is necessary to recover wallets on machines without
|
||||||
|
# libraries
|
||||||
if self.libraries_available:
|
if self.libraries_available:
|
||||||
# Scan connected devices every second
|
|
||||||
now = time.time()
|
now = time.time()
|
||||||
if now > self.last_scan + 1:
|
if now > self.last_scan + 1:
|
||||||
self.last_scan = now
|
self.last_scan = now
|
||||||
|
@ -294,10 +295,6 @@ class TrezorCompatiblePlugin(BasePlugin):
|
||||||
def is_enabled(self):
|
def is_enabled(self):
|
||||||
return self.libraries_available
|
return self.libraries_available
|
||||||
|
|
||||||
@staticmethod
|
|
||||||
def normalize_passphrase(self, passphrase):
|
|
||||||
return normalize('NFKD', unicode(passphrase or ''))
|
|
||||||
|
|
||||||
def on_restore_wallet(self, wallet, wizard):
|
def on_restore_wallet(self, wallet, wizard):
|
||||||
assert isinstance(wallet, self.wallet_class)
|
assert isinstance(wallet, self.wallet_class)
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ from plugin import TrezorCompatiblePlugin
|
||||||
from electrum.i18n import _
|
from electrum.i18n import _
|
||||||
from electrum.plugins import hook
|
from electrum.plugins import hook
|
||||||
from electrum.util import PrintError
|
from electrum.util import PrintError
|
||||||
|
from electrum.wallet import BIP44_Wallet
|
||||||
|
|
||||||
|
|
||||||
# By far the trickiest thing about this handler is the window stack;
|
# By far the trickiest thing about this handler is the window stack;
|
||||||
|
@ -75,7 +76,7 @@ class QtHandler(PrintError):
|
||||||
PasswordDialog.PW_PASSPHRASE)
|
PasswordDialog.PW_PASSPHRASE)
|
||||||
confirmed, p, passphrase = d.run()
|
confirmed, p, passphrase = d.run()
|
||||||
if confirmed:
|
if confirmed:
|
||||||
passphrase = TrezorCompatiblePlugin.normalize_passphrase(passphrase)
|
passphrase = BIP44_Wallet.normalize_passphrase(passphrase)
|
||||||
self.passphrase = passphrase
|
self.passphrase = passphrase
|
||||||
self.done.set()
|
self.done.set()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue