diff options
author | Jaquee <jaquee.monero@gmail.com> | 2017-08-04 23:31:33 +0200 |
---|---|---|
committer | Jaquee <jaquee.monero@gmail.com> | 2017-10-15 17:57:43 +0200 |
commit | fc9229342dfe56655415c190b84cec267d041540 (patch) | |
tree | 4afb2ee9adb7895e5b34efd0b60568c39c356618 | |
parent | walletAPI: init() lightwallet and SSL support (diff) | |
download | monero-fc9229342dfe56655415c190b84cec267d041540.tar.xz |
walletAPI: add lightwallet login() and importWalletRequest()
-rw-r--r-- | src/wallet/api/wallet.cpp | 32 | ||||
-rw-r--r-- | src/wallet/api/wallet.h | 2 | ||||
-rw-r--r-- | src/wallet/wallet2_api.h | 6 |
3 files changed, 40 insertions, 0 deletions
diff --git a/src/wallet/api/wallet.cpp b/src/wallet/api/wallet.cpp index 9a9625c15..5e6972a92 100644 --- a/src/wallet/api/wallet.cpp +++ b/src/wallet/api/wallet.cpp @@ -712,6 +712,38 @@ bool WalletImpl::init(const std::string &daemon_address, uint64_t upper_transact return doInit(daemon_address, upper_transaction_size_limit, use_ssl); } +bool WalletImpl::lightWalletLogin(bool &isNewWallet) const +{ + return m_wallet->light_wallet_login(isNewWallet); +} + +bool WalletImpl::lightWalletImportWalletRequest(std::string &payment_id, uint64_t &fee, bool &new_request, bool &request_fulfilled, std::string &payment_address, std::string &status) +{ + try + { + cryptonote::COMMAND_RPC_IMPORT_WALLET_REQUEST::response response; + if(!m_wallet->light_wallet_import_wallet_request(response)){ + m_errorString = tr("Failed to send import wallet request"); + m_status = Status_Error; + return false; + } + fee = response.import_fee; + payment_id = response.payment_id; + new_request = response.new_request; + request_fulfilled = response.request_fulfilled; + payment_address = response.payment_address; + status = response.status; + } + catch (const std::exception &e) + { + LOG_ERROR("Error sending import wallet request: " << e.what()); + m_errorString = e.what(); + m_status = Status_Error; + return false; + } + return true; +} + void WalletImpl::setRefreshFromBlockHeight(uint64_t refresh_from_block_height) { m_wallet->set_refresh_from_block_height(refresh_from_block_height); diff --git a/src/wallet/api/wallet.h b/src/wallet/api/wallet.h index 30af9550e..ecb218ea0 100644 --- a/src/wallet/api/wallet.h +++ b/src/wallet/api/wallet.h @@ -143,6 +143,8 @@ public: virtual void pauseRefresh(); virtual bool parse_uri(const std::string &uri, std::string &address, std::string &payment_id, uint64_t &amount, std::string &tx_description, std::string &recipient_name, std::vector<std::string> &unknown_parameters, std::string &error); virtual std::string getDefaultDataDir() const; + virtual bool lightWalletLogin(bool &isNewWallet) const; + virtual bool lightWalletImportWalletRequest(std::string &payment_id, uint64_t &fee, bool &new_request, bool &request_fulfilled, std::string &payment_address, std::string &status); private: void clearStatus() const; diff --git a/src/wallet/wallet2_api.h b/src/wallet/wallet2_api.h index be17c7506..4d734ab94 100644 --- a/src/wallet/wallet2_api.h +++ b/src/wallet/wallet2_api.h @@ -725,6 +725,12 @@ struct Wallet * \return true on success */ virtual bool rescanSpent() = 0; + + //! Light wallet authenticate and login + virtual bool lightWalletLogin(bool &isNewWallet) const = 0; + + //! Initiates a light wallet import wallet request + virtual bool lightWalletImportWalletRequest(std::string &payment_id, uint64_t &fee, bool &new_request, bool &request_fulfilled, std::string &payment_address, std::string &status) = 0; }; /** |