mirror of
https://github.com/monero-project/monero-gui.git
synced 2024-11-17 00:07:51 +00:00
Merge pull request #442
0b41fbc
Don't close/reopen when changing daemon requires #1655 (Jaquee)2586404
sync progress improvements (Jaquee)eb909e1
async connectionStatus and init (Jaquee)cb3281d
WalletManager: fix possible race (Jaquee)9dbbd4c
WalletManager: check connection before isMining() (Jaquee)
This commit is contained in:
commit
739d24efb4
7 changed files with 96 additions and 45 deletions
|
@ -42,7 +42,7 @@ Item {
|
||||||
var progressLevel = ((currentBlock/targetBlock) * 100).toFixed(0);
|
var progressLevel = ((currentBlock/targetBlock) * 100).toFixed(0);
|
||||||
fillLevel = progressLevel
|
fillLevel = progressLevel
|
||||||
progressText.text = qsTr("Synchronizing blocks %1/%2").arg(currentBlock.toFixed(0)).arg(targetBlock.toFixed(0));
|
progressText.text = qsTr("Synchronizing blocks %1/%2").arg(currentBlock.toFixed(0)).arg(targetBlock.toFixed(0));
|
||||||
item.visible = (currentWallet.connected !== Wallet.ConnectionStatus_Disconnected) && (currentBlock < targetBlock)
|
progressBar.visible = currentBlock < targetBlock
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
27
main.qml
27
main.qml
|
@ -55,7 +55,6 @@ ApplicationWindow {
|
||||||
property var transaction;
|
property var transaction;
|
||||||
property var transactionDescription;
|
property var transactionDescription;
|
||||||
property alias password : passwordDialog.password
|
property alias password : passwordDialog.password
|
||||||
property int splashCounter: 0
|
|
||||||
property bool isNewWallet: false
|
property bool isNewWallet: false
|
||||||
property int restoreHeight:0
|
property int restoreHeight:0
|
||||||
property bool daemonSynced: false
|
property bool daemonSynced: false
|
||||||
|
@ -265,9 +264,11 @@ ApplicationWindow {
|
||||||
return path.replace(/.*[\/\\]/, '').replace(/\.keys$/, '')
|
return path.replace(/.*[\/\\]/, '').replace(/\.keys$/, '')
|
||||||
}
|
}
|
||||||
|
|
||||||
function onWalletConnectionStatusChanged(){
|
function onWalletConnectionStatusChanged(status){
|
||||||
console.log("Wallet connection status changed")
|
console.log("Wallet connection status changed")
|
||||||
middlePanel.updateStatus();
|
middlePanel.updateStatus();
|
||||||
|
leftPanel.networkStatus.connected = status
|
||||||
|
leftPanel.progressBar.visible = (status === Wallet.ConnectionStatus_Connected) && !daemonSynced
|
||||||
}
|
}
|
||||||
|
|
||||||
function onWalletOpened(wallet) {
|
function onWalletOpened(wallet) {
|
||||||
|
@ -310,7 +311,6 @@ ApplicationWindow {
|
||||||
console.log(">>> wallet updated")
|
console.log(">>> wallet updated")
|
||||||
middlePanel.unlockedBalanceText = leftPanel.unlockedBalanceText = walletManager.displayAmount(currentWallet.unlockedBalance);
|
middlePanel.unlockedBalanceText = leftPanel.unlockedBalanceText = walletManager.displayAmount(currentWallet.unlockedBalance);
|
||||||
middlePanel.balanceText = leftPanel.balanceText = walletManager.displayAmount(currentWallet.balance);
|
middlePanel.balanceText = leftPanel.balanceText = walletManager.displayAmount(currentWallet.balance);
|
||||||
console.log("time to unlock: ", currentWallet.history.minutesToUnlock);
|
|
||||||
// Update history if new block found since last update and balance is locked.
|
// Update history if new block found since last update and balance is locked.
|
||||||
if(foundNewBlock && currentWallet.history.locked) {
|
if(foundNewBlock && currentWallet.history.locked) {
|
||||||
foundNewBlock = false;
|
foundNewBlock = false;
|
||||||
|
@ -336,11 +336,16 @@ ApplicationWindow {
|
||||||
|
|
||||||
// Daemon fully synced
|
// Daemon fully synced
|
||||||
// TODO: implement onDaemonSynced or similar in wallet API and don't start refresh thread before daemon is synced
|
// TODO: implement onDaemonSynced or similar in wallet API and don't start refresh thread before daemon is synced
|
||||||
daemonSynced = (currentWallet.connected != Wallet.ConnectionStatus_Disconnected && dCurrentBlock >= dTargetBlock)
|
daemonSynced = dCurrentBlock >= dTargetBlock
|
||||||
|
// Update daemon sync progress
|
||||||
leftPanel.progressBar.updateProgress(dCurrentBlock,dTargetBlock);
|
leftPanel.progressBar.updateProgress(dCurrentBlock,dTargetBlock);
|
||||||
updateSyncing((currentWallet.connected !== Wallet.ConnectionStatus_Disconnected) && (dCurrentBlock < dTargetBlock))
|
leftPanel.progressBar.visible = !daemonSynced && currentWallet.connected !== Wallet.ConnectionStatus_Disconnected
|
||||||
|
// Update wallet sync progress
|
||||||
|
updateSyncing((currentWallet.connected !== Wallet.ConnectionStatus_Disconnected) && !daemonSynced)
|
||||||
|
// Update transfer page status
|
||||||
middlePanel.updateStatus();
|
middlePanel.updateStatus();
|
||||||
|
|
||||||
|
|
||||||
// If wallet isnt connected and no daemon is running - Ask
|
// If wallet isnt connected and no daemon is running - Ask
|
||||||
if(currentWallet.connected === Wallet.ConnectionStatus_Disconnected && !daemonManager.running() && !walletInitialized){
|
if(currentWallet.connected === Wallet.ConnectionStatus_Disconnected && !daemonManager.running() && !walletInitialized){
|
||||||
daemonManagerDialog.open();
|
daemonManagerDialog.open();
|
||||||
|
@ -392,16 +397,9 @@ ApplicationWindow {
|
||||||
daemonRunning = false;
|
daemonRunning = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function onWalletNewBlock(blockHeight) {
|
function onWalletNewBlock(blockHeight, targetHeight) {
|
||||||
// Update progress bar
|
// Update progress bar
|
||||||
var currHeight = blockHeight
|
leftPanel.progressBar.updateProgress(blockHeight,targetHeight);
|
||||||
//fast refresh until restoreHeight is reached
|
|
||||||
var increment = ((restoreHeight == 0) || currHeight < restoreHeight)? 1000 : 10
|
|
||||||
|
|
||||||
if(currHeight > splashCounter + increment){
|
|
||||||
splashCounter = currHeight
|
|
||||||
leftPanel.progressBar.updateProgress(currHeight,currentWallet.daemonBlockChainTargetHeight());
|
|
||||||
}
|
|
||||||
foundNewBlock = true;
|
foundNewBlock = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -712,7 +710,6 @@ ApplicationWindow {
|
||||||
// close wallet and show wizard
|
// close wallet and show wizard
|
||||||
function showWizard(){
|
function showWizard(){
|
||||||
walletInitialized = false;
|
walletInitialized = false;
|
||||||
splashCounter = 0;
|
|
||||||
closeWallet();
|
closeWallet();
|
||||||
currentWallet = undefined;
|
currentWallet = undefined;
|
||||||
wizard.restart();
|
wizard.restart();
|
||||||
|
|
|
@ -324,8 +324,8 @@ Rectangle {
|
||||||
var newDaemon = daemonAddr.text + ":" + daemonPort.text
|
var newDaemon = daemonAddr.text + ":" + daemonPort.text
|
||||||
if(persistentSettings.daemon_address != newDaemon) {
|
if(persistentSettings.daemon_address != newDaemon) {
|
||||||
persistentSettings.daemon_address = newDaemon
|
persistentSettings.daemon_address = newDaemon
|
||||||
//reconnect wallet
|
//Reinit wallet
|
||||||
appWindow.initialize();
|
currentWallet.initAsync(newDaemon)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -682,7 +682,6 @@ Rectangle {
|
||||||
//TODO: enable send page when we're connected and daemon is synced
|
//TODO: enable send page when we're connected and daemon is synced
|
||||||
|
|
||||||
function updateStatus() {
|
function updateStatus() {
|
||||||
console.log("updated transfer page status")
|
|
||||||
if(typeof currentWallet === "undefined") {
|
if(typeof currentWallet === "undefined") {
|
||||||
statusText.text = qsTr("Wallet is not connected to daemon.") + "<br>" + root.startLinkText
|
statusText.text = qsTr("Wallet is not connected to daemon.") + "<br>" + root.startLinkText
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
#include <QtConcurrent/QtConcurrent>
|
#include <QtConcurrent/QtConcurrent>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QVector>
|
#include <QVector>
|
||||||
|
#include <QMutex>
|
||||||
|
#include <QMutexLocker>
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
static const int DAEMON_BLOCKCHAIN_HEIGHT_CACHE_TTL_SECONDS = 10;
|
static const int DAEMON_BLOCKCHAIN_HEIGHT_CACHE_TTL_SECONDS = 10;
|
||||||
|
@ -54,7 +56,7 @@ public:
|
||||||
virtual void newBlock(uint64_t height)
|
virtual void newBlock(uint64_t height)
|
||||||
{
|
{
|
||||||
// qDebug() << __FUNCTION__;
|
// qDebug() << __FUNCTION__;
|
||||||
emit m_wallet->newBlock(height);
|
emit m_wallet->newBlock(height, m_wallet->daemonBlockChainTargetHeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void updated()
|
virtual void updated()
|
||||||
|
@ -103,17 +105,35 @@ bool Wallet::testnet() const
|
||||||
return m_walletImpl->testnet();
|
return m_walletImpl->testnet();
|
||||||
}
|
}
|
||||||
|
|
||||||
Wallet::ConnectionStatus Wallet::connected() const
|
|
||||||
|
void Wallet::updateConnectionStatusAsync()
|
||||||
{
|
{
|
||||||
// cache connection status
|
QFuture<Monero::Wallet::ConnectionStatus> future = QtConcurrent::run(m_walletImpl, &Monero::Wallet::connected);
|
||||||
if (!m_initialized || m_connectionStatusTime.elapsed() / 1000 > m_connectionStatusTtl) {
|
QFutureWatcher<Monero::Wallet::ConnectionStatus> *connectionWatcher = new QFutureWatcher<Monero::Wallet::ConnectionStatus>();
|
||||||
m_initialized = true;
|
|
||||||
ConnectionStatus newStatus = static_cast<ConnectionStatus>(m_walletImpl->connected());
|
connect(connectionWatcher, &QFutureWatcher<Monero::Wallet::ConnectionStatus>::finished, [=]() {
|
||||||
|
QFuture<Monero::Wallet::ConnectionStatus> future = connectionWatcher->future();
|
||||||
|
connectionWatcher->deleteLater();
|
||||||
|
ConnectionStatus newStatus = static_cast<ConnectionStatus>(future.result());
|
||||||
if (newStatus != m_connectionStatus) {
|
if (newStatus != m_connectionStatus) {
|
||||||
m_connectionStatus = newStatus;
|
m_connectionStatus = newStatus;
|
||||||
emit connectionStatusChanged();
|
emit connectionStatusChanged(newStatus);
|
||||||
}
|
}
|
||||||
|
// Release lock
|
||||||
|
m_connectionStatusRunning = false;
|
||||||
|
});
|
||||||
|
connectionWatcher->setFuture(future);
|
||||||
|
}
|
||||||
|
|
||||||
|
Wallet::ConnectionStatus Wallet::connected(bool forceCheck)
|
||||||
|
{
|
||||||
|
// cache connection status
|
||||||
|
if (forceCheck || !m_initialized || (m_connectionStatusTime.elapsed() / 1000 > m_connectionStatusTtl && !m_connectionStatusRunning) || m_connectionStatusTime.elapsed() > 30000) {
|
||||||
|
qDebug() << "Checking connection status";
|
||||||
|
m_connectionStatusRunning = true;
|
||||||
|
m_initialized = true;
|
||||||
m_connectionStatusTime.restart();
|
m_connectionStatusTime.restart();
|
||||||
|
updateConnectionStatusAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
return m_connectionStatus;
|
return m_connectionStatus;
|
||||||
|
@ -151,17 +171,38 @@ bool Wallet::store(const QString &path)
|
||||||
|
|
||||||
bool Wallet::init(const QString &daemonAddress, quint64 upperTransactionLimit, bool isRecovering, quint64 restoreHeight)
|
bool Wallet::init(const QString &daemonAddress, quint64 upperTransactionLimit, bool isRecovering, quint64 restoreHeight)
|
||||||
{
|
{
|
||||||
return m_walletImpl->init(daemonAddress.toStdString(), upperTransactionLimit);
|
qDebug() << "init non async";
|
||||||
}
|
|
||||||
|
|
||||||
void Wallet::initAsync(const QString &daemonAddress, quint64 upperTransactionLimit, bool isRecovering, quint64 restoreHeight)
|
|
||||||
{
|
|
||||||
if (isRecovering){
|
if (isRecovering){
|
||||||
qDebug() << "RESTORING";
|
qDebug() << "RESTORING";
|
||||||
m_walletImpl->setRecoveringFromSeed(true);
|
m_walletImpl->setRecoveringFromSeed(true);
|
||||||
m_walletImpl->setRefreshFromBlockHeight(restoreHeight);
|
m_walletImpl->setRefreshFromBlockHeight(restoreHeight);
|
||||||
}
|
}
|
||||||
m_walletImpl->initAsync(daemonAddress.toStdString(), upperTransactionLimit);
|
m_walletImpl->init(daemonAddress.toStdString(), upperTransactionLimit);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Wallet::initAsync(const QString &daemonAddress, quint64 upperTransactionLimit, bool isRecovering, quint64 restoreHeight)
|
||||||
|
{
|
||||||
|
qDebug() << "initAsync: " + daemonAddress;
|
||||||
|
m_connectionStatus = Wallet::ConnectionStatus_Disconnected;
|
||||||
|
emit connectionStatusChanged(m_connectionStatus);
|
||||||
|
|
||||||
|
QFuture<bool> future = QtConcurrent::run(this, &Wallet::init,
|
||||||
|
daemonAddress, upperTransactionLimit, isRecovering, restoreHeight);
|
||||||
|
QFutureWatcher<bool> * watcher = new QFutureWatcher<bool>();
|
||||||
|
|
||||||
|
connect(watcher, &QFutureWatcher<bool>::finished,
|
||||||
|
this, [this, watcher, daemonAddress, upperTransactionLimit, isRecovering, restoreHeight]() {
|
||||||
|
QFuture<bool> future = watcher->future();
|
||||||
|
watcher->deleteLater();
|
||||||
|
if(future.result()){
|
||||||
|
qDebug() << "init async finished - starting refresh";
|
||||||
|
connected(true);
|
||||||
|
m_walletImpl->startRefresh();
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
watcher->setFuture(future);
|
||||||
}
|
}
|
||||||
|
|
||||||
//! create a view only wallet
|
//! create a view only wallet
|
||||||
|
@ -220,6 +261,7 @@ quint64 Wallet::daemonBlockChainTargetHeight() const
|
||||||
if (m_daemonBlockChainTargetHeight == 0
|
if (m_daemonBlockChainTargetHeight == 0
|
||||||
|| m_daemonBlockChainTargetHeightTime.elapsed() / 1000 > m_daemonBlockChainTargetHeightTtl) {
|
|| m_daemonBlockChainTargetHeightTime.elapsed() / 1000 > m_daemonBlockChainTargetHeightTtl) {
|
||||||
m_daemonBlockChainTargetHeight = m_walletImpl->daemonBlockChainTargetHeight();
|
m_daemonBlockChainTargetHeight = m_walletImpl->daemonBlockChainTargetHeight();
|
||||||
|
|
||||||
// Target height is set to 0 if daemon is synced.
|
// Target height is set to 0 if daemon is synced.
|
||||||
// Use current height from daemon when target height < current height
|
// Use current height from daemon when target height < current height
|
||||||
if (m_daemonBlockChainTargetHeight < m_daemonBlockChainHeight){
|
if (m_daemonBlockChainTargetHeight < m_daemonBlockChainHeight){
|
||||||
|
@ -242,6 +284,7 @@ bool Wallet::refresh()
|
||||||
|
|
||||||
void Wallet::refreshAsync()
|
void Wallet::refreshAsync()
|
||||||
{
|
{
|
||||||
|
qDebug() << "refresh async";
|
||||||
m_walletImpl->refreshAsync();
|
m_walletImpl->refreshAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -273,13 +316,14 @@ void Wallet::createTransactionAsync(const QString &dst_addr, const QString &paym
|
||||||
QFuture<PendingTransaction*> future = QtConcurrent::run(this, &Wallet::createTransaction,
|
QFuture<PendingTransaction*> future = QtConcurrent::run(this, &Wallet::createTransaction,
|
||||||
dst_addr, payment_id,amount, mixin_count, priority);
|
dst_addr, payment_id,amount, mixin_count, priority);
|
||||||
QFutureWatcher<PendingTransaction*> * watcher = new QFutureWatcher<PendingTransaction*>();
|
QFutureWatcher<PendingTransaction*> * watcher = new QFutureWatcher<PendingTransaction*>();
|
||||||
watcher->setFuture(future);
|
|
||||||
connect(watcher, &QFutureWatcher<PendingTransaction*>::finished,
|
connect(watcher, &QFutureWatcher<PendingTransaction*>::finished,
|
||||||
this, [this, watcher,dst_addr,payment_id,mixin_count]() {
|
this, [this, watcher,dst_addr,payment_id,mixin_count]() {
|
||||||
QFuture<PendingTransaction*> future = watcher->future();
|
QFuture<PendingTransaction*> future = watcher->future();
|
||||||
watcher->deleteLater();
|
watcher->deleteLater();
|
||||||
emit transactionCreated(future.result(),dst_addr,payment_id,mixin_count);
|
emit transactionCreated(future.result(),dst_addr,payment_id,mixin_count);
|
||||||
});
|
});
|
||||||
|
watcher->setFuture(future);
|
||||||
}
|
}
|
||||||
|
|
||||||
PendingTransaction *Wallet::createTransactionAll(const QString &dst_addr, const QString &payment_id,
|
PendingTransaction *Wallet::createTransactionAll(const QString &dst_addr, const QString &payment_id,
|
||||||
|
@ -299,13 +343,14 @@ void Wallet::createTransactionAllAsync(const QString &dst_addr, const QString &p
|
||||||
QFuture<PendingTransaction*> future = QtConcurrent::run(this, &Wallet::createTransactionAll,
|
QFuture<PendingTransaction*> future = QtConcurrent::run(this, &Wallet::createTransactionAll,
|
||||||
dst_addr, payment_id, mixin_count, priority);
|
dst_addr, payment_id, mixin_count, priority);
|
||||||
QFutureWatcher<PendingTransaction*> * watcher = new QFutureWatcher<PendingTransaction*>();
|
QFutureWatcher<PendingTransaction*> * watcher = new QFutureWatcher<PendingTransaction*>();
|
||||||
watcher->setFuture(future);
|
|
||||||
connect(watcher, &QFutureWatcher<PendingTransaction*>::finished,
|
connect(watcher, &QFutureWatcher<PendingTransaction*>::finished,
|
||||||
this, [this, watcher,dst_addr,payment_id,mixin_count]() {
|
this, [this, watcher,dst_addr,payment_id,mixin_count]() {
|
||||||
QFuture<PendingTransaction*> future = watcher->future();
|
QFuture<PendingTransaction*> future = watcher->future();
|
||||||
watcher->deleteLater();
|
watcher->deleteLater();
|
||||||
emit transactionCreated(future.result(),dst_addr,payment_id,mixin_count);
|
emit transactionCreated(future.result(),dst_addr,payment_id,mixin_count);
|
||||||
});
|
});
|
||||||
|
watcher->setFuture(future);
|
||||||
}
|
}
|
||||||
|
|
||||||
PendingTransaction *Wallet::createSweepUnmixableTransaction()
|
PendingTransaction *Wallet::createSweepUnmixableTransaction()
|
||||||
|
@ -319,13 +364,14 @@ void Wallet::createSweepUnmixableTransactionAsync()
|
||||||
{
|
{
|
||||||
QFuture<PendingTransaction*> future = QtConcurrent::run(this, &Wallet::createSweepUnmixableTransaction);
|
QFuture<PendingTransaction*> future = QtConcurrent::run(this, &Wallet::createSweepUnmixableTransaction);
|
||||||
QFutureWatcher<PendingTransaction*> * watcher = new QFutureWatcher<PendingTransaction*>();
|
QFutureWatcher<PendingTransaction*> * watcher = new QFutureWatcher<PendingTransaction*>();
|
||||||
watcher->setFuture(future);
|
|
||||||
connect(watcher, &QFutureWatcher<PendingTransaction*>::finished,
|
connect(watcher, &QFutureWatcher<PendingTransaction*>::finished,
|
||||||
this, [this, watcher]() {
|
this, [this, watcher]() {
|
||||||
QFuture<PendingTransaction*> future = watcher->future();
|
QFuture<PendingTransaction*> future = watcher->future();
|
||||||
watcher->deleteLater();
|
watcher->deleteLater();
|
||||||
emit transactionCreated(future.result(),"","",0);
|
emit transactionCreated(future.result(),"","",0);
|
||||||
});
|
});
|
||||||
|
watcher->setFuture(future);
|
||||||
}
|
}
|
||||||
|
|
||||||
UnsignedTransaction * Wallet::loadTxFile(const QString &fileName)
|
UnsignedTransaction * Wallet::loadTxFile(const QString &fileName)
|
||||||
|
@ -542,6 +588,7 @@ Wallet::Wallet(Monero::Wallet *w, QObject *parent)
|
||||||
m_daemonBlockChainHeightTime.restart();
|
m_daemonBlockChainHeightTime.restart();
|
||||||
m_daemonBlockChainTargetHeightTime.restart();
|
m_daemonBlockChainTargetHeightTime.restart();
|
||||||
m_initialized = false;
|
m_initialized = false;
|
||||||
|
m_connectionStatusRunning = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Wallet::~Wallet()
|
Wallet::~Wallet()
|
||||||
|
|
|
@ -3,6 +3,8 @@
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QTime>
|
#include <QTime>
|
||||||
|
#include <QMutex>
|
||||||
|
#include <QtConcurrent/QtConcurrent>
|
||||||
|
|
||||||
#include "wallet/wallet2_api.h" // we need to have an access to the Monero::Wallet::Status enum here;
|
#include "wallet/wallet2_api.h" // we need to have an access to the Monero::Wallet::Status enum here;
|
||||||
#include "PendingTransaction.h" // we need to have an access to the PendingTransaction::Priority enum here;
|
#include "PendingTransaction.h" // we need to have an access to the PendingTransaction::Priority enum here;
|
||||||
|
@ -75,7 +77,8 @@ public:
|
||||||
bool testnet() const;
|
bool testnet() const;
|
||||||
|
|
||||||
//! returns whether the wallet is connected, and version status
|
//! returns whether the wallet is connected, and version status
|
||||||
ConnectionStatus connected() const;
|
ConnectionStatus connected(bool forceCheck = false);
|
||||||
|
void updateConnectionStatusAsync();
|
||||||
|
|
||||||
//! returns true if wallet was ever synchronized
|
//! returns true if wallet was ever synchronized
|
||||||
bool synchronized() const;
|
bool synchronized() const;
|
||||||
|
@ -98,10 +101,10 @@ public:
|
||||||
Q_INVOKABLE bool store(const QString &path = "");
|
Q_INVOKABLE bool store(const QString &path = "");
|
||||||
|
|
||||||
//! initializes wallet
|
//! initializes wallet
|
||||||
Q_INVOKABLE bool init(const QString &daemonAddress, quint64 upperTransactionLimit, bool isRecovering = false, quint64 restoreHeight = 0);
|
Q_INVOKABLE bool init(const QString &daemonAddress, quint64 upperTransactionLimit = 0, bool isRecovering = false, quint64 restoreHeight = 0);
|
||||||
|
|
||||||
//! initializes wallet asynchronously
|
//! initializes wallet asynchronously
|
||||||
Q_INVOKABLE void initAsync(const QString &daemonAddress, quint64 upperTransactionLimit, bool isRecovering = false, quint64 restoreHeight = 0);
|
Q_INVOKABLE void initAsync(const QString &daemonAddress, quint64 upperTransactionLimit = 0, bool isRecovering = false, quint64 restoreHeight = 0);
|
||||||
|
|
||||||
//! create a view only wallet
|
//! create a view only wallet
|
||||||
Q_INVOKABLE bool createViewOnly(const QString &path, const QString &password) const;
|
Q_INVOKABLE bool createViewOnly(const QString &path, const QString &password) const;
|
||||||
|
@ -231,13 +234,13 @@ signals:
|
||||||
void moneySpent(const QString &txId, quint64 amount);
|
void moneySpent(const QString &txId, quint64 amount);
|
||||||
void moneyReceived(const QString &txId, quint64 amount);
|
void moneyReceived(const QString &txId, quint64 amount);
|
||||||
void unconfirmedMoneyReceived(const QString &txId, quint64 amount);
|
void unconfirmedMoneyReceived(const QString &txId, quint64 amount);
|
||||||
void newBlock(quint64 height);
|
void newBlock(quint64 height, quint64 targetHeight);
|
||||||
void historyModelChanged() const;
|
void historyModelChanged() const;
|
||||||
|
|
||||||
// emitted when transaction is created async
|
// emitted when transaction is created async
|
||||||
void transactionCreated(PendingTransaction * transaction, QString address, QString paymentId, quint32 mixinCount);
|
void transactionCreated(PendingTransaction * transaction, QString address, QString paymentId, quint32 mixinCount);
|
||||||
|
|
||||||
void connectionStatusChanged() const;
|
void connectionStatusChanged(ConnectionStatus status) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Wallet(QObject * parent = nullptr);
|
Wallet(QObject * parent = nullptr);
|
||||||
|
@ -266,6 +269,8 @@ private:
|
||||||
mutable bool m_initialized;
|
mutable bool m_initialized;
|
||||||
AddressBook * m_addressBook;
|
AddressBook * m_addressBook;
|
||||||
mutable AddressBookModel * m_addressBookModel;
|
mutable AddressBookModel * m_addressBookModel;
|
||||||
|
QMutex m_connectionStatusMutex;
|
||||||
|
bool m_connectionStatusRunning;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -64,13 +64,14 @@ void WalletManager::openWalletAsync(const QString &path, const QString &password
|
||||||
QFuture<Wallet*> future = QtConcurrent::run(this, &WalletManager::openWallet,
|
QFuture<Wallet*> future = QtConcurrent::run(this, &WalletManager::openWallet,
|
||||||
path, password, testnet);
|
path, password, testnet);
|
||||||
QFutureWatcher<Wallet*> * watcher = new QFutureWatcher<Wallet*>();
|
QFutureWatcher<Wallet*> * watcher = new QFutureWatcher<Wallet*>();
|
||||||
watcher->setFuture(future);
|
|
||||||
connect(watcher, &QFutureWatcher<Wallet*>::finished,
|
connect(watcher, &QFutureWatcher<Wallet*>::finished,
|
||||||
this, [this, watcher]() {
|
this, [this, watcher]() {
|
||||||
QFuture<Wallet*> future = watcher->future();
|
QFuture<Wallet*> future = watcher->future();
|
||||||
watcher->deleteLater();
|
watcher->deleteLater();
|
||||||
emit walletOpened(future.result());
|
emit walletOpened(future.result());
|
||||||
});
|
});
|
||||||
|
watcher->setFuture(future);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -121,7 +122,6 @@ void WalletManager::closeWalletAsync()
|
||||||
{
|
{
|
||||||
QFuture<QString> future = QtConcurrent::run(this, &WalletManager::closeWallet);
|
QFuture<QString> future = QtConcurrent::run(this, &WalletManager::closeWallet);
|
||||||
QFutureWatcher<QString> * watcher = new QFutureWatcher<QString>();
|
QFutureWatcher<QString> * watcher = new QFutureWatcher<QString>();
|
||||||
watcher->setFuture(future);
|
|
||||||
|
|
||||||
connect(watcher, &QFutureWatcher<QString>::finished,
|
connect(watcher, &QFutureWatcher<QString>::finished,
|
||||||
this, [this, watcher]() {
|
this, [this, watcher]() {
|
||||||
|
@ -129,6 +129,7 @@ void WalletManager::closeWalletAsync()
|
||||||
watcher->deleteLater();
|
watcher->deleteLater();
|
||||||
emit walletClosed(future.result());
|
emit walletClosed(future.result());
|
||||||
});
|
});
|
||||||
|
watcher->setFuture(future);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WalletManager::walletExists(const QString &path) const
|
bool WalletManager::walletExists(const QString &path) const
|
||||||
|
@ -256,6 +257,8 @@ double WalletManager::miningHashRate() const
|
||||||
|
|
||||||
bool WalletManager::isMining() const
|
bool WalletManager::isMining() const
|
||||||
{
|
{
|
||||||
|
if(!m_currentWallet->connected())
|
||||||
|
return false;
|
||||||
return m_pimpl->isMining();
|
return m_pimpl->isMining();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue