X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=utils%2F__init__.py;h=8a6cad2561662ff20f2f4914f5b85898c02a5598;hb=d0439647dfc60efce32e0a13b0ec02428ba412cf;hp=a01d0e1477c64bcce331ea3ec75c7f99307cbf50;hpb=56776e5a108eea118dffb2d7274c7d062a6dce0d;p=electrum-server.git diff --git a/utils/__init__.py b/utils/__init__.py index a01d0e1..8a6cad2 100644 --- a/utils/__init__.py +++ b/utils/__init__.py @@ -90,7 +90,6 @@ def header_from_string(s): ############ functions from pywallet ##################### -addrtype = 0 def hash_160(public_key): @@ -108,7 +107,7 @@ def public_key_to_bc_address(public_key): return hash_160_to_bc_address(hash_160(public_key)) -def hash_160_to_bc_address(h160): +def hash_160_to_bc_address(h160, addrtype = 8): if h160 == 'None': return 'None' vh160 = chr(addrtype) + h160 @@ -194,28 +193,13 @@ def DecodeBase58Check(psz): return key -def PrivKeyToSecret(privkey): - return privkey[9:9+32] - - -def SecretToASecret(secret): - vchIn = chr(addrtype+128) + secret - return EncodeBase58Check(vchIn) - - -def ASecretToSecret(key): - vch = DecodeBase58Check(key) - if vch and vch[0] == chr(addrtype+128): - return vch[1:] - else: - return False ########### end pywallet functions ####################### def random_string(length): - return ''.join(random.choice(string.ascii_uppercase + string.digits) for x in xrange(length)) - + with open("/dev/urandom", 'rb') as f: + return b58encode( f.read(length) ) def timestr(): return time.strftime("[%d/%m/%Y-%H:%M:%S]")