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