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.tsvcontains public wallet metadata;wallet_engine_secrets.tsvcontains plaintext recovery phrases;wallet_engine_journal.tsvcontains opaque durable send state;wallet_engine_toncenter_api_keycontains the persisted provider key;wallet_engine_cpp.logcontains 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 qtOn Ubuntu:
sudo apt install qt6-base-devBuild and run it from the repository root:
just example-cpp-bindgen-runUse 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.