Skip to content

Latest commit

 

History

History
86 lines (67 loc) · 3.83 KB

README.md

File metadata and controls

86 lines (67 loc) · 3.83 KB

Qt wallet app with generated C++ bindings

This example uses the experimental C++ API generated by uniffi-bindgen-cpp. It provides a small Qt 6 Widgets application that creates mainnet or testnet wallets and exercises the generated lifecycle and wallet-client APIs.

The interface follows familiar desktop-wallet patterns while keeping its own visual identity:

  • a persistent navigation sidebar and portfolio overview;
  • compact wallet cards with network badges and address copy actions;
  • clear empty, loading, success, and error states;
  • a dedicated recovery-phrase dialog that requires backup confirmation;
  • live balance and account status refresh through Toncenter;
  • incoming and outgoing activity with explicit pagination states;
  • transaction-detail dialogs with full hash, logical time, and counterparty;
  • receive-address presentation and a two-step transfer flow;
  • fee emulation before the recovery phrase is unlocked for signing;
  • a persistent Toncenter API-key setting with environment-variable override;
  • an in-app log viewer for lifecycle, refresh, HTTP, activity, and send events.

The generated API currently exposes Rust async functions as blocking C++ methods. The application runs lifecycle, refresh, pagination, preview, and send operations with QtConcurrent, keeping the GUI event loop responsive while the generated bridge polls Rust futures. QtHttpHost implements the engine's HTTP callback with Qt Network, rejects redirects, enforces response limits and timeouts, and supports cancellation.

The example deliberately uses an insecure file-backed host:

  • wallet_engine_wallets.tsv contains public wallet metadata;
  • wallet_engine_secrets.tsv contains plaintext recovery phrases;
  • wallet_engine_journal.tsv contains opaque durable send state;
  • wallet_engine_toncenter_api_key contains the persisted provider key;
  • wallet_engine_cpp.log contains timestamped application diagnostics.

The secret file exists only to demonstrate a C++ implementation of WalletPlatformHost. Never use this storage implementation in production. Replace it with Keychain, Keystore, Credential Manager, or an equivalent secure store.

Metadata written by an older version of this example does not contain the wallet public key. Its Upgrade action derives and appends the missing public metadata from the already stored demo recovery phrase.

The standard public Toncenter endpoint works without configuration. Open Settings to add, replace, or clear an API key. A key entered there is saved to wallet_engine_toncenter_api_key with owner-only permissions and restored at the next launch. TONCENTER_API_KEY, when non-empty, overrides that value for the current process without replacing the persisted key. The key is owned by the HTTP host, is attached only to official Toncenter HTTPS origins, and is never passed through Wallet Engine request values. This demo storage is not a replacement for Keychain, Keystore, or Credential Manager.

Open Logs in the sidebar to inspect or copy the current log. The same lines are written to the terminal. Recovery phrases, API-key values, comments, signed BOCs, request query strings, and complete destination addresses are deliberately excluded from logging.

This remains an integration example, not a production wallet. In particular, do not fund a mainnet wallet created with the plaintext storage adapter.

Install Qt 6 before building. On macOS with Homebrew:

brew install qt

On Ubuntu:

sudo apt install qt6-base-dev

Build and run it from the repository root:

just example-cpp-bindgen-run

Use just example-cpp-bindgen-build when you only need to build it. Both commands regenerate bindings/cpp-experimental first.

Tagged releases also contain native archives for Linux and macOS. Each archive has the static library, shared library, generated C++20 wrapper, and a CMake package file.