You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.5 KiB
Python

from io import BytesIO
from base64 import b64encode
from qrcode import make as qrcode_make
4 years ago
from app.models import Operation
from app.library.digitalocean import do
from app.factory import db
from flask import current_app
4 years ago
def to_ausd(amount):
return int(amount * 1000000)
def from_ausd(amount):
return amount / 1000000
def generate_qr(xmr_address, tx_description):
_address_qr = BytesIO()
qr_uri = f'monero:{xmr_address}?tx_description="{tx_description}"'
qrcode_make(qr_uri).save(_address_qr)
qrcode = b64encode(_address_qr.getvalue()).decode()
return qrcode
4 years ago
def cancel_operation(codename):
op = Operation.query.filter(
Operation.codename == codename
).first()
if op:
if op.droplet_id:
do.destroy_droplet(op.droplet_id)
op.droplet_id = None
op.volume_id = None
db.session.commit()
current_app.logger.info(f'Deleted droplet and associated volume for {codename}')
4 years ago
if op.record_v4_id:
r = do.delete_record(op.record_v4_id)
if r:
op.record_v4_id = None
db.session.commit()
current_app.logger.info(f'Deleted A records for {codename}')
4 years ago
if op.record_v6_id:
r = do.delete_record(op.record_v6_id)
if r:
op.record_v6_id = None
db.session.commit()
current_app.logger.info(f'Deleted AAAA records for {codename}')
4 years ago
else:
current_app.logger.info('Not an op')