diff options
Diffstat (limited to 'src/wallet/api/wallet2_api.h')
-rw-r--r-- | src/wallet/api/wallet2_api.h | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/src/wallet/api/wallet2_api.h b/src/wallet/api/wallet2_api.h index ee1d6ae79..0af3b1867 100644 --- a/src/wallet/api/wallet2_api.h +++ b/src/wallet/api/wallet2_api.h @@ -37,6 +37,7 @@ #include <set> #include <ctime> #include <iostream> +#include <stdexcept> // Public interface for libwallet library namespace Monero { @@ -337,6 +338,7 @@ protected: bool m_indeterminate; }; +struct Wallet; struct WalletListener { virtual ~WalletListener() = 0; @@ -381,7 +383,12 @@ struct WalletListener /** * @brief called by device if the action is required */ - virtual void onDeviceButtonRequest(uint64_t code) {} + virtual void onDeviceButtonRequest(uint64_t code) { (void)code; } + + /** + * @brief called by device if the button was pressed + */ + virtual void onDeviceButtonPressed() { } /** * @brief called by device when PIN is needed @@ -401,7 +408,12 @@ struct WalletListener /** * @brief Signalizes device operation progress */ - virtual void onDeviceProgress(const DeviceProgress & event) {}; + virtual void onDeviceProgress(const DeviceProgress & event) { (void)event; }; + + /** + * @brief If the listener is created before the wallet this enables to set created wallet object + */ + virtual void onSetWallet(Wallet * wallet) { (void)wallet; }; }; @@ -440,8 +452,8 @@ struct Wallet //! returns both error and error string atomically. suggested to use in instead of status() and errorString() virtual void statusWithErrorString(int& status, std::string& errorString) const = 0; virtual bool setPassword(const std::string &password) = 0; - virtual bool setDevicePin(const std::string &password) { return false; }; - virtual bool setDevicePassphrase(const std::string &password) { return false; }; + virtual bool setDevicePin(const std::string &pin) { (void)pin; return false; }; + virtual bool setDevicePassphrase(const std::string &passphrase) { (void)passphrase; return false; }; virtual std::string address(uint32_t accountIndex = 0, uint32_t addressIndex = 0) const = 0; std::string mainAddress() const { return address(0, 0); } virtual std::string path() const = 0; @@ -1020,9 +1032,10 @@ struct WalletManager * \param password Password of wallet file * \param nettype Network type * \param kdf_rounds Number of rounds for key derivation function + * \param listener Wallet listener to set to the wallet after creation * \return Wallet instance (Wallet::status() needs to be called to check if opened successfully) */ - virtual Wallet * openWallet(const std::string &path, const std::string &password, NetworkType nettype, uint64_t kdf_rounds = 1) = 0; + virtual Wallet * openWallet(const std::string &path, const std::string &password, NetworkType nettype, uint64_t kdf_rounds = 1, WalletListener * listener = nullptr) = 0; Wallet * openWallet(const std::string &path, const std::string &password, bool testnet = false) // deprecated { return openWallet(path, password, testnet ? TESTNET : MAINNET); @@ -1134,6 +1147,7 @@ struct WalletManager * \param restoreHeight restore from start height (0 sets to current height) * \param subaddressLookahead Size of subaddress lookahead (empty sets to some default low value) * \param kdf_rounds Number of rounds for key derivation function + * \param listener Wallet listener to set to the wallet after creation * \return Wallet instance (Wallet::status() needs to be called to check if recovered successfully) */ virtual Wallet * createWalletFromDevice(const std::string &path, @@ -1142,7 +1156,8 @@ struct WalletManager const std::string &deviceName, uint64_t restoreHeight = 0, const std::string &subaddressLookahead = "", - uint64_t kdf_rounds = 1) = 0; + uint64_t kdf_rounds = 1, + WalletListener * listener = nullptr) = 0; /*! * \brief Closes wallet. In case operation succeeded, wallet object deleted. in case operation failed, wallet object not deleted |