util: rm hfu, cleaner bh2u
This commit is contained in:
parent
7f3de8241c
commit
3ad6f738bd
@ -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,
|
||||
@ -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
|
||||
@ -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
|
||||
|
||||
|
||||
@ -462,7 +462,6 @@ def to_bytes(something, encoding='utf8') -> bytes:
|
||||
|
||||
|
||||
bfh = bytes.fromhex
|
||||
hfu = binascii.hexlify
|
||||
|
||||
|
||||
def bh2u(x: bytes) -> str:
|
||||
@ -473,7 +472,7 @@ def bh2u(x: bytes) -> str:
|
||||
>>> bh2u(x)
|
||||
'01020A'
|
||||
"""
|
||||
return hfu(x).decode('ascii')
|
||||
return x.hex()
|
||||
|
||||
|
||||
def user_dir():
|
||||
|
||||
Loading…
Reference in New Issue
Block a user