Ejemplo n.º 1
0
def transfercoins_serverside():
  fromaddr=str(request.form['from_public_address'])
  privatekey=str(request.form['from_private_key'])
  coloramt=int(request.form['amount'])
  color_address=str(request.form['color_address'])
  destination=str(request.form['to_public_address'])
  fee=0.00005
  othermeta="Transfer"
  result=transactions.transfer_tx(fromaddr, destination, fee, privatekey, color_address, coloramt, othermeta)

  response=make_response(result, 200)
  response.headers['Access-Control-Allow-Origin']= '*'
  return response
Ejemplo n.º 2
0
def tx_queue():
    dbstring = "select * from tx_queue where success='False';"
    txs = databases.dbexecute(dbstring, True)
    print txs
    for tx in txs:
        fromaddr = tx[0]
        destination = tx[2]
        fee = float(tx[3]) * 0.00000001
        privatekey = tx[1]
        source_address = tx[4]
        coloramt = tx[5]
        randomid = tx[10]
        othermeta = "transfer"
        try:
            result = transactions.transfer_tx(
                fromaddr, destination, fee, privatekey, source_address, coloramt, othermeta
            )
        except:
            print "ERROR processing queued TX from " + str(fromaddr)
            result = None
        result = result[0]
        if result is None:
            print "No response heard from Bitcoin Network"
            firsttriedatblock = tx[6]
            if firsttriedatblock == -1:
                dbstring = (
                    "update tx_queue set first_tried_at_block='"
                    + str(current_block)
                    + "' where randomid='"
                    + randomid
                    + "';"
                )
                databases.dbexecute(dbstring, False)
            elif current_block - firsttriedatblock > 500:
                dbstring = "delete from tx_queue * where randomid='" + randomid + "';"
                databases.dbexecute(dbstring, False)

        elif len(str(result)) > 10:
            print "HEARD TX RESULT: " + str(result)
            dbstring2 = (
                "update tx_queue set txhash='" + str(result) + "', success='True' where randomid='" + randomid + "';"
            )
            databases.dbexecute(dbstring2, False)
            print dbstring2
            response = {}
            response["transaction_hash"] = result
            response = json.dumps(response)
            postresponse = requests.post(tx[9], data=response)
            print "SENDING POST TO " + str(tx[9]) + " WITH DATA= " + str(response)
            print "RESPONSE HEARD TYPE " + str(postresponse.status_code)
            print "RESPONSE CONTENTS: " + str(postresponse.content)
Ejemplo n.º 3
0
def transfercoins_serverside():
    fromaddr = str(request.form['from_public_address'])
    privatekey = str(request.form['from_private_key'])
    coloramt = int(request.form['amount'])
    color_address = str(request.form['color_address'])
    destination = str(request.form['to_public_address'])
    fee = 0.00005
    othermeta = "Transfer"
    result = transactions.transfer_tx(fromaddr, destination, fee, privatekey,
                                      color_address, coloramt, othermeta)

    response = make_response(result, 200)
    response.headers['Access-Control-Allow-Origin'] = '*'
    return response
Ejemplo n.º 4
0
def transfercoins_serverside():
  jsoninput=json.loads(request.data)

  fromaddr=str(jsoninput['from_public_address'])
  privatekey=str(jsoninput['from_private_key'])
  coloramt=int(jsoninput['amount'])
  source_address=str(jsoninput['source_address'])
  destination=str(jsoninput['to_public_address'])
  fee=0.00005
  othermeta="Transfer"
  result=transactions.transfer_tx(fromaddr, destination, fee, privatekey, source_address, coloramt, othermeta)
  jsonresponse={}
  jsonresponse['transaction_hash']=result[0]
  jsonresponse['source_address']=source_address
  jsonresponse=json.dumps(jsonresponse)
  response=make_response(str(jsonresponse), 200)
  response.headers['Access-Control-Allow-Origin']= '*'
  return response
Ejemplo n.º 5
0
def transfercoins_serverside():
    jsoninput = json.loads(request.data)

    fromaddr = str(jsoninput['from_public_address'])
    privatekey = str(jsoninput['from_private_key'])
    coloramt = int(jsoninput['amount'])
    source_address = str(jsoninput['source_address'])
    destination = str(jsoninput['to_public_address'])
    fee = 0.00005
    othermeta = "Transfer"
    result = transactions.transfer_tx(fromaddr, destination, fee, privatekey,
                                      source_address, coloramt, othermeta)
    jsonresponse = {}
    jsonresponse['transaction_hash'] = result[0]
    jsonresponse['source_address'] = source_address
    jsonresponse = json.dumps(jsonresponse)
    response = make_response(str(jsonresponse), 200)
    response.headers['Access-Control-Allow-Origin'] = '*'
    return response