|
|
@ -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
|
|
|
|
)
|
|
|
|
)
|
|
|
|