From b7de7b9701ee22e561a0b6fd24fddda635d05c04 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Fri, 18 Oct 2024 10:32:08 +0000 Subject: [PATCH] whitespace: various --- mmgen/altcoin/params.py | 32 ++++++++++++++++---------------- mmgen/altcoin/util.py | 10 +++++----- mmgen/bip_hd/__init__.py | 2 +- mmgen/help/help_notes.py | 2 +- mmgen/help/seedsplit.py | 6 +++--- mmgen/main_seedjoin.py | 2 +- 6 files changed, 27 insertions(+), 27 deletions(-) diff --git a/mmgen/altcoin/params.py b/mmgen/altcoin/params.py index 9705a4d7..0ce4cf3b 100755 --- a/mmgen/altcoin/params.py +++ b/mmgen/altcoin/params.py @@ -17,7 +17,7 @@ altcoin.py - Constants for Bitcoin-derived altcoins # pc: https://github.com/richardkiss/pycoin/blob/master/pycoin/networks/legacy_networks.py # vg: https://github.com/exploitagency/vanitygen-plus/blob/master/keyconv.c # wn: https://walletgenerator.net -# cc: https://www.cryptocompare.com/api/data/coinlist/ (names,symbols only) +# cc: https://www.cryptocompare.com/api/data/coinlist/ (names, symbols only) # BIP44 # https://github.com/bitcoin/bips/blob/master/bip-0044.mediawiki @@ -34,7 +34,7 @@ from ..protocol import CoinProtocol from ..proto.btc.params import mainnet ce = namedtuple('CoinInfoEntry', - ['name','symbol','wif_ver_num','p2pkh_info','p2sh_info','has_segwit','trust_level']) + ['name', 'symbol', 'wif_ver_num', 'p2pkh_info', 'p2sh_info', 'has_segwit', 'trust_level']) class CoinInfo: coin_constants = {} @@ -256,26 +256,26 @@ class CoinInfo: ) @classmethod - def get_supported_coins(cls,network): + def get_supported_coins(cls, network): return [e for e in cls.coin_constants[network] if e.trust_level != -1] @classmethod - def get_entry(cls,coin,network): + def get_entry(cls, coin, network): try: idx = [e.symbol for e in cls.coin_constants[network]].index(coin.upper()) except: return None return cls.coin_constants[network][idx] -def make_proto(e,testnet=False): +def make_proto(e, testnet=False): proto = ('X_' if e.name[0] in '0123456789' else '') + e.name + ('Testnet' if testnet else '') - if hasattr(CoinProtocol,proto): + if hasattr(CoinProtocol, proto): return def num2hexstr(n): - return '{:0{}x}'.format(n,(4,2)[n < 256]) + return '{:0{}x}'.format(n, (4, 2)[n < 256]) setattr( CoinProtocol, @@ -286,18 +286,18 @@ def make_proto(e,testnet=False): { 'base_coin': e.symbol, 'addr_ver_info': dict( - [( num2hexstr(e.p2pkh_info[0]), 'p2pkh' )] + - ([( num2hexstr(e.p2sh_info[0]), 'p2sh' )] if e.p2sh_info else []) + [(num2hexstr(e.p2pkh_info[0]), 'p2pkh')] + + ([(num2hexstr(e.p2sh_info[0]), 'p2sh')] if e.p2sh_info else []) ), - 'wif_ver_num': { 'std': num2hexstr(e.wif_ver_num) }, - 'mmtypes': ('L','C','S') if e.has_segwit else ('L','C'), + 'wif_ver_num': {'std': num2hexstr(e.wif_ver_num)}, + 'mmtypes': ('L', 'C', 'S') if e.has_segwit else ('L', 'C'), 'dfl_mmtype': 'L', 'mmcaps': (), }, ) ) -def init_genonly_altcoins(usr_coin=None,testnet=False): +def init_genonly_altcoins(usr_coin=None, testnet=False): """ Initialize altcoin protocol class or classes for current network. If usr_coin is a core coin, initialization is skipped. @@ -306,7 +306,7 @@ def init_genonly_altcoins(usr_coin=None,testnet=False): Returns trust_level of usr_coin, or 0 (untrusted) if usr_coin is None. """ - data = { 'mainnet': (), 'testnet': () } + data = {'mainnet': (), 'testnet': ()} networks = ['mainnet'] + (['testnet'] if testnet else []) network = 'testnet' if testnet else 'mainnet' @@ -317,7 +317,7 @@ def init_genonly_altcoins(usr_coin=None,testnet=False): if usr_coin.lower() in gc.core_coins: # core coin, so return immediately return CoinProtocol.coins[usr_coin.lower()].trust_level for network in networks: - data[network] = (CoinInfo.get_entry(usr_coin,network),) + data[network] = (CoinInfo.get_entry(usr_coin, network),) cinfo = data[network][0] if not cinfo: @@ -329,11 +329,11 @@ def init_genonly_altcoins(usr_coin=None,testnet=False): make_proto(e) for e in data['testnet']: - make_proto(e,testnet=True) + make_proto(e, testnet=True) for e in data['mainnet']: if e.symbol.lower() in CoinProtocol.coins: continue CoinProtocol.coins[e.symbol.lower()] = CoinProtocol.proto_info( name = 'X_'+e.name if e.name[0] in '0123456789' else e.name, - trust_level = e.trust_level ) + trust_level = e.trust_level) diff --git a/mmgen/altcoin/util.py b/mmgen/altcoin/util.py index f60c4422..4ae158b9 100755 --- a/mmgen/altcoin/util.py +++ b/mmgen/altcoin/util.py @@ -14,7 +14,7 @@ altcoin.util: various altcoin-related utilities from ..util import die -def decrypt_keystore(data,passwd,mac_algo=None,mac_params={}): +def decrypt_keystore(data, passwd, mac_algo=None, mac_params={}): """ Decrypt the encrypted data in a cross-chain keystore Returns the decrypted data as a bytestring @@ -23,14 +23,14 @@ def decrypt_keystore(data,passwd,mac_algo=None,mac_params={}): cdata = data['crypto'] parms = cdata['kdfparams'] - valid_kdfs = ['scrypt','pbkdf2'] - valid_ciphers = ['aes-128-ctr','aes-256-ctr'] + valid_kdfs = ['scrypt', 'pbkdf2'] + valid_ciphers = ['aes-128-ctr', 'aes-256-ctr'] if (kdf := cdata['kdf']) not in valid_kdfs: die(1, f'unsupported key derivation function {kdf!r} (must be one of {valid_kdfs})') if (cipher := cdata['cipher']) not in valid_ciphers: - die(1,f'unsupported cipher {cipher!r} (must be one of {valid_ciphers})') + die(1, f'unsupported cipher {cipher!r} (must be one of {valid_ciphers})') # Derive encryption key from password: if kdf == 'scrypt': @@ -72,7 +72,7 @@ def decrypt_keystore(data,passwd,mac_algo=None,mac_params={}): die(1, 'incorrect password') # Decrypt data: - from cryptography.hazmat.primitives.ciphers import Cipher,algorithms,modes + from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes from cryptography.hazmat.backends import default_backend cipher_len = int(cipher.split('-')[1]) // 8 c = Cipher( diff --git a/mmgen/bip_hd/__init__.py b/mmgen/bip_hd/__init__.py index c576124d..6e08f4fa 100644 --- a/mmgen/bip_hd/__init__.py +++ b/mmgen/bip_hd/__init__.py @@ -55,7 +55,7 @@ def parse_version_bytes(vb_hex): def compress_pubkey(pubkey_bytes): # see: proto.secp256k1.keygen.pubkey_format() - return (b'\x02',b'\x03')[pubkey_bytes[-1] & 1] + pubkey_bytes[1:33] + return (b'\x02', b'\x03')[pubkey_bytes[-1] & 1] + pubkey_bytes[1:33] def decompress_pubkey(pubkey_bytes): import ecdsa diff --git a/mmgen/help/help_notes.py b/mmgen/help/help_notes.py index e9b9738b..8328f4e5 100755 --- a/mmgen/help/help_notes.py +++ b/mmgen/help/help_notes.py @@ -58,7 +58,7 @@ class help_notes: from ..passwdlist import PasswordList pwi_fs = '{:8} {:1} {:26} {:<7} {:<7} {}' return '\n '.join( - [pwi_fs.format('Code', '','Description', 'Min Len', 'Max Len', 'Default Len')] + + [pwi_fs.format('Code', '', 'Description', 'Min Len', 'Max Len', 'Default Len')] + [pwi_fs.format(k, '-', v.desc, v.min_len, v.max_len, v.dfl_len) for k, v in PasswordList.pw_info.items()] ) diff --git a/mmgen/help/seedsplit.py b/mmgen/help/seedsplit.py index 17848548..9a519919 100755 --- a/mmgen/help/seedsplit.py +++ b/mmgen/help/seedsplit.py @@ -12,8 +12,8 @@ help.seedsplit: seedsplit help notes for MMGen suite """ -def help(proto,cfg): - from ..seedsplit import SeedShareIdx,SeedShareCount,MasterShareIdx +def help(proto, cfg): + from ..seedsplit import SeedShareIdx, SeedShareCount, MasterShareIdx return """ COMMAND NOTES: @@ -102,4 +102,4 @@ EXAMPLES: """.strip().format( si = SeedShareIdx, sc = SeedShareCount, - mi = MasterShareIdx ) + mi = MasterShareIdx) diff --git a/mmgen/main_seedjoin.py b/mmgen/main_seedjoin.py index 57876e7d..80d8cbcd 100755 --- a/mmgen/main_seedjoin.py +++ b/mmgen/main_seedjoin.py @@ -105,7 +105,7 @@ def print_shares_info(): id_str.hl2(encl='‘’'), len(shares)) si = 1 - for n, s in enumerate(shares[si:],si+1): + for n, s in enumerate(shares[si:], si+1): out += f'{n:3}: {s.sid}\n' cfg._util.qmsg(out)