diff --git a/src/wallet/MoneroWallet.cpp b/src/wallet/MoneroWallet.cpp index e3fa5ad..d36b4c0 100644 --- a/src/wallet/MoneroWallet.cpp +++ b/src/wallet/MoneroWallet.cpp @@ -581,7 +581,7 @@ namespace monero { bool isPool = canBeIncoming && canBeInTxPool; bool isFailed = !boolEquals(false, txReq.isFailed) && !boolEquals(true, txReq.isConfirmed) && !boolEquals(true, txReq.inTxPool); - // collect unique txs and blocks using internal data structures + // collect unique txs and blocks map> txMap; map> blockMap; @@ -652,7 +652,29 @@ namespace monero { // TODO: this will modify original request, construct copy? add test MoneroTxRequest txReq = *(request.txRequest != boost::none ? *request.txRequest : shared_ptr(new MoneroTxRequest())); - throw runtime_error("Not implemented"); + // get outputs from wallet2 (referred to as "transfers" in wallet2 terminology) + tools::wallet2::transfer_container outputsW2; + wallet2->get_transfers(outputsW2); + + // collect unique txs and blocks + map> txMap; + map> blockMap; + for (const auto& outputW2 : outputsW2) { + // TODO: skip tx building if w2 output filtered by indices, etc + shared_ptr tx = buildTxWithVout(outputW2); + mergeTx(tx, txMap, blockMap, false); + } + + // filter and return vouts + vector> vouts; + for (map>::const_iterator txIter = txMap.begin(); txIter != txMap.end(); txIter++) { + shared_ptr tx = txIter->second; + for (const shared_ptr& output : tx->vouts) { + shared_ptr outputWallet = static_pointer_cast(output); + if (request.meetsCriteria(outputWallet.get())) vouts.push_back(outputWallet); + } + } + return vouts; } void MoneroWallet::save() { @@ -863,4 +885,8 @@ namespace monero { // return pointer to new tx return tx; } + + shared_ptr MoneroWallet::buildTxWithVout(const tools::wallet2::transfer_details& outputW2) const { + throw runtime_error("buildTxWithVout() not implemented"); + } } diff --git a/src/wallet/MoneroWallet.h b/src/wallet/MoneroWallet.h index 250e545..45fb3e4 100644 --- a/src/wallet/MoneroWallet.h +++ b/src/wallet/MoneroWallet.h @@ -1087,5 +1087,6 @@ namespace monero { vector getSubaddressesAux(uint32_t accountIdx, vector subaddressIndices, vector transfers) const; shared_ptr buildTxWithIncomingTransfer(const crypto::hash &txid, const crypto::hash &payment_id, const tools::wallet2::payment_details &pd) const; // TODO: these could be made inner anonymous by moving to top of .cpp shared_ptr buildTxWithOutgoingTransfer(const crypto::hash &txid, const tools::wallet2::confirmed_transfer_details &pd) const; + shared_ptr buildTxWithVout(const tools::wallet2::transfer_details& outputW2) const; }; }