mirror of
https://github.com/monero-project/monero-gui.git
synced 2024-12-23 03:59:38 +00:00
Init wallet asynchronously
This commit is contained in:
parent
7df82af75d
commit
71da777375
3 changed files with 28 additions and 17 deletions
20
main.qml
20
main.qml
|
@ -145,23 +145,12 @@ ApplicationWindow {
|
|||
}
|
||||
console.log("Wallet opened successfully: ", wallet.errorString);
|
||||
}
|
||||
// display splash screen...
|
||||
|
||||
console.log("initializing with daemon address..")
|
||||
if (!wallet.init(persistentSettings.daemon_address, 0)) {
|
||||
console.log("Error initialize wallet: ", wallet.errorString);
|
||||
return
|
||||
}
|
||||
console.log("Wallet initialized successfully")
|
||||
// TODO: update network indicator
|
||||
|
||||
// subscribing for wallet updates
|
||||
wallet.updated.connect(onWalletUpdate);
|
||||
wallet.refreshed.connect(onWalletRefresh);
|
||||
console.log("refreshing wallet async")
|
||||
// TODO: refresh asynchronously without blocking UI, implement signal(s)
|
||||
wallet.refreshAsync();
|
||||
console.log("wallet balance: ", wallet.balance)
|
||||
|
||||
console.log("initializing with daemon address..")
|
||||
wallet.initAsync(persistentSettings.daemon_address, 0);
|
||||
|
||||
}
|
||||
|
||||
|
@ -173,8 +162,7 @@ ApplicationWindow {
|
|||
|
||||
function onWalletRefresh() {
|
||||
console.log(">>> wallet refreshed")
|
||||
leftPanel.unlockedBalanceText = walletManager.displayAmount(wallet.unlockedBalance);
|
||||
leftPanel.balanceText = walletManager.displayAmount(wallet.balance);
|
||||
onWalletUpdate();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ public:
|
|||
// TODO
|
||||
Q_UNUSED(txId)
|
||||
Q_UNUSED(amount)
|
||||
qDebug() << __FUNCTION__;
|
||||
}
|
||||
|
||||
virtual void moneyReceived(const std::string &txId, uint64_t amount)
|
||||
|
@ -35,16 +36,19 @@ public:
|
|||
// TODO
|
||||
Q_UNUSED(txId)
|
||||
Q_UNUSED(amount)
|
||||
qDebug() << __FUNCTION__;
|
||||
}
|
||||
|
||||
virtual void updated()
|
||||
{
|
||||
qDebug() << __FUNCTION__;
|
||||
emit m_wallet->updated();
|
||||
}
|
||||
|
||||
// called when wallet refreshed by background thread or explicitly
|
||||
virtual void refreshed()
|
||||
{
|
||||
qDebug() << __FUNCTION__;
|
||||
emit m_wallet->refreshed();
|
||||
}
|
||||
|
||||
|
@ -74,6 +78,11 @@ Wallet::Status Wallet::status() const
|
|||
return static_cast<Status>(m_walletImpl->status());
|
||||
}
|
||||
|
||||
bool Wallet::connected() const
|
||||
{
|
||||
return m_walletImpl->connected();
|
||||
}
|
||||
|
||||
QString Wallet::errorString() const
|
||||
{
|
||||
return QString::fromStdString(m_walletImpl->errorString());
|
||||
|
@ -99,6 +108,11 @@ bool Wallet::init(const QString &daemonAddress, quint64 upperTransactionLimit)
|
|||
return m_walletImpl->init(daemonAddress.toStdString(), upperTransactionLimit);
|
||||
}
|
||||
|
||||
void Wallet::initAsync(const QString &daemonAddress, quint64 upperTransactionLimit)
|
||||
{
|
||||
m_walletImpl->initAsync(daemonAddress.toStdString(), upperTransactionLimit);
|
||||
}
|
||||
|
||||
bool Wallet::connectToDaemon()
|
||||
{
|
||||
return m_walletImpl->connectToDaemon();
|
||||
|
@ -183,7 +197,7 @@ void Wallet::setPaymentId(const QString &paymentId)
|
|||
Wallet::Wallet(Bitmonero::Wallet *w, QObject *parent)
|
||||
: QObject(parent), m_walletImpl(w), m_history(nullptr)
|
||||
{
|
||||
|
||||
m_walletImpl->setListener(new WalletListenerImpl(this));
|
||||
}
|
||||
|
||||
Wallet::~Wallet()
|
||||
|
|
|
@ -20,6 +20,7 @@ class Wallet : public QObject
|
|||
Q_PROPERTY(QString seed READ getSeed)
|
||||
Q_PROPERTY(QString seedLanguage READ getSeedLanguage)
|
||||
Q_PROPERTY(Status status READ status)
|
||||
Q_PROPERTY(bool connected READ connected)
|
||||
Q_PROPERTY(QString errorString READ errorString)
|
||||
Q_PROPERTY(QString address READ address)
|
||||
Q_PROPERTY(quint64 balance READ balance)
|
||||
|
@ -27,6 +28,7 @@ class Wallet : public QObject
|
|||
Q_PROPERTY(TransactionHistory * history READ history)
|
||||
Q_PROPERTY(QString paymentId READ paymentId WRITE setPaymentId)
|
||||
|
||||
|
||||
public:
|
||||
enum Status {
|
||||
Status_Ok = Bitmonero::Wallet::Status_Ok,
|
||||
|
@ -47,6 +49,9 @@ public:
|
|||
//! returns last operation's status
|
||||
Status status() const;
|
||||
|
||||
//! returns of wallet connected
|
||||
bool connected() const;
|
||||
|
||||
//! returns last operation's error message
|
||||
QString errorString() const;
|
||||
|
||||
|
@ -62,6 +67,9 @@ public:
|
|||
//! initializes wallet
|
||||
Q_INVOKABLE bool init(const QString &daemonAddress, quint64 upperTransactionLimit);
|
||||
|
||||
//! initializes wallet asynchronously
|
||||
Q_INVOKABLE void initAsync(const QString &daemonAddress, quint64 upperTransactionLimit);
|
||||
|
||||
//! connects to daemon
|
||||
Q_INVOKABLE bool connectToDaemon();
|
||||
|
||||
|
@ -124,6 +132,7 @@ private:
|
|||
// history lifetime managed by wallet;
|
||||
TransactionHistory * m_history;
|
||||
QString m_paymentId;
|
||||
|
||||
};
|
||||
|
||||
#endif // WALLET_H
|
||||
|
|
Loading…
Reference in a new issue