mirror of
https://github.com/wownero/wownero-cpp.git
synced 2026-10-21 17:18:44 +02:00
define deep copy constructors for tx, output, transfers and descendants
This commit is contained in:
@@ -175,6 +175,18 @@ namespace monero {
|
||||
|
||||
// ------------------------------- MONERO TX --------------------------------
|
||||
|
||||
MoneroTx::MoneroTx() {
|
||||
|
||||
}
|
||||
|
||||
MoneroTx::MoneroTx(const MoneroTx& tx) {
|
||||
throw runtime_error("MoneroTx deep copy constructor not implemented");
|
||||
}
|
||||
|
||||
// shared_ptr<MoneroTx> MoneroTx::copy() const {
|
||||
// return MoneroTx(this);
|
||||
// }
|
||||
|
||||
boost::property_tree::ptree MoneroTx::toPropertyTree() const {
|
||||
boost::property_tree::ptree node;
|
||||
if (id != boost::none) node.put("id", *id);
|
||||
@@ -366,6 +378,14 @@ namespace monero {
|
||||
|
||||
// ------------------------------ MONERO OUTPUT -----------------------------
|
||||
|
||||
MoneroOutput::MoneroOutput() {
|
||||
|
||||
}
|
||||
|
||||
MoneroOutput::MoneroOutput(const MoneroOutput& output) {
|
||||
throw runtime_error("MoneroOutput deep copy not implemented");
|
||||
}
|
||||
|
||||
boost::property_tree::ptree MoneroOutput::toPropertyTree() const {
|
||||
boost::property_tree::ptree node;
|
||||
if (keyImage != boost::none) node.add_child("keyImage", (*keyImage)->toPropertyTree());
|
||||
|
||||
@@ -192,9 +192,12 @@ namespace monero {
|
||||
boost::optional<string> maxUsedBlockId;
|
||||
vector<string> signatures;
|
||||
|
||||
MoneroTx(); // default constructor
|
||||
MoneroTx(const MoneroTx& tx); // deep copy constructor
|
||||
//shared_ptr<MoneroTx> MoneroTx::copy() const;
|
||||
boost::property_tree::ptree toPropertyTree() const;
|
||||
boost::optional<uint64_t> getHeight() const;
|
||||
virtual void merge(const shared_ptr<MoneroTx>& self, const shared_ptr<MoneroTx>& other);
|
||||
boost::optional<uint64_t> getHeight() const;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -219,6 +222,8 @@ namespace monero {
|
||||
vector<uint32_t> ringOutputIndices;
|
||||
boost::optional<string> stealthPublicKey;
|
||||
|
||||
MoneroOutput();
|
||||
MoneroOutput(const MoneroOutput& output); // deep copy constructor
|
||||
boost::property_tree::ptree toPropertyTree() const;
|
||||
virtual void merge(const shared_ptr<MoneroOutput>& self, const shared_ptr<MoneroOutput>& other);
|
||||
};
|
||||
|
||||
@@ -1271,9 +1271,14 @@ namespace monero {
|
||||
return getTxs(request);
|
||||
}
|
||||
|
||||
vector<shared_ptr<MoneroTxWallet>> MoneroWallet::getTxs(MoneroTxRequest& request) const {
|
||||
// TODO: change param to for real
|
||||
vector<shared_ptr<MoneroTxWallet>> MoneroWallet::getTxs(const MoneroTxRequest& requestParam) const {
|
||||
MTRACE("getTxs(request)");
|
||||
|
||||
// preserve original request
|
||||
//MoneroTxRequest& request = request.copy().get();
|
||||
MoneroTxRequest request = requestParam;
|
||||
|
||||
// print request
|
||||
if (request.block != boost::none) MTRACE("Tx request's rooted at [block]: " << request.block.get()->serialize());
|
||||
else MTRACE("Tx request: " << request.serialize());
|
||||
|
||||
@@ -644,7 +644,7 @@ namespace monero {
|
||||
* @param request filters query results (optional)
|
||||
* @return wallet transactions per the request
|
||||
*/
|
||||
vector<shared_ptr<MoneroTxWallet>> getTxs(MoneroTxRequest& request) const;
|
||||
vector<shared_ptr<MoneroTxWallet>> getTxs(const MoneroTxRequest& request) const;
|
||||
|
||||
// /**
|
||||
// * Get all incoming and outgoing transfers to and from this wallet. An
|
||||
|
||||
@@ -105,6 +105,14 @@ namespace monero {
|
||||
|
||||
// --------------------------- MONERO TX WALLET -----------------------------
|
||||
|
||||
MoneroTxWallet::MoneroTxWallet() {
|
||||
|
||||
}
|
||||
|
||||
MoneroTxWallet::MoneroTxWallet(const MoneroTxWallet& tx) {
|
||||
throw runtime_error("MoneroTxWallet deepy copy constructor not implemented");
|
||||
}
|
||||
|
||||
boost::property_tree::ptree MoneroTxWallet::toPropertyTree() const {
|
||||
boost::property_tree::ptree node = MoneroTx::toPropertyTree();
|
||||
if (!incomingTransfers.empty()) node.add_child("incomingTransfers", MoneroUtils::toPropertyTree(incomingTransfers));
|
||||
@@ -153,6 +161,14 @@ namespace monero {
|
||||
|
||||
// -------------------------- MONERO TX REQUEST -----------------------------
|
||||
|
||||
MoneroTxRequest::MoneroTxRequest() {
|
||||
|
||||
}
|
||||
|
||||
MoneroTxRequest::MoneroTxRequest(const MoneroTxRequest& txRequest) {
|
||||
throw runtime_error("MoneroTxRequest deep copy constructor not implemented");
|
||||
}
|
||||
|
||||
boost::property_tree::ptree MoneroTxRequest::toPropertyTree() const {
|
||||
boost::property_tree::ptree node = MoneroTxWallet::toPropertyTree();
|
||||
if (isOutgoing != boost::none) node.put("isOutgoing", *isOutgoing);
|
||||
@@ -230,6 +246,14 @@ namespace monero {
|
||||
|
||||
// ---------------------------- MONERO TRANSFER -----------------------------
|
||||
|
||||
MoneroTransfer::MoneroTransfer() {
|
||||
|
||||
}
|
||||
|
||||
MoneroTransfer::MoneroTransfer(const MoneroTransfer& transfer) {
|
||||
throw runtime_error("MoneroTransfer deep copy constructor not implemented");
|
||||
}
|
||||
|
||||
boost::property_tree::ptree MoneroTransfer::toPropertyTree() const {
|
||||
boost::property_tree::ptree node;
|
||||
if (amount != boost::none) node.put("amount", *amount);
|
||||
@@ -264,6 +288,14 @@ namespace monero {
|
||||
|
||||
// ----------------------- MONERO INCOMING TRANSFER -------------------------
|
||||
|
||||
MoneroIncomingTransfer::MoneroIncomingTransfer() {
|
||||
|
||||
}
|
||||
|
||||
MoneroIncomingTransfer::MoneroIncomingTransfer(const MoneroIncomingTransfer& transfer) {
|
||||
throw runtime_error("MoneroIncomingTransfer deepy copy not implemented");
|
||||
}
|
||||
|
||||
boost::optional<bool> MoneroIncomingTransfer::getIsIncoming() const { return true; }
|
||||
|
||||
boost::property_tree::ptree MoneroIncomingTransfer::toPropertyTree() const {
|
||||
@@ -286,6 +318,14 @@ namespace monero {
|
||||
|
||||
// ----------------------- MONERO OUTGOING TRANSFER -------------------------
|
||||
|
||||
MoneroOutgoingTransfer::MoneroOutgoingTransfer() {
|
||||
|
||||
}
|
||||
|
||||
MoneroOutgoingTransfer::MoneroOutgoingTransfer(const MoneroOutgoingTransfer& transfer) {
|
||||
throw runtime_error("MoneroOutgoingTransfer deep copy not implemented");
|
||||
}
|
||||
|
||||
boost::optional<bool> MoneroOutgoingTransfer::getIsIncoming() const { return false; }
|
||||
|
||||
boost::property_tree::ptree MoneroOutgoingTransfer::toPropertyTree() const {
|
||||
@@ -310,6 +350,18 @@ namespace monero {
|
||||
|
||||
// ----------------------- MONERO TRANSFER REQUEST --------------------------
|
||||
|
||||
MoneroTransferRequest::MoneroTransferRequest() {
|
||||
|
||||
}
|
||||
|
||||
MoneroTransferRequest::MoneroTransferRequest(const MoneroTransferRequest& request) {
|
||||
throw runtime_error("MoneroTransferRequet deep copy not implemented");
|
||||
}
|
||||
|
||||
// shared_ptr<MoneroTransfer>MoneroTransferRequest::copy() const {
|
||||
//
|
||||
// }
|
||||
|
||||
boost::optional<bool> MoneroTransferRequest::getIsIncoming() const { return isIncoming; }
|
||||
|
||||
boost::property_tree::ptree MoneroTransferRequest::toPropertyTree() const {
|
||||
@@ -398,6 +450,14 @@ namespace monero {
|
||||
|
||||
// ------------------------- MONERO OUTPUT WALLET ---------------------------
|
||||
|
||||
MoneroOutputWallet::MoneroOutputWallet() {
|
||||
|
||||
}
|
||||
|
||||
MoneroOutputWallet::MoneroOutputWallet(const MoneroOutputWallet& output) {
|
||||
throw runtime_error("MoneroOutputWallet deep copy constructor not implemented");
|
||||
}
|
||||
|
||||
boost::property_tree::ptree MoneroOutputWallet::toPropertyTree() const {
|
||||
boost::property_tree::ptree node = MoneroOutput::toPropertyTree();
|
||||
if (accountIndex != boost::none) node.put("accountIndex", *accountIndex);
|
||||
@@ -418,6 +478,10 @@ namespace monero {
|
||||
|
||||
// ------------------------ MONERO OUTPUT REQUEST ---------------------------
|
||||
|
||||
MoneroOutputRequest::MoneroOutputRequest() {
|
||||
|
||||
}
|
||||
|
||||
boost::property_tree::ptree MoneroOutputRequest::toPropertyTree() const {
|
||||
boost::property_tree::ptree node = MoneroOutputWallet::toPropertyTree();
|
||||
if (!subaddressIndices.empty()) node.add_child("subaddressIndices", MoneroUtils::toPropertyTree(subaddressIndices));
|
||||
|
||||
@@ -147,6 +147,8 @@ namespace monero {
|
||||
boost::optional<uint32_t> accountIndex;
|
||||
boost::optional<uint32_t> numSuggestedConfirmations;
|
||||
|
||||
MoneroTransfer();
|
||||
MoneroTransfer(const MoneroTransfer& transfer); // deep copy constructor
|
||||
virtual boost::optional<bool> getIsIncoming() const = 0; // derived class must implement
|
||||
boost::optional<bool> getIsOutgoing() const {
|
||||
if (getIsIncoming() == boost::none) return boost::none;
|
||||
@@ -163,6 +165,8 @@ namespace monero {
|
||||
boost::optional<uint32_t> subaddressIndex;
|
||||
boost::optional<string> address;
|
||||
|
||||
MoneroIncomingTransfer();
|
||||
MoneroIncomingTransfer(const MoneroIncomingTransfer& transfer); // deep copy constructor
|
||||
boost::optional<bool> getIsIncoming() const;
|
||||
boost::property_tree::ptree toPropertyTree() const;
|
||||
void merge(const shared_ptr<MoneroTransfer>& self, const shared_ptr<MoneroTransfer>& other);
|
||||
@@ -177,6 +181,8 @@ namespace monero {
|
||||
vector<string> addresses;
|
||||
vector<shared_ptr<MoneroDestination>> destinations;
|
||||
|
||||
MoneroOutgoingTransfer();
|
||||
MoneroOutgoingTransfer(const MoneroOutgoingTransfer& transfer);
|
||||
boost::optional<bool> getIsIncoming() const;
|
||||
boost::property_tree::ptree toPropertyTree() const;
|
||||
void merge(const shared_ptr<MoneroTransfer>& self, const shared_ptr<MoneroTransfer>& other);
|
||||
@@ -198,6 +204,9 @@ namespace monero {
|
||||
boost::optional<bool> hasDestinations;
|
||||
boost::optional<shared_ptr<MoneroTxRequest>> txRequest;
|
||||
|
||||
MoneroTransferRequest();
|
||||
MoneroTransferRequest(const MoneroTransferRequest& request);
|
||||
//shared_ptr<MoneroTransferRequest> copy() const;
|
||||
boost::optional<bool> getIsIncoming() const;
|
||||
boost::property_tree::ptree toPropertyTree() const;
|
||||
bool meetsCriteria(MoneroTransfer* transfer) const;
|
||||
@@ -213,6 +222,8 @@ namespace monero {
|
||||
boost::optional<bool> isUnlocked;
|
||||
boost::optional<bool> isFrozen;
|
||||
|
||||
MoneroOutputWallet();
|
||||
MoneroOutputWallet(const MoneroOutputWallet& output); // deep copy constructor
|
||||
boost::property_tree::ptree toPropertyTree() const;
|
||||
void merge(const shared_ptr<MoneroOutput>& self, const shared_ptr<MoneroOutput>& other);
|
||||
void merge(const shared_ptr<MoneroOutputWallet>& self, const shared_ptr<MoneroOutputWallet>& other);
|
||||
@@ -228,6 +239,9 @@ namespace monero {
|
||||
vector<uint32_t> subaddressIndices;
|
||||
boost::optional<shared_ptr<MoneroTxRequest>> txRequest;
|
||||
|
||||
|
||||
MoneroOutputRequest();
|
||||
MoneroOutputRequest(const MoneroOutputRequest& request); // deep copy constructor
|
||||
boost::property_tree::ptree toPropertyTree() const;
|
||||
bool meetsCriteria(MoneroOutputWallet* output) const;
|
||||
};
|
||||
@@ -240,6 +254,8 @@ namespace monero {
|
||||
boost::optional<shared_ptr<MoneroOutgoingTransfer>> outgoingTransfer;
|
||||
boost::optional<string> note;
|
||||
|
||||
MoneroTxWallet();
|
||||
MoneroTxWallet(const MoneroTxWallet& tx);
|
||||
bool getIsIncoming() const;
|
||||
bool getIsOutgoing() const;
|
||||
boost::property_tree::ptree toPropertyTree() const;
|
||||
@@ -265,6 +281,8 @@ namespace monero {
|
||||
boost::optional<shared_ptr<MoneroTransferRequest>> transferRequest;
|
||||
boost::optional<shared_ptr<MoneroOutputRequest>> outputRequest;
|
||||
|
||||
MoneroTxRequest();
|
||||
MoneroTxRequest(const MoneroTxRequest& txRequest);
|
||||
boost::property_tree::ptree toPropertyTree() const;
|
||||
bool meetsCriteria(MoneroTxWallet* tx) const;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user