From 14dbe5d9deef238e9ecc400d06bd5b0594198a7c Mon Sep 17 00:00:00 2001 From: woodser Date: Sun, 28 Jul 2019 16:12:05 -0400 Subject: [PATCH] compiling; ready to impl MoneroTransfer copy() --- src/daemon/MoneroDaemonModel.cpp | 10 +++++++--- src/daemon/MoneroDaemonModel.h | 3 ++- src/wallet/MoneroWalletModel.cpp | 34 +++++++++++++++++++++++++++++--- src/wallet/MoneroWalletModel.h | 10 ++++++++-- 4 files changed, 48 insertions(+), 9 deletions(-) diff --git a/src/daemon/MoneroDaemonModel.cpp b/src/daemon/MoneroDaemonModel.cpp index e7c6ee6..fa40a9c 100644 --- a/src/daemon/MoneroDaemonModel.cpp +++ b/src/daemon/MoneroDaemonModel.cpp @@ -183,9 +183,9 @@ namespace monero { throw runtime_error("MoneroTx deep copy constructor not implemented"); } -// shared_ptr MoneroTx::copy() const { -// return MoneroTx(this); -// } + shared_ptr MoneroTx::copy() const { + return make_shared(); + } boost::property_tree::ptree MoneroTx::toPropertyTree() const { boost::property_tree::ptree node; @@ -386,6 +386,10 @@ namespace monero { throw runtime_error("MoneroOutput deep copy not implemented"); } + shared_ptr MoneroOutput::copy() const { + return make_shared(); + } + boost::property_tree::ptree MoneroOutput::toPropertyTree() const { boost::property_tree::ptree node; if (keyImage != boost::none) node.add_child("keyImage", (*keyImage)->toPropertyTree()); diff --git a/src/daemon/MoneroDaemonModel.h b/src/daemon/MoneroDaemonModel.h index 9d28363..bf9a794 100644 --- a/src/daemon/MoneroDaemonModel.h +++ b/src/daemon/MoneroDaemonModel.h @@ -194,7 +194,7 @@ namespace monero { MoneroTx(); // default constructor MoneroTx(const MoneroTx& tx); // deep copy constructor - //shared_ptr MoneroTx::copy() const; + shared_ptr copy() const; boost::property_tree::ptree toPropertyTree() const; virtual void merge(const shared_ptr& self, const shared_ptr& other); boost::optional getHeight() const; @@ -224,6 +224,7 @@ namespace monero { MoneroOutput(); MoneroOutput(const MoneroOutput& output); // deep copy constructor + shared_ptr copy() const; boost::property_tree::ptree toPropertyTree() const; virtual void merge(const shared_ptr& self, const shared_ptr& other); }; diff --git a/src/wallet/MoneroWalletModel.cpp b/src/wallet/MoneroWalletModel.cpp index 3c40415..04a9350 100644 --- a/src/wallet/MoneroWalletModel.cpp +++ b/src/wallet/MoneroWalletModel.cpp @@ -169,6 +169,10 @@ namespace monero { throw runtime_error("MoneroTxRequest deep copy constructor not implemented"); } + shared_ptr MoneroTxRequest::copy() const { + return make_shared(); + } + boost::property_tree::ptree MoneroTxRequest::toPropertyTree() const { boost::property_tree::ptree node = MoneroTxWallet::toPropertyTree(); if (isOutgoing != boost::none) node.put("isOutgoing", *isOutgoing); @@ -254,6 +258,10 @@ 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); @@ -296,6 +304,10 @@ namespace monero { throw runtime_error("MoneroIncomingTransfer deepy copy not implemented"); } + shared_ptr MoneroIncomingTransfer::copy() const { + return make_shared(); + } + boost::optional MoneroIncomingTransfer::getIsIncoming() const { return true; } boost::property_tree::ptree MoneroIncomingTransfer::toPropertyTree() const { @@ -326,6 +338,10 @@ namespace monero { throw runtime_error("MoneroOutgoingTransfer deep copy not implemented"); } + shared_ptr MoneroOutgoingTransfer::copy() const { + return make_shared(); + } + boost::optional MoneroOutgoingTransfer::getIsIncoming() const { return false; } boost::property_tree::ptree MoneroOutgoingTransfer::toPropertyTree() const { @@ -358,9 +374,9 @@ namespace monero { throw runtime_error("MoneroTransferRequet deep copy not implemented"); } -// shared_ptrMoneroTransferRequest::copy() const { -// -// } + shared_ptr MoneroTransferRequest::copy() const { + return make_shared(); + } boost::optional MoneroTransferRequest::getIsIncoming() const { return isIncoming; } @@ -458,6 +474,10 @@ namespace monero { throw runtime_error("MoneroOutputWallet deep copy constructor not implemented"); } + shared_ptr MoneroOutputWallet::copy() const { + return make_shared(); + } + boost::property_tree::ptree MoneroOutputWallet::toPropertyTree() const { boost::property_tree::ptree node = MoneroOutput::toPropertyTree(); if (accountIndex != boost::none) node.put("accountIndex", *accountIndex); @@ -482,6 +502,14 @@ namespace monero { } + MoneroOutputRequest::MoneroOutputRequest(const MoneroOutputRequest& request) { + throw runtime_error("MonerOutputRequest deep copy not implemented"); + } + + shared_ptr MoneroOutputRequest::copy() const { + return make_shared(); + } + boost::property_tree::ptree MoneroOutputRequest::toPropertyTree() const { boost::property_tree::ptree node = MoneroOutputWallet::toPropertyTree(); if (!subaddressIndices.empty()) node.add_child("subaddressIndices", MoneroUtils::toPropertyTree(subaddressIndices)); diff --git a/src/wallet/MoneroWalletModel.h b/src/wallet/MoneroWalletModel.h index b005910..9f01275 100644 --- a/src/wallet/MoneroWalletModel.h +++ b/src/wallet/MoneroWalletModel.h @@ -149,6 +149,7 @@ namespace monero { MoneroTransfer(); MoneroTransfer(const MoneroTransfer& transfer); // deep copy constructor + shared_ptr copy() const; virtual boost::optional getIsIncoming() const = 0; // derived class must implement boost::optional getIsOutgoing() const { if (getIsIncoming() == boost::none) return boost::none; @@ -167,6 +168,7 @@ namespace monero { MoneroIncomingTransfer(); MoneroIncomingTransfer(const MoneroIncomingTransfer& transfer); // deep copy constructor + shared_ptr copy() const; boost::optional getIsIncoming() const; boost::property_tree::ptree toPropertyTree() const; void merge(const shared_ptr& self, const shared_ptr& other); @@ -183,6 +185,7 @@ namespace monero { MoneroOutgoingTransfer(); MoneroOutgoingTransfer(const MoneroOutgoingTransfer& transfer); + shared_ptr copy() const; boost::optional getIsIncoming() const; boost::property_tree::ptree toPropertyTree() const; void merge(const shared_ptr& self, const shared_ptr& other); @@ -206,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; @@ -224,6 +227,7 @@ namespace monero { MoneroOutputWallet(); MoneroOutputWallet(const MoneroOutputWallet& output); // deep copy constructor + shared_ptr copy() const; boost::property_tree::ptree toPropertyTree() const; void merge(const shared_ptr& self, const shared_ptr& other); void merge(const shared_ptr& self, const shared_ptr& other); @@ -239,9 +243,9 @@ namespace monero { vector subaddressIndices; boost::optional> txRequest; - MoneroOutputRequest(); MoneroOutputRequest(const MoneroOutputRequest& request); // deep copy constructor + shared_ptr copy() const; boost::property_tree::ptree toPropertyTree() const; bool meetsCriteria(MoneroOutputWallet* output) const; }; @@ -256,6 +260,7 @@ namespace monero { MoneroTxWallet(); MoneroTxWallet(const MoneroTxWallet& tx); + shared_ptr copy() const; bool getIsIncoming() const; bool getIsOutgoing() const; boost::property_tree::ptree toPropertyTree() const; @@ -283,6 +288,7 @@ namespace monero { MoneroTxRequest(); MoneroTxRequest(const MoneroTxRequest& txRequest); + shared_ptr copy() const; boost::property_tree::ptree toPropertyTree() const; bool meetsCriteria(MoneroTxWallet* tx) const; };