Example #1
0
 def get_xpubkeys(self, for_change, n):
     # unsorted
     s = ''.join(map(lambda x: int_to_hex(x, 2), (for_change, n)))
     xpubs = self.get_master_pubkeys()
     return map(
         lambda xpub: 'ff' + DecodeBase58Check(xpub).encode('hex') + s,
         xpubs)
Example #2
0
def ASecretToSecret(key, addrtype=0):
    vch = DecodeBase58Check(key)
    if vch and vch[0] == chr((addrtype + 128) & 255):
        return vch[1:]
    elif is_minikey(key):
        return minikey_to_private_key(key)
    else:
        return False
Example #3
0
def deserialize_xkey(xkey):
    xkey = DecodeBase58Check(xkey)
    assert len(xkey) == 78

    xkey_header = xkey[0:4].encode('hex')
    # Determine if the key is a bitcoin key or a testnet key.
    if xkey_header in TESTNET_HEADERS:
        head = TESTNET_HEADER_PRIV
    elif xkey_header in BITCOIN_HEADERS:
        head = BITCOIN_HEADER_PRIV
    else:
        raise Exception("Unknown xkey header: '%s'" % xkey_header)

    depth = ord(xkey[4])
    fingerprint = xkey[5:9]
    child_number = xkey[9:13]
    c = xkey[13:13 + 32]
    if xkey[0:4].encode('hex') == head:
        K_or_k = xkey[13 + 33:]
    else:
        K_or_k = xkey[13 + 32:]
    return depth, fingerprint, child_number, c, K_or_k