Exemplo n.º 1
0
def create_user(username):
    """Checks if a Telegram user is present in the database.
    Returns True if a user is created, False otherwise.
    """
    db.connect(reuse_if_open=True)
    key = Key()
    try:
        User.create(username=username, bch_address=key.address, wif=key.to_wif())
        db.close()
        return True
    except IntegrityError:
        db.close()
        return False
Exemplo n.º 2
0
def index():
    if 'user' not in session:
        session['user'] = secrets.token_hex()
        key = Key()
        wif = key.to_wif()
        # Stores the keys in the cookies
        session['wif'] = wif
        session['address'] = key.address

    return render_template(
        'index.html',
        eb_link=EVENT_BRIBE_LINK,
        address=session['address'],
        wif=session['wif'],
    )
Exemplo n.º 3
0
    return satoshi_to_currency_cached(satoshi, 'bch')


def is_address_valid(address):
    return convert.is_valid(address)


def send(address, amount):
    outputs = [
        (address, amount, 'bch'),
    ]
    try:
        return key.send(outputs)
    except:
        return false


if key_exists():
    print('Debug: key exists')
    priv_key = open(PRIVATE_KEY, 'r')
    key = Key(priv_key.read())
else:
    print('Debug: key does not exists')
    key = Key()
    create_path(PRIVATE_KEY)
    priv_key = open(PRIVATE_KEY, 'w')
    priv_key.write(key.to_wif())
    priv_key.close()
    img = pyqrcode.create(key.address)
    img.svg(QR)