Files
lez-programs/apps/shared/wallet/src/WalletController.h
T
Ricardo Guilherme Schmidt 64ce091045 feat(wallet): add reusable wallet modules
Add program-neutral wallet access, a stable account model, reusable QML controls, transaction confirmation, submitted-transaction presentation, and isolated contract tests.
2026-07-27 12:14:27 +02:00

68 lines
1.8 KiB
C++

#pragma once
#include <QObject>
#include <QString>
#include "WalletProvider.h"
class QNetworkAccessManager;
class QTimer;
class WalletAccountModel;
struct WalletUiState {
bool isWalletOpen = false;
bool walletExists = false;
QString configPath;
QString storagePath;
QString walletHome;
int lastSyncedBlock = 0;
int currentBlockHeight = 0;
QString sequencerAddress;
bool sequencerReachable = true;
};
class WalletController final : public QObject {
Q_OBJECT
public:
// The provider must outlive the controller.
explicit WalletController(WalletProvider& wallet,
QString settingsApplication,
QObject* parent = nullptr);
~WalletController() override;
WalletAccountModel* accountModel() const { return m_accountModel; }
const WalletUiState& state() const { return m_state; }
void start();
QString createAccount(bool isPublic);
void refresh();
QString balance(const QString& accountId, bool isPublic);
QString createDefaultWallet(const QString& password);
QString createWallet(const QString& configPath,
const QString& storagePath,
const QString& password);
bool open();
void disconnect();
signals:
void stateChanged();
private:
static QString defaultWalletHome();
QString defaultConfigPath() const;
QString defaultStoragePath() const;
void openOnStartup();
void applySnapshot(const WalletSnapshot& snapshot);
void checkReachability();
WalletProvider& m_wallet;
QString m_settingsApplication;
WalletUiState m_state;
WalletAccountModel* m_accountModel;
QNetworkAccessManager* m_network;
QTimer* m_reachabilityTimer;
bool m_started = false;
};