tutil: rm hfu, cleaner bh2u - electrum - Electrum Bitcoin wallet HTML git clone https://git.parazyd.org/electrum DIR Log DIR Files DIR Refs DIR Submodules --- DIR commit 3ad6f738bd15e2574b68251a633cd3c77caf7145 DIR parent 7f3de8241c3856c2e873c5f6e9fa513f454e5d9b HTML Author: SomberNight <somber.night@protonmail.com> Date: Fri, 1 Feb 2019 18:07:28 +0100 util: rm hfu, cleaner bh2u Diffstat: M electrum/keystore.py | 7 ++++--- M electrum/util.py | 3 +-- 2 files changed, 5 insertions(+), 5 deletions(-) --- DIR diff --git a/electrum/keystore.py b/electrum/keystore.py t@@ -26,6 +26,7 @@ from unicodedata import normalize import hashlib +import binascii from . import bitcoin, ecc, constants, bip32 from .bitcoin import (deserialize_privkey, serialize_privkey, t@@ -35,9 +36,9 @@ from .bip32 import (bip32_public_derivation, deserialize_xpub, CKD_pub, bip32_private_key, bip32_derivation, BIP32_PRIME, is_xpub, is_xprv) from .ecc import string_to_number, number_to_string -from .crypto import (pw_decode, pw_encode, sha256d, PW_HASH_VERSION_LATEST, +from .crypto import (pw_decode, pw_encode, sha256, sha256d, PW_HASH_VERSION_LATEST, SUPPORTED_PW_HASH_VERSIONS, UnsupportedPasswordHashVersion) -from .util import (PrintError, InvalidPassword, hfu, WalletFileException, +from .util import (PrintError, InvalidPassword, WalletFileException, BitcoinException, bh2u, bfh, print_error, inv_dict) from .mnemonic import Mnemonic, load_wordlist from .plugin import run_hook t@@ -625,7 +626,7 @@ def bip39_is_checksum_valid(mnemonic): while len(h) < entropy_length/4: h = '0'+h b = bytearray.fromhex(h) - hashed = int(hfu(hashlib.sha256(b).digest()), 16) + hashed = int(binascii.hexlify(sha256(b)), 16) calculated_checksum = hashed >> (256 - checksum_length) return checksum == calculated_checksum, True DIR diff --git a/electrum/util.py b/electrum/util.py t@@ -462,7 +462,6 @@ def to_bytes(something, encoding='utf8') -> bytes: bfh = bytes.fromhex -hfu = binascii.hexlify def bh2u(x: bytes) -> str: t@@ -473,7 +472,7 @@ def bh2u(x: bytes) -> str: >>> bh2u(x) '01020A' """ - return hfu(x).decode('ascii') + return x.hex() def user_dir():