Ejemplo n.º 1
0
    cur = conn.cursor()        
    cur.execute("INSERT INTO p2sh (input_id, full_script) VALUES (%s,%s)", (input_id, full_script))
    conn.commit()
def writetooutput_script(output_id, full_script):
        print('OUTPUT_SCRIPT:  ', output_id, full_script)
        cur = conn.cursor()        
        cur.execute("INSERT INTO output_script (output_id, full_script) VALUES (%s,%s)", (output_id, full_script))
        conn.commit()
def fetch_single_data(table, column, id):
    cur.execute("SELECT %s FROM %s WHERE id = %s", (column, table, id))
    return cur.fetchone()


# Instanciate the Blockchain by giving the path to the directory 
blockchain = Blockchain(sys.argv[1])
print(blockchain.get_main_chain())
#ordere blocks according to height starting with genesis block
#orderedblockchain= blockchain.get_main_chain()
#print(type(orderedblockchain))
#print(orderedblockchain[0])
#get relevant data from relevant blocks and save to db
def saveblockinfo(block):   
    height = block.height
    id = block.hash
    header = block.header
    timestamp = time.mktime(header.timestamp.timetuple())
    #writetoblock(id, height, timestamp)
    writetoblock(id, height, timestamp)

#returns type of transaction
#types are: coinbase, paytopubkey, paytopubkeyhash, p2sh, op_return