fixing bugs in send cmd

master
lza_menace 4 years ago
parent 779f889b6c
commit 3444c6b0c4

@ -168,20 +168,19 @@ def send(update, context):
update.message.reply_text('Bad Wownero amount specified. Provide only positive integers or decimals greater than or equal to 1.')
return False
tipper = db.User.get(telegram_id=update.message.from_user['id'])
tipper_balances = wownero.Wallet().balances(account=tipper.account_index)
if amount > tipper_balances[1]:
sender = db.User.get(telegram_id=update.message.from_user['id'])
sender_balances = wownero.Wallet().balances(account=sender.account_index)
if amount > sender_balances[1]:
update.message.reply_text(f'You do not have sufficient funds to send {amount} WOW. Check your /balance')
return False
# transfer funds to given address
try:
tx = wownero.Wallet().transfer(dest_address=address, amount=amount, priority=2, account=u.account_index)
print(tx)
update.message.reply_text(f'@{update.message.from_user["username"]} has tipped @{target_un} {amount} WOW!')
tx = wownero.Wallet().transfer(dest_address=address, amount=amount, priority=2, account=sender.account_index)
update.message.reply_text(f'Sent {amount} WOW! Tx: {tx}')
except Exception as e:
logging.error(f'Unable to send transfer: {e}. Debug: {update.message}')
update.message.reply_text('Failed to send a tip. Ask for help.')
update.message.reply_text('Failed to send Wownero. Ask for help.')
@wallet_rpc_required
@registration_required

Loading…
Cancel
Save