<commit_before>#!/usr/bin/python
#Function Definitions for send utils
import sys
import json
import time
import random
import hashlib
import operator
import commands, csv
import pybitcointools
import os, decimal
import requests, urlparse
from pycoin import encoding
from ecdsa import curves, ecdsa

def is_pubkey_valid(pubkey):
    try:
        sec=encoding.binascii.unhexlify(pubkey)
        public_pair=encoding.sec_to_public_pair(sec)
        return curves.ecdsa.point_is_valid(ecdsa.generator_secp256k1, public_pair[0], public_pair[1])
    except TypeError:
        return False

#get all the utxo we are tracking
def get_utxo():
    list=[]
    try:
	with open('utxolist.csv') as f:
	    reader = csv.DictReader(f, delimiter=',')
	    for row in reader:
	        list.append(row)
    except IOError:
	commands.getoutput('touch utxolist.csv')
    return list

def write_utxo(listdata):
    with open('utxolist.csv', "wb") as out_file:
	writer = csv.DictWriter(out_file, delimiter=',', fieldnames=["address","tx_hash","hash_index","satoshi","block","lock"])
	writer.writeheader()
	for row in listdata:
	    writer.writerow(row)

#def get_utxo_db(address):
#    con=None
#    ROWS=[]
#    try:
#        con = psycopg2.connect(database=DBNAME, user=DBUSER)
#        dbc = con.cursor(cursor_factory=psycopg2.extras.DictCursor)
#        dbc.execute("select * from tx_utxo where lock='1' and address='%s' order by satoshi desc;" % str(address))
#        ROWS = dbc.fetchall()
#    except psycopg2.DatabaseError, e:
#        print json.dumps({"status": "DB Update Error", "error": e , "fix": "Check files/db status and try again "})
#        sys.exit(1)
#    finally:
#        if con:
#            con.close()
#        return ROWS

#def update_db(txlist, status):
#    con=None
#    try:
#        con = psycopg2.connect(database=DBNAME, user=DBUSER)
#        dbc = con.cursor(cursor_factory=psycopg2.extras.DictCursor)
#        if "Success" in status.split(':')[1]:
#          for x in txlist:
#            dbc.execute("update tx_utxo set lock='2' where id=%s;" % int(x['id']))
#            con.commit()
#        else:
#          for x in txlist:
#            dbc.execute("update tx_utxo set lock='3' where id=%s;" % x['id'])
#            con.commit()
#    except psycopg2.DatabaseError, e:
#        print json.dumps({"status": "DB Update Error", "error": e , "fix": "Check files/db status and try again "})
#        sys.exit(1)
#    finally:
#        if con:
#            con.close()

def get_balance(address, csym, div):
    bal1=-3
    bal2=-4
    url =  'https://test.omniwallet.org/v1/address/addr/'
    PAYLOAD = {'addr': address }
    try:
        tx_data= requests.post(url, data=PAYLOAD, verify=False).json()<commit_msg>Update omniwallet url for balance checks<commit_after>#!/usr/bin/python
#Function Definitions for send utils
import sys
import json
import time
import random
import hashlib
import operator
import commands, csv
import pybitcointools
import os, decimal
import requests, urlparse
from pycoin import encoding
from ecdsa import curves, ecdsa

def is_pubkey_valid(pubkey):
    try:
        sec=encoding.binascii.unhexlify(pubkey)
        public_pair=encoding.sec_to_public_pair(sec)
        return curves.ecdsa.point_is_valid(ecdsa.generator_secp256k1, public_pair[0], public_pair[1])
    except TypeError:
        return False

#get all the utxo we are tracking
def get_utxo():
    list=[]
    try:
	with open('utxolist.csv') as f:
	    reader = csv.DictReader(f, delimiter=',')
	    for row in reader:
	        list.append(row)
    except IOError:
	commands.getoutput('touch utxolist.csv')
    return list

def write_utxo(listdata):
    with open('utxolist.csv', "wb") as out_file:
	writer = csv.DictWriter(out_file, delimiter=',', fieldnames=["address","tx_hash","hash_index","satoshi","block","lock"])
	writer.writeheader()
	for row in listdata:
	    writer.writerow(row)

#def get_utxo_db(address):
#    con=None
#    ROWS=[]
#    try:
#        con = psycopg2.connect(database=DBNAME, user=DBUSER)
#        dbc = con.cursor(cursor_factory=psycopg2.extras.DictCursor)
#        dbc.execute("select * from tx_utxo where lock='1' and address='%s' order by satoshi desc;" % str(address))
#        ROWS = dbc.fetchall()
#    except psycopg2.DatabaseError, e:
#        print json.dumps({"status": "DB Update Error", "error": e , "fix": "Check files/db status and try again "})
#        sys.exit(1)
#    finally:
#        if con:
#            con.close()
#        return ROWS

#def update_db(txlist, status):
#    con=None
#    try:
#        con = psycopg2.connect(database=DBNAME, user=DBUSER)
#        dbc = con.cursor(cursor_factory=psycopg2.extras.DictCursor)
#        if "Success" in status.split(':')[1]:
#          for x in txlist:
#            dbc.execute("update tx_utxo set lock='2' where id=%s;" % int(x['id']))
#            con.commit()
#        else:
#          for x in txlist:
#            dbc.execute("update tx_utxo set lock='3' where id=%s;" % x['id'])
#            con.commit()
#    except psycopg2.DatabaseError, e:
#        print json.dumps({"status": "DB Update Error", "error": e , "fix": "Check files/db status and try again "})
#        sys.exit(1)
#    finally:
#        if con:
#            con.close()

def get_balance(address, csym, div):
    bal1=-3
    bal2=-4
    url =  'https://www.omniwallet.org/v1/address/addr/'
    PAYLOAD = {'addr': address }
    try:
        tx_data= requests.post(url, data=PAYLOAD, verify=False).json()
{'fraction_non_alphanumeric': 0.13691128148959475, 'fraction_numerical': 0.008397225264695144, 'mean_word_length': 3.0949177877429, 'pattern_counts': {'":': 12, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6686820', 'n_tokens_mistral': 1912, 'n_tokens_neox': 1886, 'n_words': 448}