mirror of
https://github.com/wownero/wownero-cpp.git
synced 2026-10-17 15:21:30 +02:00
block merge sets coinbase tx block
This commit is contained in:
@@ -152,7 +152,7 @@ namespace monero {
|
||||
if (this != self.get()) throw runtime_error("this != self");
|
||||
if (self == other) return;
|
||||
|
||||
// merge base classes
|
||||
// merge header fields
|
||||
MoneroBlockHeader::merge(self, other);
|
||||
|
||||
// merge reconcilable block extensions
|
||||
@@ -161,9 +161,9 @@ namespace monero {
|
||||
|
||||
// merge coinbase tx
|
||||
if (coinbaseTx == boost::none) coinbaseTx = other->coinbaseTx;
|
||||
else if (other->coinbaseTx != boost::none) {
|
||||
if (other->coinbaseTx != boost::none) {
|
||||
other->coinbaseTx.get()->block = self;
|
||||
coinbaseTx.get()->merge(*coinbaseTx, *other->coinbaseTx);
|
||||
coinbaseTx.get()->merge(coinbaseTx.get(), other->coinbaseTx.get());
|
||||
}
|
||||
|
||||
// merge non-coinbase txs
|
||||
@@ -385,6 +385,14 @@ namespace monero {
|
||||
void MoneroOutput::merge(const shared_ptr<MoneroOutput>& self, const shared_ptr<MoneroOutput>& other) {
|
||||
if (this != self.get()) throw runtime_error("this != self");
|
||||
if (self == other) return;
|
||||
|
||||
// merge txs if they're different which comes back to merging outputs
|
||||
if (tx != other->tx) {
|
||||
tx->merge(tx, other->tx);
|
||||
return;
|
||||
}
|
||||
|
||||
// otherwise merge output fields
|
||||
if (keyImage == boost::none) keyImage = other->keyImage;
|
||||
else if (other->keyImage != boost::none) keyImage.get()->merge(keyImage.get(), other->keyImage.get());
|
||||
amount = MoneroUtils::reconcile(amount, other->amount);
|
||||
|
||||
@@ -1329,7 +1329,7 @@ namespace monero {
|
||||
|
||||
//cout << "4" << endl;
|
||||
|
||||
// collect unique txs
|
||||
// cache unique txs and blocks
|
||||
uint64_t chainHeight = getChainHeight();
|
||||
map<string, shared_ptr<MoneroTxWallet>> txMap;
|
||||
map<uint64_t, shared_ptr<MoneroBlock>> blockMap;
|
||||
@@ -1442,7 +1442,7 @@ namespace monero {
|
||||
tools::wallet2::transfer_container outputsW2;
|
||||
wallet2->get_transfers(outputsW2);
|
||||
|
||||
// collect unique txs and blocks
|
||||
// cache unique txs and blocks
|
||||
map<string, shared_ptr<MoneroTxWallet>> txMap;
|
||||
map<uint64_t, shared_ptr<MoneroBlock>> blockMap;
|
||||
for (const auto& outputW2 : outputsW2) {
|
||||
@@ -1466,7 +1466,7 @@ namespace monero {
|
||||
}
|
||||
}
|
||||
|
||||
// remove txs without requested transfer
|
||||
// remove txs without requested vout
|
||||
if (tx->vouts.empty() && tx->block != boost::none) tx->block.get()->txs.erase(std::remove(tx->block.get()->txs.begin(), tx->block.get()->txs.end(), tx), tx->block.get()->txs.end()); // TODO, no way to use const_iterator?
|
||||
}
|
||||
return vouts;
|
||||
|
||||
@@ -156,18 +156,6 @@ namespace monero {
|
||||
}
|
||||
}
|
||||
|
||||
//boost::property_tree::ptree MoneroUtils::txWalletToPropertyTree(const MoneroTxWallet& tx) {
|
||||
// cout << "txWalletToPropertyTree(tx)" << endl;
|
||||
// boost::property_tree::ptree txNode = txToPropertyTree(tx);
|
||||
// if (!tx.vouts.empty()) throw runtime_error("not implemented");
|
||||
// if (!tx.incomingTransfers.empty()) throw runtime_error("not implemented");
|
||||
// if (tx.outgoingTransfer != boost::none) throw runtime_error("not implemented");
|
||||
// if (tx.numSuggestedConfirmations != boost::none) txNode.put("numSuggestedConfirmations", *tx.numSuggestedConfirmations);
|
||||
// if (tx.note != boost::none) txNode.put("note", *tx.note);
|
||||
// return txNode;
|
||||
//}
|
||||
//
|
||||
|
||||
// -------------------------- MONERO TX REQUEST -----------------------------
|
||||
|
||||
boost::property_tree::ptree MoneroTxRequest::toPropertyTree() const {
|
||||
|
||||
Reference in New Issue
Block a user