merge(self, other) with base shared_ptrs to suppoert merge inheritance

This commit is contained in:
woodser
2019-06-16 09:48:44 -04:00
parent 9b181df21c
commit d646894707
4 changed files with 193 additions and 187 deletions
+164 -164
View File
@@ -98,183 +98,183 @@ namespace monero {
// -------------------------- MODEL IMPLEMENTATION --------------------------
void MoneroBlockHeader::merge(const MoneroBlockHeader& header) {
void MoneroBlockHeader::merge(const shared_ptr<MoneroBlockHeader>& header) {
cout << "MoneroBlockHeader::merge()" << endl;
if (this == &header) return;
id = MoneroUtils::reconcile(id, header.id);
height = MoneroUtils::reconcile(height, header.height, boost::none, boost::none, true); // height can increase
timestamp = MoneroUtils::reconcile(timestamp, header.timestamp, boost::none, boost::none, true); // timestamp can increase
size = MoneroUtils::reconcile(size, header.size);
weight = MoneroUtils::reconcile(weight, header.weight);
longTermWeight = MoneroUtils::reconcile(longTermWeight, header.longTermWeight);
depth = MoneroUtils::reconcile(depth, header.depth);
difficulty = MoneroUtils::reconcile(difficulty, header.difficulty);
cumulativeDifficulty = MoneroUtils::reconcile(cumulativeDifficulty, header.cumulativeDifficulty);
majorVersion = MoneroUtils::reconcile(majorVersion, header.majorVersion);
minorVersion = MoneroUtils::reconcile(minorVersion, header.minorVersion);
nonce = MoneroUtils::reconcile(nonce, header.nonce);
coinbaseTxId = MoneroUtils::reconcile(coinbaseTxId, header.coinbaseTxId);
numTxs = MoneroUtils::reconcile(numTxs, header.numTxs);
orphanStatus = MoneroUtils::reconcile(orphanStatus, header.orphanStatus);
prevId = MoneroUtils::reconcile(prevId, header.prevId);
reward = MoneroUtils::reconcile(reward, header.reward);
powHash = MoneroUtils::reconcile(powHash, header.powHash);
// if (this == &header) return;
// id = MoneroUtils::reconcile(id, header.id);
// height = MoneroUtils::reconcile(height, header.height, boost::none, boost::none, true); // height can increase
// timestamp = MoneroUtils::reconcile(timestamp, header.timestamp, boost::none, boost::none, true); // timestamp can increase
// size = MoneroUtils::reconcile(size, header.size);
// weight = MoneroUtils::reconcile(weight, header.weight);
// longTermWeight = MoneroUtils::reconcile(longTermWeight, header.longTermWeight);
// depth = MoneroUtils::reconcile(depth, header.depth);
// difficulty = MoneroUtils::reconcile(difficulty, header.difficulty);
// cumulativeDifficulty = MoneroUtils::reconcile(cumulativeDifficulty, header.cumulativeDifficulty);
// majorVersion = MoneroUtils::reconcile(majorVersion, header.majorVersion);
// minorVersion = MoneroUtils::reconcile(minorVersion, header.minorVersion);
// nonce = MoneroUtils::reconcile(nonce, header.nonce);
// coinbaseTxId = MoneroUtils::reconcile(coinbaseTxId, header.coinbaseTxId);
// numTxs = MoneroUtils::reconcile(numTxs, header.numTxs);
// orphanStatus = MoneroUtils::reconcile(orphanStatus, header.orphanStatus);
// prevId = MoneroUtils::reconcile(prevId, header.prevId);
// reward = MoneroUtils::reconcile(reward, header.reward);
// powHash = MoneroUtils::reconcile(powHash, header.powHash);
}
void MoneroBlock::merge(const MoneroBlock& block) {
void MoneroBlock::merge(const shared_ptr<MoneroBlockHeader>& block) {
cout << "MoneroBlock::merge()" << endl;
if (this == &block) return;
// merge header fields
MoneroBlockHeader::merge(block);
// merge coinbase tx
if (coinbaseTx == boost::none) coinbaseTx = block.coinbaseTx;
else if (block.coinbaseTx != boost::none) (**coinbaseTx).merge(**block.coinbaseTx);
// merge non-coinbase txs
if (txs.empty()) txs = block.txs;
else if (!block.txs.empty()) {
for (const shared_ptr<MoneroTx>& thatTx : block.txs) {
bool found = false;
for (const shared_ptr<MoneroTx>& thisTx : txs) {
if (thatTx->id == thisTx->id) {
thisTx->merge(*thatTx);
found = true;
break;
}
}
if (!found) txs.push_back(thatTx);
}
}
if (!txs.empty()) {
for (const shared_ptr<MoneroTx>& tx : txs) {
tx->block = shared_ptr<MoneroBlock>(this);
}
}
// merge other fields
hex = MoneroUtils::reconcile(hex, block.hex);
//txIds = MoneroUtils::reconcile(txIds, block.txIds); // TODO: implement
cout << "Returning from block::merge()!" << endl;
// if (this == &block) return;
//
// // merge header fields
// MoneroBlockHeader::merge(block);
//
// // merge coinbase tx
// if (coinbaseTx == boost::none) coinbaseTx = block.coinbaseTx;
// else if (block.coinbaseTx != boost::none) (**coinbaseTx).merge(**block.coinbaseTx);
//
// // merge non-coinbase txs
// if (txs.empty()) txs = block.txs;
// else if (!block.txs.empty()) {
// for (const shared_ptr<MoneroTx>& thatTx : block.txs) {
// bool found = false;
// for (const shared_ptr<MoneroTx>& thisTx : txs) {
// if (thatTx->id == thisTx->id) {
// thisTx->merge(*thatTx);
// found = true;
// break;
// }
// }
// if (!found) txs.push_back(thatTx);
// }
// }
// if (!txs.empty()) {
// for (const shared_ptr<MoneroTx>& tx : txs) {
// tx->block = shared_ptr<MoneroBlock>(this);
// }
// }
//
// // merge other fields
// hex = MoneroUtils::reconcile(hex, block.hex);
// //txIds = MoneroUtils::reconcile(txIds, block.txIds); // TODO: implement
// cout << "Returning from block::merge()!" << endl;
}
void MoneroTx::merge(const MoneroTx& tx) {
void MoneroTx::merge(const shared_ptr<MoneroTx>& self, const shared_ptr<MoneroTx>& other) {
cout << "MoneroTx::merge()" << endl;
if (this == &tx) return;
id = MoneroUtils::reconcile(id, tx.id);
version = MoneroUtils::reconcile(version, tx.version);
paymentId = MoneroUtils::reconcile(paymentId, tx.paymentId);
fee = MoneroUtils::reconcile(fee, tx.fee);
mixin = MoneroUtils::reconcile(mixin, tx.mixin);
isConfirmed = MoneroUtils::reconcile(isConfirmed, tx.isConfirmed);
doNotRelay = MoneroUtils::reconcile(doNotRelay, tx.doNotRelay);
isRelayed = MoneroUtils::reconcile(isRelayed, tx.isRelayed);
isDoubleSpend = MoneroUtils::reconcile(isDoubleSpend, tx.isDoubleSpend);
key = MoneroUtils::reconcile(key, tx.key);
fullHex = MoneroUtils::reconcile(fullHex, tx.fullHex);
prunedHex = MoneroUtils::reconcile(prunedHex, tx.prunedHex);
prunableHex = MoneroUtils::reconcile(prunableHex, tx.prunableHex);
prunableHash = MoneroUtils::reconcile(prunableHash, tx.prunableHash);
size = MoneroUtils::reconcile(size, tx.size);
weight = MoneroUtils::reconcile(weight, tx.weight);
//outputIndices = MoneroUtils::reconcile(outputIndices, tx.outputIndices); // TODO
metadata = MoneroUtils::reconcile(metadata, tx.metadata);
commonTxSets = MoneroUtils::reconcile(commonTxSets, tx.commonTxSets);
//extra = MoneroUtils::reconcile(extra, tx.extra); // TODO
rctSignatures = MoneroUtils::reconcile(rctSignatures, tx.rctSignatures);
rctSigPrunable = MoneroUtils::reconcile(rctSigPrunable, tx.rctSigPrunable);
isKeptByBlock = MoneroUtils::reconcile(isKeptByBlock, tx.isKeptByBlock);
isFailed = MoneroUtils::reconcile(isFailed, tx.isFailed);
lastFailedHeight = MoneroUtils::reconcile(lastFailedHeight, tx.lastFailedHeight);
lastFailedId = MoneroUtils::reconcile(lastFailedId, tx.lastFailedId);
maxUsedBlockHeight = MoneroUtils::reconcile(maxUsedBlockHeight, tx.maxUsedBlockHeight);
maxUsedBlockId = MoneroUtils::reconcile(maxUsedBlockId, tx.maxUsedBlockId);
//signatures = MoneroUtils::reconcile(signatures, tx.signatures); // TODO
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->keyImage)->hex == (*merger->keyImage)->hex) {
mergee->merge(*merger);
merged = true;
break;
}
}
if (!merged) vins.push_back(merger);
}
}
// merge vouts
if (!tx.vouts.empty()) {
for (const shared_ptr<MoneroOutput>& vout : tx.vouts) vout->tx = shared_ptr<MoneroTx>(this);
if (vouts.empty()) vouts = tx.vouts;
else {
// determine if key images present
int numKeyImages = 0;
for (const shared_ptr<MoneroOutput> vout : vouts) {
if (vout->keyImage != boost::none) {
if ((*vout->keyImage)->hex == boost::none) throw runtime_error("Key image hex cannot be null");
numKeyImages++;
}
}
for (const shared_ptr<MoneroOutput>& vout : tx.vouts) {
if (vout->keyImage != boost::none) {
if ((*vout->keyImage)->hex == boost::none) throw runtime_error("Key image hex cannot be null");
numKeyImages++;
}
}
if (numKeyImages != 0 && vouts.size() + tx.vouts.size() != numKeyImages) throw runtime_error("Some vouts have a key image and some do not");
// merge by key images
if (numKeyImages > 0) {
for (const shared_ptr<MoneroOutput>& merger : tx.vouts) {
bool merged = false;
for (const shared_ptr<MoneroOutput>& mergee : vouts) {
if ((*mergee->keyImage)->hex == (*merger->keyImage)->hex) {
mergee->merge(*merger);
merged = true;
break;
}
}
if (!merged) vouts.push_back(merger);
}
}
// merge by position
else {
if (vouts.size() != tx.vouts.size()) throw runtime_error("Vout sizes are different");
for (int i = 0; i < tx.vouts.size(); i++) {
vouts.at(i)->merge(*tx.vouts.at(i));
}
}
}
}
// handle unrelayed -> relayed -> confirmed
if (*isConfirmed) {
inTxPool = false;
receivedTimestamp = boost::none;
lastRelayedTimestamp = boost::none;
} else {
inTxPool = MoneroUtils::reconcile(inTxPool, tx.inTxPool, boost::none, true, boost::none); // unrelayed -> tx pool
receivedTimestamp = MoneroUtils::reconcile(receivedTimestamp, tx.receivedTimestamp, boost::none, boost::none, false); // take earliest receive time
lastRelayedTimestamp = MoneroUtils::reconcile(lastRelayedTimestamp, tx.lastRelayedTimestamp, boost::none, boost::none, true); // take latest relay time
}
// if (this == &tx) return;
// id = MoneroUtils::reconcile(id, tx.id);
// version = MoneroUtils::reconcile(version, tx.version);
// paymentId = MoneroUtils::reconcile(paymentId, tx.paymentId);
// fee = MoneroUtils::reconcile(fee, tx.fee);
// mixin = MoneroUtils::reconcile(mixin, tx.mixin);
// isConfirmed = MoneroUtils::reconcile(isConfirmed, tx.isConfirmed);
// doNotRelay = MoneroUtils::reconcile(doNotRelay, tx.doNotRelay);
// isRelayed = MoneroUtils::reconcile(isRelayed, tx.isRelayed);
// isDoubleSpend = MoneroUtils::reconcile(isDoubleSpend, tx.isDoubleSpend);
// key = MoneroUtils::reconcile(key, tx.key);
// fullHex = MoneroUtils::reconcile(fullHex, tx.fullHex);
// prunedHex = MoneroUtils::reconcile(prunedHex, tx.prunedHex);
// prunableHex = MoneroUtils::reconcile(prunableHex, tx.prunableHex);
// prunableHash = MoneroUtils::reconcile(prunableHash, tx.prunableHash);
// size = MoneroUtils::reconcile(size, tx.size);
// weight = MoneroUtils::reconcile(weight, tx.weight);
// //outputIndices = MoneroUtils::reconcile(outputIndices, tx.outputIndices); // TODO
// metadata = MoneroUtils::reconcile(metadata, tx.metadata);
// commonTxSets = MoneroUtils::reconcile(commonTxSets, tx.commonTxSets);
// //extra = MoneroUtils::reconcile(extra, tx.extra); // TODO
// rctSignatures = MoneroUtils::reconcile(rctSignatures, tx.rctSignatures);
// rctSigPrunable = MoneroUtils::reconcile(rctSigPrunable, tx.rctSigPrunable);
// isKeptByBlock = MoneroUtils::reconcile(isKeptByBlock, tx.isKeptByBlock);
// isFailed = MoneroUtils::reconcile(isFailed, tx.isFailed);
// lastFailedHeight = MoneroUtils::reconcile(lastFailedHeight, tx.lastFailedHeight);
// lastFailedId = MoneroUtils::reconcile(lastFailedId, tx.lastFailedId);
// maxUsedBlockHeight = MoneroUtils::reconcile(maxUsedBlockHeight, tx.maxUsedBlockHeight);
// maxUsedBlockId = MoneroUtils::reconcile(maxUsedBlockId, tx.maxUsedBlockId);
// //signatures = MoneroUtils::reconcile(signatures, tx.signatures); // TODO
// 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->keyImage)->hex == (*merger->keyImage)->hex) {
// mergee->merge(*merger);
// merged = true;
// break;
// }
// }
// if (!merged) vins.push_back(merger);
// }
// }
//
// // merge vouts
// if (!tx.vouts.empty()) {
// for (const shared_ptr<MoneroOutput>& vout : tx.vouts) vout->tx = shared_ptr<MoneroTx>(this);
// if (vouts.empty()) vouts = tx.vouts;
// else {
//
// // determine if key images present
// int numKeyImages = 0;
// for (const shared_ptr<MoneroOutput> vout : vouts) {
// if (vout->keyImage != boost::none) {
// if ((*vout->keyImage)->hex == boost::none) throw runtime_error("Key image hex cannot be null");
// numKeyImages++;
// }
// }
// for (const shared_ptr<MoneroOutput>& vout : tx.vouts) {
// if (vout->keyImage != boost::none) {
// if ((*vout->keyImage)->hex == boost::none) throw runtime_error("Key image hex cannot be null");
// numKeyImages++;
// }
// }
// if (numKeyImages != 0 && vouts.size() + tx.vouts.size() != numKeyImages) throw runtime_error("Some vouts have a key image and some do not");
//
// // merge by key images
// if (numKeyImages > 0) {
// for (const shared_ptr<MoneroOutput>& merger : tx.vouts) {
// bool merged = false;
// for (const shared_ptr<MoneroOutput>& mergee : vouts) {
// if ((*mergee->keyImage)->hex == (*merger->keyImage)->hex) {
// mergee->merge(*merger);
// merged = true;
// break;
// }
// }
// if (!merged) vouts.push_back(merger);
// }
// }
//
// // merge by position
// else {
// if (vouts.size() != tx.vouts.size()) throw runtime_error("Vout sizes are different");
// for (int i = 0; i < tx.vouts.size(); i++) {
// vouts.at(i)->merge(*tx.vouts.at(i));
// }
// }
// }
// }
//
// // handle unrelayed -> relayed -> confirmed
// if (*isConfirmed) {
// inTxPool = false;
// receivedTimestamp = boost::none;
// lastRelayedTimestamp = boost::none;
// } else {
// inTxPool = MoneroUtils::reconcile(inTxPool, tx.inTxPool, boost::none, true, boost::none); // unrelayed -> tx pool
// receivedTimestamp = MoneroUtils::reconcile(receivedTimestamp, tx.receivedTimestamp, boost::none, boost::none, false); // take earliest receive time
// lastRelayedTimestamp = MoneroUtils::reconcile(lastRelayedTimestamp, tx.lastRelayedTimestamp, boost::none, boost::none, true); // take latest relay time
// }
}
void MoneroKeyImage::merge(const MoneroKeyImage& keyImage) {
void MoneroKeyImage::merge(const shared_ptr<MoneroKeyImage>& self, const shared_ptr<MoneroKeyImage>& other) {
cout << "MoneroKeyImage::merge()" << endl;
throw runtime_error("Not implemented");
}
void MoneroOutput::merge(const MoneroOutput& output) {
void MoneroOutput::merge(const shared_ptr<MoneroOutput>& self, const shared_ptr<MoneroOutput>& other) {
cout << "MoneroOutput::merge()" << endl;
throw runtime_error("Not implemented");
}
+5 -5
View File
@@ -82,7 +82,7 @@ namespace monero {
boost::optional<string> powHash;
boost::property_tree::ptree toPropertyTree() const;
void merge(const MoneroBlockHeader& header);
void merge(const shared_ptr<MoneroBlockHeader>& header);
};
/**
@@ -95,7 +95,7 @@ namespace monero {
vector<string> txIds;
boost::property_tree::ptree toPropertyTree() const;
void merge(const MoneroBlock& block);
void merge(const shared_ptr<MoneroBlockHeader>& block);
};
/**
@@ -147,7 +147,7 @@ namespace monero {
if (block == boost::none) return boost::none;
return *((*block)->height);
}
void merge(const MoneroTx& tx);
void merge(const shared_ptr<MoneroTx>& self, const shared_ptr<MoneroTx>& other);
};
/**
@@ -157,7 +157,7 @@ namespace monero {
boost::optional<string> hex;
boost::optional<string> signature;
void merge(const MoneroKeyImage& keyImage);
void merge(const shared_ptr<MoneroKeyImage>& self, const shared_ptr<MoneroKeyImage>& other);
};
/**
@@ -171,7 +171,7 @@ namespace monero {
vector<uint32_t> ringOutputIndices;
boost::optional<string> stealthPublicKey;
void merge(const MoneroOutput& output);
void merge(const shared_ptr<MoneroOutput>& self, const shared_ptr<MoneroOutput>& other);
};
}
+21 -16
View File
@@ -185,8 +185,8 @@ namespace monero {
* @param skipIfAbsent specifies if the tx should not be added if it doesn't already exist
* @returns the merged tx
*/
void mergeTx(vector<shared_ptr<MoneroTxWallet>>& txs, const shared_ptr<MoneroTxWallet>& tx, bool skipIfAbsent) {
cout << "mergeTx()" << endl;
void mergeTx(vector<shared_ptr<MoneroTx>>& txs, const shared_ptr<MoneroTx>& tx, bool skipIfAbsent) {
cout << "mergeTx(txs, txs)" << endl;
if (tx->id == boost::none) throw runtime_error("Tx id is not initialized");
for (const auto& aTx: txs) {
@@ -209,16 +209,16 @@ namespace monero {
(*tx->block)->txs = txs;
(*tx->block)->height = *aTx->getHeight();
}
(*aTx->block)->merge(**tx->block);
(*aTx->block)->merge(*tx->block);
} else {
aTx->merge(*tx);
aTx->merge(aTx, tx);
}
return;
}
// merge common block of different txs
if (tx->getHeight() != boost::none && *tx->getHeight() == *aTx->getHeight()) {
(*aTx->block)->merge(**tx->block);
(*aTx->block)->merge(*tx->block);
//if (aTx.getIsConfirmed()) assertTrue(aTx.getBlock().getTxs().contains(aTx));
}
}
@@ -624,7 +624,7 @@ namespace monero {
// createSubaddress
vector<MoneroTxWallet> MoneroWallet::getTxs(const MoneroTxRequest& request) const {
vector<shared_ptr<MoneroTxWallet>> MoneroWallet::getTxs(const MoneroTxRequest& request) const {
cout << "getTxs(request)" << endl;
// print for debug
@@ -673,14 +673,14 @@ namespace monero {
// collect unique transactions
vector<shared_ptr<MoneroTxWallet>> txs;
vector<shared_ptr<MoneroTx>> txs;
// get confirmed incoming transfers
if (isIn) {
std::list<std::pair<crypto::hash, tools::wallet2::payment_details>> payments;
wallet2->get_payments(payments, minHeight, maxHeight, accountIndex, subaddressIndices);
for (std::list<std::pair<crypto::hash, tools::wallet2::payment_details>>::const_iterator i = payments.begin(); i != payments.end(); ++i) {
shared_ptr<MoneroTxWallet> tx = buildTxWithIncomingTransfer(i->second.m_tx_hash, i->first, i->second);
shared_ptr<MoneroTx> tx = buildTxWithIncomingTransfer(i->second.m_tx_hash, i->first, i->second);
mergeTx(txs, tx, false);
//txs.push_back(tx);
}
@@ -706,7 +706,8 @@ namespace monero {
// collect resulting transfers
vector<shared_ptr<MoneroTransfer>> transfers;
for (int i = 0; i < txs.size(); i++) {
shared_ptr<MoneroTxWallet> tx = txs[i];
shared_ptr<MoneroTx> txBase = txs[i];
const MoneroTxWallet* tx = static_cast<MoneroTxWallet*>(&*txBase); // shared_ptrs use base class but these are actually MoneroTxWallets
for (int j = 0; j < tx->incomingTransfers.size(); j++) {
transfers.push_back(tx->incomingTransfers[j]);
}
@@ -862,16 +863,19 @@ namespace monero {
return subaddresses;
}
shared_ptr<MoneroTxWallet> MoneroWallet::buildTxWithIncomingTransfer(const crypto::hash &txid, const crypto::hash &payment_id, const tools::wallet2::payment_details &pd) const {
shared_ptr<MoneroTx> MoneroWallet::buildTxWithIncomingTransfer(const crypto::hash &txid, const crypto::hash &payment_id, const tools::wallet2::payment_details &pd) const {
cout << "buildTxWithIncomingTransfer()" << endl;
// construct block
shared_ptr<MoneroBlock> block = shared_ptr<MoneroBlock>(new MoneroBlock());
block->height = pd.m_block_height;
block->timestamp = pd.m_timestamp;
shared_ptr<MoneroTxWallet> tx = shared_ptr<MoneroTxWallet>(new MoneroTxWallet());
// construct tx
shared_ptr<MoneroTx> txBase = shared_ptr<MoneroTx>(new MoneroTxWallet());
MoneroTxWallet* tx = static_cast<MoneroTxWallet*>(&*txBase); // get MoneroTxWallet* from base shared_ptr
tx->block = block;
block->txs.push_back(tx);
block->txs.push_back(txBase);
tx->id = string_tools::pod_to_hex(pd.m_tx_hash);
tx->paymentId = string_tools::pod_to_hex(payment_id);
if (tx->paymentId->substr(16).find_first_not_of('0') == std::string::npos) tx->paymentId = tx->paymentId->substr(0, 16); // TODO monero core: this should be part of core wallet
@@ -894,9 +898,10 @@ namespace monero {
else tx->numConfirmations = chainHeight - *block->height;
// construct transfer
shared_ptr<MoneroIncomingTransfer> incomingTransfer = shared_ptr<MoneroIncomingTransfer>(new MoneroIncomingTransfer());
incomingTransfer->tx = tx;
tx->incomingTransfers.push_back(incomingTransfer);
shared_ptr<MoneroIncomingTransfer> incomingTransferBase = shared_ptr<MoneroIncomingTransfer>(new MoneroIncomingTransfer());
MoneroIncomingTransfer* incomingTransfer = static_cast<MoneroIncomingTransfer*>(&*incomingTransferBase);
incomingTransfer->tx = txBase;
tx->incomingTransfers.push_back(incomingTransferBase);
incomingTransfer->amount = pd.m_amount;
incomingTransfer->accountIndex = pd.m_subaddr_index.major;
incomingTransfer->subaddressIndex = pd.m_subaddr_index.minor;
@@ -908,7 +913,7 @@ namespace monero {
else incomingTransfer->numSuggestedConfirmations = (*incomingTransfer->amount + blockReward - 1) / blockReward;
// return pointer to new tx
return tx;
return txBase;
}
// MoneroTransfer MoneroWallet::convertWallet2IncomingTransfer(const tools::wallet2& wallet2, const crypto::hash &txid, const crypto::hash &payment_id, const tools::wallet2::payment_details &pd) const {
+3 -2
View File
@@ -52,6 +52,7 @@ namespace monero {
// END_KV_SERIALIZE_MAP()
boost::property_tree::ptree toPropertyTree() const;
//void merge(const shared_ptr<MoneroSubaddress>& self, const shared_ptr<MoneroSubaddress>& other);
};
/**
@@ -686,7 +687,7 @@ namespace monero {
* @param request filters query results (optional)
* @return wallet transactions per the request
*/
vector<MoneroTxWallet> getTxs(const MoneroTxRequest& request) const;
vector<shared_ptr<MoneroTxWallet>> getTxs(const MoneroTxRequest& request) const;
// /**
// * Get all incoming and outgoing transfers to and from this wallet. An
@@ -1267,7 +1268,7 @@ namespace monero {
MoneroSyncResult syncAux(boost::optional<uint64_t> startHeight, boost::optional<uint64_t> endHeight, boost::optional<MoneroSyncListener&> listener);
vector<MoneroSubaddress> getSubaddressesAux(uint32_t accountIdx, vector<uint32_t> subaddressIndices, vector<tools::wallet2::transfer_details> transfers) const;
shared_ptr<MoneroTxWallet> buildTxWithIncomingTransfer(const crypto::hash &txid, const crypto::hash &payment_id, const tools::wallet2::payment_details &pd) const;
shared_ptr<MoneroTx> buildTxWithIncomingTransfer(const crypto::hash &txid, const crypto::hash &payment_id, const tools::wallet2::payment_details &pd) const;
};
}