diff --git a/src/wallet/MoneroWalletModel.cpp b/src/wallet/MoneroWalletModel.cpp index 04a9350..23556e3 100644 --- a/src/wallet/MoneroWalletModel.cpp +++ b/src/wallet/MoneroWalletModel.cpp @@ -258,10 +258,6 @@ namespace monero { throw runtime_error("MoneroTransfer deep copy constructor not implemented"); } - shared_ptr MoneroTransfer::copy() const { - //return make_shared(); // TODO: MoneroTransfer is abstract - } - boost::property_tree::ptree MoneroTransfer::toPropertyTree() const { boost::property_tree::ptree node; if (amount != boost::none) node.put("amount", *amount); @@ -304,8 +300,8 @@ namespace monero { throw runtime_error("MoneroIncomingTransfer deepy copy not implemented"); } - shared_ptr MoneroIncomingTransfer::copy() const { - return make_shared(); + shared_ptr MoneroIncomingTransfer::copy() const { + return make_shared(*this); } boost::optional MoneroIncomingTransfer::getIsIncoming() const { return true; } @@ -338,8 +334,8 @@ namespace monero { throw runtime_error("MoneroOutgoingTransfer deep copy not implemented"); } - shared_ptr MoneroOutgoingTransfer::copy() const { - return make_shared(); + shared_ptr MoneroOutgoingTransfer::copy() const { + return make_shared(*this); } boost::optional MoneroOutgoingTransfer::getIsIncoming() const { return false; } @@ -374,8 +370,8 @@ namespace monero { throw runtime_error("MoneroTransferRequet deep copy not implemented"); } - shared_ptr MoneroTransferRequest::copy() const { - return make_shared(); + shared_ptr MoneroTransferRequest::copy() const { + return make_shared(*this); } boost::optional MoneroTransferRequest::getIsIncoming() const { return isIncoming; } @@ -394,7 +390,7 @@ namespace monero { bool MoneroTransferRequest::meetsCriteria(MoneroTransfer* transfer) const { if (transfer == nullptr) throw runtime_error("transfer is null"); - if (txRequest != boost::none && (*txRequest)->transferRequest != boost::none) throw runtime_error("Transfer request's tx request cannot have a circular transfer request"); // TODO: could auto detect and handl this. port to java/js + if (txRequest != boost::none && (*txRequest)->transferRequest != boost::none) throw runtime_error("Transfer request's tx request cannot have a circular transfer request"); // TODO: could auto detect and handle this. port to java/js // filter on common fields if (getIsIncoming() != boost::none && *getIsIncoming() != *transfer->getIsIncoming()) return false; diff --git a/src/wallet/MoneroWalletModel.h b/src/wallet/MoneroWalletModel.h index 9f01275..01b569b 100644 --- a/src/wallet/MoneroWalletModel.h +++ b/src/wallet/MoneroWalletModel.h @@ -149,14 +149,14 @@ namespace monero { MoneroTransfer(); MoneroTransfer(const MoneroTransfer& transfer); // deep copy constructor - shared_ptr copy() const; + virtual shared_ptr copy() const = 0; // derived class must implement virtual boost::optional getIsIncoming() const = 0; // derived class must implement boost::optional getIsOutgoing() const { if (getIsIncoming() == boost::none) return boost::none; return !(*getIsIncoming()); } boost::property_tree::ptree toPropertyTree() const; - virtual void merge(const shared_ptr& self, const shared_ptr& other); + void merge(const shared_ptr& self, const shared_ptr& other); }; /** @@ -168,7 +168,7 @@ namespace monero { MoneroIncomingTransfer(); MoneroIncomingTransfer(const MoneroIncomingTransfer& transfer); // deep copy constructor - shared_ptr copy() const; + shared_ptr copy() const; boost::optional getIsIncoming() const; boost::property_tree::ptree toPropertyTree() const; void merge(const shared_ptr& self, const shared_ptr& other); @@ -185,7 +185,7 @@ namespace monero { MoneroOutgoingTransfer(); MoneroOutgoingTransfer(const MoneroOutgoingTransfer& transfer); - shared_ptr copy() const; + shared_ptr copy() const; boost::optional getIsIncoming() const; boost::property_tree::ptree toPropertyTree() const; void merge(const shared_ptr& self, const shared_ptr& other); @@ -209,7 +209,7 @@ namespace monero { MoneroTransferRequest(); MoneroTransferRequest(const MoneroTransferRequest& request); - shared_ptr copy() const; + shared_ptr copy() const; boost::optional getIsIncoming() const; boost::property_tree::ptree toPropertyTree() const; bool meetsCriteria(MoneroTransfer* transfer) const;