add merge vins impl to MoneroTx()::merge();

define output / key image merge()
This commit is contained in:
woodser
2019-06-12 22:43:27 -04:00
parent b8a6f79c7d
commit 78d2e8dd2f
2 changed files with 32 additions and 1 deletions
+27
View File
@@ -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<MoneroOutput>& merger : tx.vins) {
bool merged = false;
merger->tx = shared_ptr<MoneroTx>(this); // TODO: can this cause this* to be deleted prematurely?
for (const shared_ptr<MoneroOutput>& 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");
}
+5 -1
View File
@@ -156,6 +156,8 @@ namespace monero {
struct MoneroKeyImage {
boost::optional<string> hex;
boost::optional<string> signature;
void merge(const MoneroKeyImage& keyImage);
};
/**
@@ -163,11 +165,13 @@ namespace monero {
*/
struct MoneroOutput {
shared_ptr<MoneroTx> tx;
boost::optional<MoneroKeyImage> keyImage;
boost::optional<shared_ptr<MoneroKeyImage>> keyImage;
boost::optional<uint64_t> amount;
boost::optional<uint32_t> index;
vector<uint32_t> ringOutputIndices;
boost::optional<string> stealthPublicKey;
void merge(const MoneroOutput& output);
};
}