From 78d2e8dd2fb8295c2083ab948b2ab65dd412b147 Mon Sep 17 00:00:00 2001 From: woodser Date: Wed, 12 Jun 2019 22:43:27 -0400 Subject: [PATCH] add merge vins impl to MoneroTx()::merge(); define output / key image merge() --- src/daemon/MoneroDaemon.cpp | 27 +++++++++++++++++++++++++++ src/daemon/MoneroDaemon.h | 6 +++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/daemon/MoneroDaemon.cpp b/src/daemon/MoneroDaemon.cpp index 3c94ea4..a1d527f 100644 --- a/src/daemon/MoneroDaemon.cpp +++ b/src/daemon/MoneroDaemon.cpp @@ -194,6 +194,33 @@ namespace monero { unlockTime = MoneroUtils::reconcile(unlockTime, tx.unlockTime); numConfirmations = MoneroUtils::reconcile(numConfirmations, tx.numConfirmations); + // merge vins + if (!tx.vins.empty()) { + for (const shared_ptr& merger : tx.vins) { + bool merged = false; + merger->tx = shared_ptr(this); // TODO: can this cause this* to be deleted prematurely? + for (const shared_ptr& mergee : vins) { + //if (mergee.getKeyImage().getHex().equals(merger.getKeyImage().getHex())) { + if ((*mergee->keyImage)->hex == (*merger->keyImage)->hex) { + mergee->merge(*merger); + merged = true; + break; + } + } + if (!merged) vins.push_back(merger); + } + } + + throw runtime_error("Not implemented"); + } + + void MoneroKeyImage::merge(const MoneroKeyImage& keyImage) { + cout << "MoneroKeyImage::merge()" << endl; + throw runtime_error("Not implemented"); + } + + void MoneroOutput::merge(const MoneroOutput& output) { + cout << "MoneroOutput::merge()" << endl; throw runtime_error("Not implemented"); } diff --git a/src/daemon/MoneroDaemon.h b/src/daemon/MoneroDaemon.h index 87cbd3c..60dc825 100644 --- a/src/daemon/MoneroDaemon.h +++ b/src/daemon/MoneroDaemon.h @@ -156,6 +156,8 @@ namespace monero { struct MoneroKeyImage { boost::optional hex; boost::optional signature; + + void merge(const MoneroKeyImage& keyImage); }; /** @@ -163,11 +165,13 @@ namespace monero { */ struct MoneroOutput { shared_ptr tx; - boost::optional keyImage; + boost::optional> keyImage; boost::optional amount; boost::optional index; vector ringOutputIndices; boost::optional stealthPublicKey; + + void merge(const MoneroOutput& output); }; }