diff options
| author | luigi1111 <luigi1111w@gmail.com> | 2018-09-12 18:18:36 -0500 |
|---|---|---|
| committer | luigi1111 <luigi1111w@gmail.com> | 2018-09-12 18:18:36 -0500 |
| commit | 3fd37b96a0acbbf54db62f8d84b392ae3e7b85f9 (patch) | |
| tree | 68f7eb2427287fd90d7054ab65c73a290dfaf3a0 /src | |
| parent | c46b5c82cd4bb10756fd3fc47cba491614160099 (diff) | |
| parent | 9bb6a25f311bccff3d089ae0b0a4156b16d6e109 (diff) | |
| download | monzero-gui-3fd37b96a0acbbf54db62f8d84b392ae3e7b85f9.tar.gz monzero-gui-3fd37b96a0acbbf54db62f8d84b392ae3e7b85f9.tar.xz monzero-gui-3fd37b96a0acbbf54db62f8d84b392ae3e7b85f9.zip | |
Merge pull request #1446
9bb6a25 Add support for creating hardware wallet (stoffu)
Diffstat (limited to 'src')
| -rw-r--r-- | src/libwalletqt/Wallet.cpp | 12 | ||||
| -rw-r--r-- | src/libwalletqt/Wallet.h | 4 | ||||
| -rw-r--r-- | src/libwalletqt/WalletManager.cpp | 14 | ||||
| -rw-r--r-- | src/libwalletqt/WalletManager.h | 6 |
4 files changed, 31 insertions, 5 deletions
diff --git a/src/libwalletqt/Wallet.cpp b/src/libwalletqt/Wallet.cpp index 0047f8dd..2c6e92c9 100644 --- a/src/libwalletqt/Wallet.cpp +++ b/src/libwalletqt/Wallet.cpp @@ -172,12 +172,18 @@ bool Wallet::store(const QString &path) return m_walletImpl->store(path.toStdString()); } -bool Wallet::init(const QString &daemonAddress, quint64 upperTransactionLimit, bool isRecovering, quint64 restoreHeight) +bool Wallet::init(const QString &daemonAddress, quint64 upperTransactionLimit, bool isRecovering, bool isRecoveringFromDevice, quint64 restoreHeight) { qDebug() << "init non async"; if (isRecovering){ qDebug() << "RESTORING"; m_walletImpl->setRecoveringFromSeed(true); + } + if (isRecoveringFromDevice){ + qDebug() << "RESTORING FROM DEVICE"; + m_walletImpl->setRecoveringFromDevice(true); + } + if (isRecovering || isRecoveringFromDevice) { m_walletImpl->setRefreshFromBlockHeight(restoreHeight); } m_walletImpl->init(daemonAddress.toStdString(), upperTransactionLimit, m_daemonUsername.toStdString(), m_daemonPassword.toStdString()); @@ -191,7 +197,7 @@ void Wallet::setDaemonLogin(const QString &daemonUsername, const QString &daemon m_daemonPassword = daemonPassword; } -void Wallet::initAsync(const QString &daemonAddress, quint64 upperTransactionLimit, bool isRecovering, quint64 restoreHeight) +void Wallet::initAsync(const QString &daemonAddress, quint64 upperTransactionLimit, bool isRecovering, bool isRecoveringFromDevice, quint64 restoreHeight) { qDebug() << "initAsync: " + daemonAddress; // Change status to disconnected if connected @@ -201,7 +207,7 @@ void Wallet::initAsync(const QString &daemonAddress, quint64 upperTransactionLim } QFuture<bool> future = QtConcurrent::run(this, &Wallet::init, - daemonAddress, upperTransactionLimit, isRecovering, restoreHeight); + daemonAddress, upperTransactionLimit, isRecovering, isRecoveringFromDevice, restoreHeight); QFutureWatcher<bool> * watcher = new QFutureWatcher<bool>(); connect(watcher, &QFutureWatcher<bool>::finished, diff --git a/src/libwalletqt/Wallet.h b/src/libwalletqt/Wallet.h index df413363..d0f053ac 100644 --- a/src/libwalletqt/Wallet.h +++ b/src/libwalletqt/Wallet.h @@ -111,10 +111,10 @@ public: Q_INVOKABLE bool store(const QString &path = ""); //! initializes wallet - Q_INVOKABLE bool init(const QString &daemonAddress, quint64 upperTransactionLimit = 0, bool isRecovering = false, quint64 restoreHeight = 0); + Q_INVOKABLE bool init(const QString &daemonAddress, quint64 upperTransactionLimit = 0, bool isRecovering = false, bool isRecoveringFromDevice = false, quint64 restoreHeight = 0); //! initializes wallet asynchronously - Q_INVOKABLE void initAsync(const QString &daemonAddress, quint64 upperTransactionLimit = 0, bool isRecovering = false, quint64 restoreHeight = 0); + Q_INVOKABLE void initAsync(const QString &daemonAddress, quint64 upperTransactionLimit = 0, bool isRecovering = false, bool isRecoveringFromDevice = false, quint64 restoreHeight = 0); // Set daemon rpc user/pass Q_INVOKABLE void setDaemonLogin(const QString &daemonUsername = "", const QString &daemonPassword = ""); diff --git a/src/libwalletqt/WalletManager.cpp b/src/libwalletqt/WalletManager.cpp index f6eb771a..355527ad 100644 --- a/src/libwalletqt/WalletManager.cpp +++ b/src/libwalletqt/WalletManager.cpp @@ -104,6 +104,20 @@ Wallet *WalletManager::createWalletFromKeys(const QString &path, const QString & return m_currentWallet; } +Wallet *WalletManager::createWalletFromDevice(const QString &path, const QString &password, NetworkType::Type nettype, + const QString &deviceName, quint64 restoreHeight, const QString &subaddressLookahead) +{ + QMutexLocker locker(&m_mutex); + if (m_currentWallet) { + qDebug() << "Closing open m_currentWallet" << m_currentWallet; + delete m_currentWallet; + m_currentWallet = NULL; + } + Monero::Wallet * w = m_pimpl->createWalletFromDevice(path.toStdString(), password.toStdString(), static_cast<Monero::NetworkType>(nettype), + deviceName.toStdString(), restoreHeight, subaddressLookahead.toStdString()); + m_currentWallet = new Wallet(w); + return m_currentWallet; +} QString WalletManager::closeWallet() { diff --git a/src/libwalletqt/WalletManager.h b/src/libwalletqt/WalletManager.h index dd44c634..75626928 100644 --- a/src/libwalletqt/WalletManager.h +++ b/src/libwalletqt/WalletManager.h @@ -62,6 +62,12 @@ public: const QString &spendkey = "", quint64 restoreHeight = 0); + Q_INVOKABLE Wallet * createWalletFromDevice(const QString &path, + const QString &password, + NetworkType::Type nettype, + const QString &deviceName, + quint64 restoreHeight = 0, + const QString &subaddressLookahead = ""); /*! * \brief closeWallet - closes current open wallet and frees memory * \return wallet address |
