Ejemplo n.º 1
0
def delete_wallet(cli, cb):
    tg_id = cb.from_user.id
    action = cb.data.split('-')[1]

    if action == "first":
        new_msg(cli, cb, tg_id,
                texts.confirm_delete_wallet(tg_id),
                kb.delete_wallet_2(tg_id),
                "wallet_menu_id",
                "wallet_menu_id",
                "on_callback")

    if action == "delete":
        cb.message.reply(texts.deleted_wallet(tg_id))
        wallet_id = cache.get_active_wallet(tg_id)["id"]
        WalletAPI.delete_wallet(wallet_id)

        wallets = cache.get_user_wallets(tg_id)

        new_msg(cli, cb, tg_id,
                # texts.manage_wallets(tg_id),
                # kb.manage_wallets(tg_id),
                # "wallet_menu_id",
                # "wallet_menu_id",
                # "on_callback"
                texts.after_del_wallet(tg_id),
                kb.after_delete_wallet(tg_id),
                "wallet_menu_id",
                "wallet_menu_id",
                "on_callback"
        )
Ejemplo n.º 2
0
def settings(tg_id):
    wallet = cache.get_active_wallet(tg_id)

    wallet_title = "None"
    wallets = cache.get_user_wallets(tg_id)
    if len(wallets) != 0:
        wallet_title = wallet["title"]

    mode = cache.read_user_cache(tg_id, "chat_mode")
    kb = InlineKeyboardMarkup([
        #[InlineKeyboardButton(f"Current Wallet: {wallet_title}", callback_data=f"settings-current_wallet")],
        [
            InlineKeyboardButton("Manage Wallet",
                                 callback_data="settings-manage_wallet")
        ],
        [
            InlineKeyboardButton(f"Chat mode: {mode}",
                                 callback_data=f"settings-chat_mode-{mode}")
        ],
        [
            InlineKeyboardButton("« Back to Wallet",
                                 callback_data="back_wallet")
        ]
    ])
    return kb
Ejemplo n.º 3
0
def await_amount_to(cli, m):
    tg_id = m.from_user.id
    wallet = cache.get_active_wallet(tg_id)
    delete_inline_kb(cli, tg_id, cache.read_user_cache(tg_id, "last_msg_id"))
    fee = cache.get_fee()
    try:
        amount = int(m.text)
        if amount + fee > wallet["balance"]:
            raise Exception
    except:
        m.reply("Invalid amount")
        new_msg(cli, m, tg_id,
                "Invalid amount",
                kb.back_wallet(tg_id),
                "wallet_menu_id",
                "wallet_menu_id",
                "on_message")
        return
    cache.change_user_flag(tg_id, "await_to_amount", False)

    new_msg(cli, m, tg_id,
            texts.confirm_transaction(cache.read_user_cache(tg_id, "address_to"), amount),
            kb.confirm_tx(tg_id, amount),
            "wallet_menu_id",
            "wallet_menu_id",
            "on_message")
Ejemplo n.º 4
0
def wallet_menu(cli, cb):
    tg_id = cb.from_user.id
    btn = cb.data.split("-")[1]
    wallet = cache.get_active_wallet(tg_id)
    if btn == "send":

        if wallet["balance"] > 1:
            cache.change_user_flag(tg_id, "await_to_address", True)

            new_msg(cli, cb, tg_id, "Send me an address to send UAX:", kb.back_wallet(), "wallet_menu_id", "wallet_menu_id",
                    "on_callback")
        else:
            new_msg(cli, cb, tg_id, "Insufficient funds", kb.back_wallet(), "wallet_menu_id",
                    "wallet_menu_id",
                    "on_callback")

    elif btn == "recive":
        new_msg(cli, cb, tg_id,
                wallet["address"],
                kb.back_wallet(),
                "wallet_menu_id",
                "wallet_menu_id",
                "on_callback")

    elif btn == "settings":
        new_msg(cli, cb, tg_id,
                texts.wallet_settings(tg_id),
                kb.settings(tg_id),
                "wallet_menu_id",
                "wallet_menu_id",
                "on_callback")
Ejemplo n.º 5
0
def wallet_menu(tg_id):
    wallet = cache.get_active_wallet(tg_id)

    wallet_txt = f"Balance of {wallet['title']}:\n\n" \
                 f"~ {wallet['balance']} UAX"

    return wallet_txt
Ejemplo n.º 6
0
def max_amount(tg_id):
    wallet = cache.get_active_wallet(tg_id)
    fee = cache.get_fee()
    max_amount = Decimal(wallet['balance']) - Decimal(fee)
    kb = InlineKeyboardMarkup([[
        InlineKeyboardButton(f"Use Max - {max_amount} UAX",
                             callback_data=f"send_max-{max_amount}")
    ], [InlineKeyboardButton("« Back to Wallet",
                             callback_data="back_wallet")]])
    return kb
Ejemplo n.º 7
0
def send_max(cli, cb):
    tg_id = cb.from_user.id
    wallet = cache.get_active_wallet(tg_id)
    fee = cache.get_fee()
    amount = wallet["balance"] - fee
    cache.change_user_flag(tg_id, "await_to_amount", False)
    new_msg(cli, cb, tg_id,
            texts.confirm_transaction(cache.read_user_cache(tg_id, "address_to"), amount),
            kb.confirm_tx(tg_id, amount),
            "wallet_menu_id",
            "wallet_menu_id",
            "on_callback")
Ejemplo n.º 8
0
def wallet_settings(cli, cb):
    tg_id = cb.from_user.id
    action = cb.data.split('-')[1]
    if action == "show_phrase":
        new_msg(cli, cb, tg_id,
                texts.show_phrase(tg_id),
                kb.back_wallet_settings(tg_id),
                "wallet_menu_id",
                "wallet_menu_id",
                "on_callback")

    elif action == "edit_title":
        cache.change_user_flag(tg_id, "await_wallet_title", True)
        #cache.write_user_cache(tg_id, "last_wallet_id", wallet_id)
        new_msg(cli, cb, tg_id,
                texts.edit_title(tg_id),
                kb.back_wallet_settings(tg_id),
                "wallet_menu_id",
                "wallet_menu_id",
                "on_callback")

    elif action == "delete_wallet":
        wallet_id = cache.get_active_wallet(tg_id)["id"]
        new_msg(cli, cb, tg_id,
                texts.delete_wallet(tg_id),
                kb.delete_wallet_1(tg_id),
                "wallet_menu_id",
                "wallet_menu_id",
                "on_callback")

    elif action == "back_wallet":
        cache.change_user_flag(tg_id, "await_wallet_title", False)
        new_msg(cli, cb, tg_id,
                texts.settings_wallet(tg_id),
                kb.settings_wallet(tg_id),
                "wallet_menu_id",
                "wallet_menu_id",
                "on_callback")
Ejemplo n.º 9
0
def my_adr(cli, m):
    wallet = cache.get_active_wallet(m.from_user.id)
    m.reply(wallet["address"])