Example #1
0
def mine():
    while True:
        starter = ''.join([
            random.choice(string.uppercase + string.lowercase + string.digits)
            for x in range(5)
        ])
        diff = send_command.send({"cmd": "get_difficulty"}, out=True)
        diff = json.loads(diff)['difficulty']
        on = 0
        print str(diff), starter
        while True:
            check = starter + str(on)
            if sha512(check).hexdigest().startswith("1" * diff):
                send_command.send({
                    "cmd":
                    "check_coin",
                    "address":
                    config.wallet.find("data", "all")[0]['address'],
                    "starter":
                    starter + str(on),
                    "hash":
                    sha512(check).hexdigest()
                })
                print "Found Coin!"
                break
            else:
                on += 1
Example #2
0
def send(address, amount):
    """

        {"cmd":"send_coin", "for":<address>, "hash":<hash>, "starter":<encrypted new one>}

    """

    amount = int(float(amount) * 10000)
    check = config.nodes.find("nodes", {"address": address})
    if not check:
        print "Address does not exist"
    else:
        check = check[0]
        my_key = config.wallet.find("data", "all")[0]
        my_address = my_key['address']
        my_key = my_key['private']
        key = check['public']
        key = re.findall("([0-9]*)", key)
        key = filter(None, key)
        key = PublicKey(int(key[0]), int(key[1]))
        my_key = re.findall("([0-9]*)", my_key)
        my_key = filter(None, my_key)
        my_key = PrivateKey(int(my_key[0]), int(my_key[1]), int(my_key[2]),
                            int(my_key[3]), int(my_key[4]))
        cc_ = config.db.find("coins", 'all')
        cc = []
        for x in cc_:
            if x['address'] == my_address:
                cc.append(x)
        if len(cc) < amount:
            print "You have insufficient funds."
            return
        cc = cc[:amount]
        transactionid = uuid.uuid4().hex
        sent_ = 0
        for x in cc:
            starter, hash_ = x['starter'], x['hash']
            starter = base64.b64encode(
                encrypt(decrypt(base64.b64decode(starter), my_key), key))
            out_s = {
                'cmd': 'send_coin',
                'for': address,
                "transid": transactionid,
                'starter': starter,
                'hash': hash_,
                "from": my_address,
                "amount_sent": amount,
                "plain": x['starter'],
                "difficulty": x['difficulty'],
                "id": x['id'],
            }

            send_command.send(out_s)
            sent_ += 1
            print str(sent_) + " coins sent to " + address
        print "Coins sent!"
Example #3
0
def send(address, amount):

    """

        {"cmd":"send_coin", "for":<address>, "hash":<hash>, "starter":<encrypted new one>}

    """

    amount = int(float(amount)*10000)
    check = config.nodes.find("nodes", {"address":address})
    if not check:
        print "Address does not exist"    
    else:
        check = check[0]
        my_key = config.wallet.find("data", "all")[0]
        my_address = my_key['address']
        my_key = my_key['private']
        key = check['public']
        key = re.findall("([0-9]*)", key)
        key = filter(None, key)
        key = PublicKey(int(key[0]), int(key[1]))
        my_key = re.findall("([0-9]*)", my_key)
        my_key = filter(None, my_key)
        my_key = PrivateKey(int(my_key[0]), int(my_key[1]), int(my_key[2]), int(my_key[3]), int(my_key[4]))
        cc_ = config.db.find("coins", 'all')
        cc = []
        for x in cc_:
            if x['address'] == my_address:
                cc.append(x)
        if len(cc) < amount:
            print "You have insufficient funds."
            return
        cc = cc[:amount]
        transactionid = uuid.uuid4().hex
        sent_ = 0
        for x in cc:
            starter, hash_ = x['starter'], x['hash']
            starter = base64.b64encode(encrypt(decrypt(base64.b64decode(starter), my_key), key))
            out_s = {'cmd': 'send_coin',
                    'for': address,
                    "transid":transactionid,
                    'starter': starter,
                    'hash': hash_,
                    "from":my_address,
                    "amount_sent":amount,
                    "plain":x['starter'],
                    "difficulty":x['difficulty'],
                    "id":x['id'],
                    }

            send_command.send(out_s)
            sent_ += 1
            print str(sent_)+" coins sent to "+address
        print "Coins sent!"
Example #4
0
def mine():
    while True:
        starter = ''.join([random.choice(string.uppercase+string.lowercase+string.digits) for x in range(5)])    
        diff = send_command.send({"cmd":"get_difficulty"}, out=True)
        diff = json.loads(diff)['difficulty']
        on = 0
        print str(diff), starter
        while True:
            check = starter + str(on)
            if sha512(check).hexdigest().startswith("1"*diff):
                send_command.send({"cmd":"check_coin", "address":config.wallet.find("data", "all")[0]['address'], "starter":starter+str(on), "hash":sha512(check).hexdigest()})
                print "Found Coin!"
                break
            else:
                on += 1
Example #5
0
def count_send():
    mine = config.nodes.find("nodes", "all")
    if not mine:
        mine = 0
    else:
        mine = len(mine)
    print mine
    check = send_command.send({"cmd":"get_nodes_count"}, out=True)
    if not check:
        return
    check = json.loads(check)
    if check['nodes'] > mine:
        send()
Example #6
0
def count_send():
    mine = config.nodes.find("nodes", "all")
    if not mine:
        mine = 0
    else:
        mine = len(mine)
    print mine
    check = send_command.send({"cmd": "get_nodes_count"}, out=True)
    if not check:
        return
    check = json.loads(check)
    if check['nodes'] > mine:
        send()
Example #7
0
def send():
    coins = config.db.find("coins", "all")
    if coins:
        coins = len(coins)
    else:
        coins = 0
    out = send_command.send({"cmd": "coin_count"}, out=True)
    try:
        out = json.loads(out)
    except:
        print "Couldn't get number of coins, if this persists please reset."
        return
    else:
        print out
        if out['coins'] > coins:
            get_db.send()
Example #8
0
def send():
    data = config.wallet.find("data", "all")[0]
    send_command.send({"cmd":"register", "relay":config.relay, "public":data['public'], "address":data['address'], "port":config.port})
Example #9
0
def send():
##    data = config.wallet.find("data", "all")[0]
    send_command.send({"cmd":"register", "relay":config.relay, "public":"hello world", "port":config.port})