Example #1
0
def test_btc_migration(blockstore_db_file, check_username, namespace):

    btc_migration = open(blockstore_db_file, 'r').read()
    btc_migration = json.loads(btc_migration)

    btc_registrations = btc_migration['registrations']

    for entry in btc_registrations:
        username = entry

        if username != (check_username + "." + namespace):
            continue

        profile_hash = btc_registrations[username]['value_hash']
        owner_address = btc_registrations[username]['address']

        print username
        print owner_address
        print '-' * 5

    entry = migration_users.find_one({"username": check_username})
    print entry['btc_address']

    hex_privkey = aes_decrypt(entry['encrypted_privkey'], SECRET_KEY)
    nmc_address, btc_address = get_addresses_from_privkey(hex_privkey)
    print btc_address
    print nmc_address
Example #2
0
def test_migration_user(check_user):

    for entry in migration_users.find():

        if entry['username'] != check_user:
            continue

        hex_privkey = aes_decrypt(entry['encrypted_privkey'], SECRET_KEY)
        nmc_privkey = NamecoinPrivateKey(hex_privkey)
        btc_privkey = BitcoinPrivateKey(hex_privkey)
        print hex_privkey
        print nmc_privkey.to_wif()
        print get_addresses_from_privkey(hex_privkey)
Example #3
0
def get_privkey(address):
    """ given an address, get decrypted hex private key from DB
    """

    entry = registrar_addresses.find_one({"address": address})

    if entry is None:
        log.debug("Address not found in DB, can't fetch privkey")
        return None

    encrypted_privkey = entry['encrypted_privkey']
    hex_privkey = aes_decrypt(encrypted_privkey, SECRET_KEY)

    return hex_privkey
Example #4
0
def get_privkey(address):
    """ given an address, get decrypted hex private key from DB
    """

    entry = registrar_addresses.find_one({"address": address})

    if entry is None:
        log.debug("Address not found in DB, can't fetch privkey")
        return None

    encrypted_privkey = entry['encrypted_privkey']
    hex_privkey = aes_decrypt(encrypted_privkey, SECRET_KEY)

    return hex_privkey
Example #5
0
def test_registrar_users():
    """ Test if registrar has access to correct private keys
    """

    for entry in registrar_users.find():

        fqu = entry['username'] + ".id"

        data = c.get_name_blockchain_record(fqu)

        if 'error' in data:
            log.debug("Error while processing: (%s, %s)" % (fqu, data))
            continue

        if entry['btc_address'] != data['address']:
            log.debug("registrar doesn't own: %s" % fqu)
            continue

        privkey = aes_decrypt(entry['encrypted_privkey'], SECRET_KEY)

        if get_address_from_privkey(privkey) == entry['btc_address']:
            log.debug("Correct pvtkey: %s" % fqu)
        else:
            log.debug("ERROR: wrong pvtkey: %s")
Example #6
0
def test_registrar_users():
    """ Test if registrar has access to correct private keys
    """

    for entry in registrar_users.find():

        fqu = entry['username'] + ".id"

        data = c.get_name_blockchain_record(fqu)

        if 'error' in data:
            log.debug("Error while processing: (%s, %s)" % (fqu, data))
            continue

        if entry['btc_address'] != data['address']:
            log.debug("registrar doesn't own: %s" % fqu)
            continue

        privkey = aes_decrypt(entry['encrypted_privkey'], SECRET_KEY)

        if get_address_from_privkey(privkey) == entry['btc_address']:
            log.debug("Correct pvtkey: %s" % fqu)
        else:
            log.debug("ERROR: wrong pvtkey: %s")