|
|
|
@ -86,6 +86,7 @@ def process_tips():
|
|
|
|
|
post.id, post.user.username
|
|
|
|
|
))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@bp.cli.command('payout_users')
|
|
|
|
|
def payout_users():
|
|
|
|
|
wallet = wownero.Wallet()
|
|
|
|
@ -93,15 +94,53 @@ def payout_users():
|
|
|
|
|
print('Wallet balances are {} locked, {} unlocked'.format(
|
|
|
|
|
wownero.from_atomic(balances[0]), wownero.from_atomic(balances[1])
|
|
|
|
|
))
|
|
|
|
|
for user in User.select():
|
|
|
|
|
for user in User.select().join(Post, on=Post.user).distinct().order_by(User.id.asc()):
|
|
|
|
|
rcvd = user.get_wow_received()
|
|
|
|
|
sent = user.get_wow_sent()
|
|
|
|
|
if rcvd == 0:
|
|
|
|
|
continue
|
|
|
|
|
to_send = rcvd - sent
|
|
|
|
|
if to_send >= 1:
|
|
|
|
|
if to_send >= wownero.to_atomic(.5):
|
|
|
|
|
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)
|
|
|
|
|
))
|
|
|
|
|
if balances[1] >= to_send:
|
|
|
|
|
tx_data = {
|
|
|
|
|
'account_index': config.WALLET_ACCOUNT,
|
|
|
|
|
'destinations': [{
|
|
|
|
|
'address': user.address,
|
|
|
|
|
'amount': to_send
|
|
|
|
|
}],
|
|
|
|
|
'subaddress_indices': user.get_post_addresses(),
|
|
|
|
|
'priority': 0,
|
|
|
|
|
'unlock_time': 0,
|
|
|
|
|
'get_tx_key': True,
|
|
|
|
|
'do_not_relay': True,
|
|
|
|
|
'ring_size': 22
|
|
|
|
|
}
|
|
|
|
|
transfer = wallet.make_wallet_rpc('transfer', tx_data)
|
|
|
|
|
print(transfer)
|
|
|
|
|
if 'code' in transfer:
|
|
|
|
|
return
|
|
|
|
|
tx_data['destinations'][0]['amount'] = to_send - transfer['fee']
|
|
|
|
|
tx_data['do_not_relay'] = False
|
|
|
|
|
transfer = wallet.make_wallet_rpc('transfer', tx_data)
|
|
|
|
|
print(tx_data)
|
|
|
|
|
print(transfer)
|
|
|
|
|
if 'code' in transfer:
|
|
|
|
|
return
|
|
|
|
|
TipSent.create(
|
|
|
|
|
from_user=user,
|
|
|
|
|
to_user=user,
|
|
|
|
|
txid=transfer['tx_hash'],
|
|
|
|
|
timestamp=datetime.utcnow(),
|
|
|
|
|
amount=transfer['amount'],
|
|
|
|
|
fee=transfer['fee'],
|
|
|
|
|
)
|
|
|
|
|
print(f'Sent tip of {wownero.from_atomic(transfer["amount"])} WOW to {user} in tx_hash {transfer["tx_hash"]}')
|
|
|
|
|
wallet.make_wallet_rpc('store')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@bp.cli.command('fix_image')
|
|
|
|
|
@click.argument('post_id')
|
|
|
|
|