Files
ObsidianDragon/src/ui/windows/key_export_dialog.h
DanS 2182c060e6 feat(keys): improve the key-export modal — auto-clear copy, inline QR, cleaner actions
- Auto-clear: the Copy button now routes through App::copySecretToClipboard, so a copied
  private/viewing key is wiped from the clipboard after ~45s (same protection as the seed) with
  a "auto-clears" notice — instead of the raw SetClipboardText that left it indefinitely.
- QR: once the key is revealed, a Show/Hide QR toggle renders the key's QR inline (via the same
  GenerateQRTexture/RenderQRCode widget the Receive tab uses) for scanning into another wallet.
  The QR texture is cached, regenerated on key change, and freed on hide/close/dismiss; hiding the
  key also hides its QR.
- Actions row tightened to Show/Hide · Copy · QR, and the key + QR texture are now cleared on any
  dismissal (Close button, scrim click, Esc), not just the Close button.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-10 20:59:06 -05:00

64 lines
1.5 KiB
C++

// DragonX Wallet - ImGui Edition
// Copyright 2024-2026 The Hush Developers
// Released under the GPLv3
#pragma once
#include <cstdint>
#include <string>
namespace dragonx {
class App;
namespace ui {
/**
* @brief Dialog for exporting private/viewing keys
*
* Displays the private or viewing key for a given address with
* security warnings and copy functionality.
*/
class KeyExportDialog {
public:
enum class KeyType {
Private,
Viewing
};
/**
* @brief Show the key export dialog for an address
* @param address The address to export key for
* @param type The type of key to export
*/
static void show(const std::string& address, KeyType type);
/**
* @brief Render the dialog (call every frame)
* @param app Pointer to app instance for RPC calls
*/
static void render(App* app);
/**
* @brief Check if dialog is currently open
*/
static bool isOpen();
private:
static bool s_open;
static bool s_fetching;
static bool s_show_key;
static bool s_show_qr; // inline QR of the revealed key (for scanning into another wallet)
static std::uintptr_t s_qr_tex; // cached QR texture handle (0 = none)
static std::string s_qr_cached; // key the cached QR was generated for
static KeyType s_key_type;
static std::string s_address;
static std::string s_key;
static std::string s_error;
static void releaseQr(); // free the QR texture + reset its state
};
} // namespace ui
} // namespace dragonx