mirror of
https://github.com/alexgo-io/stacks-puppet-node.git
synced 2026-05-10 12:24:05 +08:00
-- added a new registration daemon (for fetching data from the new DB) -- updated the old register/activate/update functions to work with the new setup -- fixed a bug in getting keys for data blobs (wasn't re-using keys)
98 lines
2.1 KiB
Python
Executable File
98 lines
2.1 KiB
Python
Executable File
#!/usr/bin/env python
|
|
# -*- coding: utf-8 -*-
|
|
#-----------------------
|
|
# Copyright 2014 Halfmoon Labs, Inc.
|
|
# All Rights Reserved
|
|
#-----------------------
|
|
|
|
import json
|
|
from pymongo import Connection
|
|
from coinrpc.namecoin.namecoind_wrapper import namecoind_transfer, namecoind_name_show, check_registration
|
|
from .register import process_user
|
|
from pymongo import MongoClient
|
|
import os
|
|
|
|
LOAD_BALANCER = os.environ['LOAD_BALANCER']
|
|
import ssl
|
|
|
|
MONGODB_URI = os.environ['MONGODB_URI']
|
|
HEROKU_APP = os.environ['HEROKU_APP']
|
|
remote_client = MongoClient(MONGODB_URI)
|
|
users = remote_client[HEROKU_APP].user
|
|
|
|
#-----------------------------------
|
|
def test_private_key(passphrase,nmc_address):
|
|
|
|
from coinkit.keypair import NamecoinKeypair
|
|
|
|
keypair = NamecoinKeypair.from_passphrase(passphrase)
|
|
|
|
print keypair.wif_pk()
|
|
|
|
generated_nmc_address = keypair.address()
|
|
|
|
if(generated_nmc_address == nmc_address):
|
|
print "found a match"
|
|
return True
|
|
else:
|
|
print "don't match"
|
|
return False
|
|
|
|
#-----------------------------------
|
|
def do_name_transfer(username,live=False):
|
|
|
|
try:
|
|
entry = users.find_one({'username':username})
|
|
nmc_address = entry['namecoin_address']
|
|
backend_server = entry['backend_server']
|
|
except:
|
|
print "no such user in DB"
|
|
return
|
|
|
|
key = 'u/' + username
|
|
|
|
if check_registration(key):
|
|
|
|
value = namecoind_name_show(key)['value']
|
|
|
|
next_blob = None
|
|
|
|
try:
|
|
next_blob = value['next']
|
|
except:
|
|
pass
|
|
|
|
if(live):
|
|
reply = namecoind_transfer(key,nmc_address)
|
|
if 'message' in reply:
|
|
print reply['message']
|
|
else:
|
|
print reply
|
|
entry['name_transferred'] = True
|
|
users.save(entry)
|
|
|
|
print key, nmc_address
|
|
print backend_server
|
|
|
|
passphrase = ''
|
|
#test_private_key(passphrase,nmc_address)
|
|
|
|
if next_blob is not None:
|
|
print next_blob, nmc_address
|
|
if(live):
|
|
print namecoind_transfer(next_blob,nmc_address)
|
|
|
|
else:
|
|
print "activate the name first"
|
|
|
|
#-----------------------------------
|
|
if __name__ == '__main__':
|
|
|
|
live = False
|
|
|
|
username = "stormtrooper64"
|
|
|
|
user = users.find_one({"username":username})
|
|
|
|
do_name_transfer(user['username'],live)
|