|
|
|
@ -55,25 +55,35 @@ def generate_data():
|
|
|
|
|
@bp.cli.command('process_tips')
|
|
|
|
|
def process_tips():
|
|
|
|
|
w = wownero.Wallet()
|
|
|
|
|
txes = w.transfers([], True, False)
|
|
|
|
|
for tx in txes['in']:
|
|
|
|
|
_tx = TipReceived.select().where(TipReceived.txid == tx['txid']).first()
|
|
|
|
|
if not _tx:
|
|
|
|
|
post = Post.select().where(Post.address == tx['address']).first()
|
|
|
|
|
if not post:
|
|
|
|
|
print('No post exists with that address. Not sure wat do.')
|
|
|
|
|
else:
|
|
|
|
|
TipReceived.create(
|
|
|
|
|
post=post,
|
|
|
|
|
txid=tx['txid'],
|
|
|
|
|
timestamp=datetime.utcfromtimestamp(tx['timestamp']),
|
|
|
|
|
amount=sum(tx['amounts']),
|
|
|
|
|
fee=tx['fee']
|
|
|
|
|
)
|
|
|
|
|
print('Saved tip {} ({} WOW) received for post {} by {}'.format(
|
|
|
|
|
tx['txid'], wownero.from_atomic(sum(tx['amounts'])),
|
|
|
|
|
post.id, post.user.username
|
|
|
|
|
))
|
|
|
|
|
for post in Post.select().order_by(Post.timestamp.desc()):
|
|
|
|
|
print(f'Checking new tips for post {post.id}')
|
|
|
|
|
txes = w.transfers(config.WALLET_ACCOUNT, [post.address_index])
|
|
|
|
|
addr = w.get_address(config.WALLET_ACCOUNT, [post.address_index])
|
|
|
|
|
if post.address != addr['addresses'][0]['address']:
|
|
|
|
|
print(f'addresses dont match. skipping.')
|
|
|
|
|
continue
|
|
|
|
|
if txes:
|
|
|
|
|
for tx in txes['in']:
|
|
|
|
|
if tx['unlock_time'] > 0:
|
|
|
|
|
print('someone added a lock time to this tx. skipping for now.')
|
|
|
|
|
continue
|
|
|
|
|
_tx = TipReceived.select().where(TipReceived.txid == tx['txid']).first()
|
|
|
|
|
if not _tx:
|
|
|
|
|
post = Post.select().where(Post.address == tx['address']).first()
|
|
|
|
|
if not post:
|
|
|
|
|
print('No post exists with that address. Not sure wat do.')
|
|
|
|
|
else:
|
|
|
|
|
TipReceived.create(
|
|
|
|
|
post=post,
|
|
|
|
|
txid=tx['txid'],
|
|
|
|
|
timestamp=datetime.utcfromtimestamp(tx['timestamp']),
|
|
|
|
|
amount=sum(tx['amounts']),
|
|
|
|
|
fee=tx['fee']
|
|
|
|
|
)
|
|
|
|
|
print('Saved tip {} ({} WOW) received for post {} by {}'.format(
|
|
|
|
|
tx['txid'], wownero.from_atomic(sum(tx['amounts'])),
|
|
|
|
|
post.id, post.user.username
|
|
|
|
|
))
|
|
|
|
|
|
|
|
|
|
@bp.cli.command('payout_users')
|
|
|
|
|
def payout_users():
|
|
|
|
@ -86,7 +96,7 @@ def payout_users():
|
|
|
|
|
rcvd = user.get_wow_received()
|
|
|
|
|
sent = user.get_wow_sent()
|
|
|
|
|
to_send = rcvd - sent
|
|
|
|
|
if to_send:
|
|
|
|
|
if to_send >= 1:
|
|
|
|
|
print('{} has received {} atomic WOW but sent {} atomic WOW. Sending {} atomic WOW'.format(
|
|
|
|
|
user.username, wownero.from_atomic(rcvd),
|
|
|
|
|
wownero.from_atomic(sent), wownero.from_atomic(to_send)
|
|
|
|
|