diff --git a/src/wallet/monero_wallet.h b/src/wallet/monero_wallet.h index 3970008..e0f8cef 100644 --- a/src/wallet/monero_wallet.h +++ b/src/wallet/monero_wallet.h @@ -129,6 +129,16 @@ namespace monero { */ virtual ~monero_wallet() {} + /** + * Indicates if the wallet is watch-only, meaning it does have the private + * spend key and can therefore only observe incoming outputs. + * + * @return true if the wallet is watch-only, false otherwise + */ + virtual bool is_watch_only() const { + throw runtime_error("is_watch_only() not supported"); + } + /** * Set the wallet's daemon connection. * diff --git a/src/wallet/monero_wallet_core.h b/src/wallet/monero_wallet_core.h index e8252e0..f948cce 100644 --- a/src/wallet/monero_wallet_core.h +++ b/src/wallet/monero_wallet_core.h @@ -173,6 +173,7 @@ namespace monero { /** * Supported wallet methods. */ + bool is_watch_only() const { return m_w2->watch_only(); } void set_daemon_connection(const string& uri, const string& username = "", const string& password = ""); void set_daemon_connection(const boost::optional& connection); boost::optional get_daemon_connection() const; diff --git a/src/wallet/monero_wallet_keys.cpp b/src/wallet/monero_wallet_keys.cpp index 3b1a720..fa4afbe 100644 --- a/src/wallet/monero_wallet_keys.cpp +++ b/src/wallet/monero_wallet_keys.cpp @@ -178,6 +178,7 @@ namespace monero { } // initialize remaining wallet + wallet->m_is_watch_only = !has_spend_key; wallet->m_network_type = network_type; if (!spend_key.empty()) { wallet->m_language = language; diff --git a/src/wallet/monero_wallet_keys.h b/src/wallet/monero_wallet_keys.h index b3484e6..053dc1f 100644 --- a/src/wallet/monero_wallet_keys.h +++ b/src/wallet/monero_wallet_keys.h @@ -116,6 +116,7 @@ namespace monero { /** * Supported wallet methods. */ + bool is_watch_only() const { return m_is_watch_only; } monero_version get_version() const; monero_network_type get_network_type() const { return m_network_type; } string get_mnemonic() const { return m_mnemonic; } @@ -137,6 +138,7 @@ namespace monero { // --------------------------------- PRIVATE -------------------------------- private: + bool m_is_watch_only; monero_network_type m_network_type; cryptonote::account_base m_account; string m_mnemonic;