Example #1
0
def address_to_key(s, version=0):
    s = ('%050x' % base58_decode(s)).decode('hex')
    key, check0 = s[:-4], s[-4:]
    check1 = dhash(key)[:4]
    if key[0] != chr(version) or check0 != check1:
        raise BadAddress(s)
    return key[1:]
Example #2
0
def address_to_key (s, version=0):
    s = ('%050x' % base58_decode (s)).decode ('hex')
    key, check0 = s[:-4], s[-4:]
    check1 = dhash (key)[:4]
    if key[0] != chr(version) or check0 != check1:
        raise BadAddress (s)
    return key[1:]
Example #3
0
def address_to_key (s):
    # strip off leading '1'
    s = ('%048x' % base58_decode (s[1:])).decode ('hex')
    hash160, check0 = s[:-4], s[-4:]
    check1 = dhash ('\x00' + hash160)[:4]
    if check0 != check1:
        raise BadAddress (s)
    return hash160
Example #4
0
def address_to_key(s):
    # strip off leading '1'
    s = ('%048x' % base58_decode(s[1:])).decode('hex')
    hash160, check0 = s[:-4], s[-4:]
    check1 = dhash('\x00' + hash160)[:4]
    if check0 != check1:
        raise BadAddress(s)
    return hash160
Example #5
0
def address_to_key (s):
    n = base58_decode (s)
    # <version:1><hash:20><check:4>
    check0 = struct.pack ('>L', n & 0xffffffff)
    n >>= 32
    h160 = n & h160_mask
    n >>= 160
    v = n
    h160 = ('%040x' % (h160)).decode ('hex')
    check1 = dhash (chr(v) + h160)[:4]
    if check0 != check1:
        raise BadAddress (s)
    return v, h160
Example #6
0
def address_to_key (s):
    n = base58_decode (s)
    # <version:1><hash:20><check:4>
    check0 = struct.pack ('>L', n & 0xffffffff)
    n >>= 32
    h160 = n & h160_mask
    n >>= 160
    v = n
    h160 = ('%040x' % (h160)).decode ('hex')
    check1 = dhash (chr(v) + h160)[:4]
    if check0 != check1:
        raise BadAddress (s)
    return v, h160