idk, mo shit

revamp
lza_menace 2 years ago
parent 25c16e5e72
commit 3e087646f5

@ -1,24 +1,10 @@
import peewee as pw import peewee as pw
import playhouse.postgres_ext as pwpg import playhouse.postgres_ext as pwpg
from monero.wallet import Wallet from monero.wallet import Wallet
# from monero.exceptions import WrongAddress
from xmrbackers import config from xmrbackers import config
# def check_tx_key(tx_id, tx_key, wallet_address):
# try:
# check_data = {
# 'txid': tx_id,
# 'tx_key': tx_key,
# 'address': wallet_address
# }
# w = Wallet(port=config.XMR_WALLET_RPC_PORT, user=config.XMR_WALLET_RPC_USER, password=config.XMR_WALLET_RPC_PASS)
# res = w._backend.raw_request('check_tx_key', check_data)
# return res
# except:
# raise Exception('there was a problem i dont feel like writing good code for right now')
def make_wallet_rpc(method, data={}): def make_wallet_rpc(method, data={}):
try: try:
w = Wallet( w = Wallet(
@ -30,7 +16,7 @@ def make_wallet_rpc(method, data={}):
res = w._backend.raw_request(method, data) res = w._backend.raw_request(method, data)
return res return res
except Exception as e: except Exception as e:
raise Exception('there was a problem i dont feel like writing good code for right now', e) raise e
class EnumArrayField(pwpg.ArrayField): class EnumArrayField(pwpg.ArrayField):

@ -1,8 +1,9 @@
from quart import Blueprint, render_template, flash, redirect, url_for from quart import Blueprint, render_template, flash, redirect, url_for, request
from flask_login import current_user, login_required from flask_login import current_user, login_required
from monero.wallet import Wallet from monero.wallet import Wallet
from monero.address import address from monero.address import address
from monero.numbers import to_atomic, from_atomic from monero.numbers import to_atomic, from_atomic
from monero.backends.jsonrpc.exceptions import RPCError
from xmrbackers.models import * from xmrbackers.models import *
from xmrbackers.helpers import make_wallet_rpc from xmrbackers.helpers import make_wallet_rpc
@ -114,21 +115,37 @@ async def show(handle):
await flash('That creator does not exist.', 'warning') await flash('That creator does not exist.', 'warning')
return redirect(url_for('main.index')) return redirect(url_for('main.index'))
if form.validate_on_submit():
await flash('valid form submission', 'success')
posts = Content.select().where( posts = Content.select().where(
Content.creator == creator, Content.creator == creator,
Content.hidden == False Content.hidden == False
).order_by(Content.post_date.desc()) ).order_by(Content.post_date.desc())
subscription = SubscriptionMeta.select().where( subscriptions = SubscriptionMeta.select().where(
SubscriptionMeta.user == creator SubscriptionMeta.user == creator
).order_by(SubscriptionMeta.create_date.desc()).first() ).order_by(SubscriptionMeta.create_date.desc())
if form.validate_on_submit():
data = {
'txid': form.tx_id.data,
'tx_key': form.tx_key.data,
'address': form.wallet_address.data
}
try:
res = make_wallet_rpc('check_tx_key', data)
subs = subscriptions.where(
SubscriptionMeta.wallet_address == data['address']
)
for sub in subs:
if res['in_pool'] is False and res['received'] >= sub.atomic_xmr:
await flash('Found a valid subscription.', 'success')
print(request)
return redirect(url_for('creator.show', handle=handle))
except RPCError:
await flash('Failed to check TX Key. Problem with provided info.', 'error')
return await render_template( return await render_template(
'creator/show.html', 'creator/show.html',
creator=creator, creator=creator,
subscription=subscription, subscription=subscriptions.first(),
posts=posts, posts=posts,
form=form form=form
) )

Loading…
Cancel
Save