Exemple #1
0
except:
    print "credentials not found"

from onename.client import OnenameClient

try:
    HEX_PRIV_KEY = os.environ['HEX_PRIV_KEY']
    wallet = HDWallet(HEX_PRIV_KEY)
except:
    wallet = HDWallet()

if __name__ == '__main__':

    username = "******"
    profile = {"name": {"formatted": "Clone 4345"},
               "v": "2"}
    owner_address, owner_privkey = wallet.get_keypairs(1, include_privkey=True)[0]


    c = OnenameClient(ONENAME_API_ID, ONENAME_API_SECRET, base_url='http://localhost:5000/v1')
    #c = OnenameClient(ONENAME_API_ID, ONENAME_API_SECRET)

    #print c.get_user_stats()
    #print c.register_user(username, owner_address)
    print c.update_user(username, profile, owner_privkey=owner_privkey)

    #print c.get_user('muneeb')
    #print c.get_dkim('onename.com')
    #print c.get_all_users()
    #print c.register_user('clone61', '4543t3fedvd')
    #print c.get_names_owned('NHDEuS8R45Nz763rNmsCXXxgZxa245LZGF
Exemple #2
0
def transfer_user(username):

    reply = {}

    try:
        user = get_authenticated_user(request.authorization)
    except Exception as e:
        raise GenericError(str(e))

    try:
        hex_privkey = aes_decrypt(user.encrypted_privkey, SECRET_KEY)
    except Exception as e:
        raise GenericError(str(e))

    wallet = HDWallet(hex_privkey)
    data = json.loads(request.data)

    fqu = username + "." + DEFAULT_NAMESPACE
    transfer_address = data['transfer_address']
    owner_pubkey = data['owner_pubkey']

    try:
        blockchain_record = bs_client.get_name_blockchain_record(fqu)
    except Exception as e:
        raise GenericError(str(e))

    if 'value_hash' not in blockchain_record:
        raise GenericError("Not yet registered %s" % fqu)

    owner_address = blockchain_record['address']

    check_address = get_address_from_pubkey(str(owner_pubkey))

    if check_address != owner_address:
        raise GenericError("Given pubkey/address doesn't own this name.")

    if not is_b58check_address(transfer_address):
        raise InvalidAddressError(transfer_address)

    if USE_DEFAULT_PAYMENT and PAYMENT_PRIVKEY is not None:

        payment_privkey = BitcoinPrivateKey(PAYMENT_PRIVKEY)
        payment_privkey = payment_privkey.to_hex()
    else:
        pubkey, payment_privkey = wallet.get_next_keypair()

        if payment_privkey is None:
            raise PaymentError(
                addresses=wallet.get_keypairs(DEFAULT_CHILD_ADDRESSES))

    resp = {}

    try:
        resp = bs_client.transfer_subsidized(fqu,
                                             transfer_address,
                                             keep_data=True,
                                             public_key=owner_pubkey,
                                             subsidy_key=payment_privkey)
    except Exception as e:
        reply['error'] = str(e)
        return jsonify(reply), 200

    if 'subsidized_tx' in resp:
        reply['unsigned_tx'] = resp['subsidized_tx']
    else:
        if 'error' in resp:
            reply['error'] = resp['error']
        else:
            reply['error'] = resp

    return jsonify(reply), 200
Exemple #3
0
except:
    print "credentials not found"

from onename.client import OnenameClient

try:
    HEX_PRIV_KEY = os.environ['HEX_PRIV_KEY']
    wallet = HDWallet(HEX_PRIV_KEY)
except:
    wallet = HDWallet()

if __name__ == '__main__':

    username = "******"
    profile = {"name": {"formatted": "Clone 4345"}, "v": "2"}
    owner_address, owner_privkey = wallet.get_keypairs(1,
                                                       include_privkey=True)[0]

    c = OnenameClient(ONENAME_API_ID,
                      ONENAME_API_SECRET,
                      base_url='http://localhost:5000/v1')
    #c = OnenameClient(ONENAME_API_ID, ONENAME_API_SECRET)

    #print c.get_user_stats()
    #print c.register_user(username, owner_address)
    print c.update_user(username, profile, owner_privkey=owner_privkey)

    #print c.get_user('muneeb')
    #print c.get_dkim('onename.com')
    #print c.get_all_users()
    #print c.register_user('clone61', '4543t3fedvd')
    #print c.get_names_owned('NHDEuS8R45Nz763rNmsCXXxgZxa245LZGF