diff --git a/src/wallet/MoneroWallet.cpp b/src/wallet/MoneroWallet.cpp index e3ceb1a..7c4dc90 100644 --- a/src/wallet/MoneroWallet.cpp +++ b/src/wallet/MoneroWallet.cpp @@ -492,14 +492,15 @@ namespace monero { wallet2->set_daemon(uri, login, isTrusted); } - MoneroRpcConnection MoneroWallet::getDaemonConnection() const { - MoneroRpcConnection connection; - if (!wallet2->get_daemon_address().empty()) connection.uri = wallet2->get_daemon_address(); + shared_ptr MoneroWallet::getDaemonConnection() const { + if (wallet2->get_daemon_address().empty()) return nullptr; + shared_ptr connection = shared_ptr(new MoneroRpcConnection()); + if (!wallet2->get_daemon_address().empty()) connection->uri = wallet2->get_daemon_address(); if (wallet2->get_daemon_login()) { - if (!wallet2->get_daemon_login()->username.empty()) connection.username = wallet2->get_daemon_login()->username; + if (!wallet2->get_daemon_login()->username.empty()) connection->username = wallet2->get_daemon_login()->username; epee::wipeable_string wipeablePassword = wallet2->get_daemon_login()->password; string password = string(wipeablePassword.data(), wipeablePassword.size()); - if (!password.empty()) connection.password = password; + if (!password.empty()) connection->password = password; } return connection; } @@ -640,8 +641,9 @@ namespace monero { uint64_t MoneroWallet::getChainHeight() const { string err; + if (getDaemonConnection() == nullptr) throw runtime_error("No connection to daemon"); uint64_t chainHeight = wallet2->get_daemon_blockchain_height(err); - if (!err.empty()) throw runtime_error(err); // TODO: proper monero error + if (!err.empty()) throw runtime_error(err); return chainHeight; } diff --git a/src/wallet/MoneroWallet.h b/src/wallet/MoneroWallet.h index fc375bc..bdfae00 100644 --- a/src/wallet/MoneroWallet.h +++ b/src/wallet/MoneroWallet.h @@ -168,7 +168,7 @@ namespace monero { /** * TODO */ - MoneroRpcConnection getDaemonConnection() const; + shared_ptr getDaemonConnection() const; /** * TODO diff --git a/todo.txt b/todo.txt index 5c46e41..4bd2b97 100644 --- a/todo.txt +++ b/todo.txt @@ -1,3 +1,4 @@ +throw MoneroErrors instead of runtime_errors toPropertyTree() should take node as parameter; optimize memory elsewhere cannot reconcile integrals on getTransfers() test, need to add reconcile debug info including vals and pass error message re-usable debug trace statements