From e4cb9769f839e7291d2d29c72c00dc2b04ced5ae Mon Sep 17 00:00:00 2001 From: woodser Date: Sat, 22 Jun 2019 00:22:22 -0400 Subject: [PATCH] buildTxWithVout() impl --- src/wallet/MoneroWallet.cpp | 39 +++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/src/wallet/MoneroWallet.cpp b/src/wallet/MoneroWallet.cpp index d36b4c0..da6ab95 100644 --- a/src/wallet/MoneroWallet.cpp +++ b/src/wallet/MoneroWallet.cpp @@ -886,7 +886,42 @@ namespace monero { return tx; } - shared_ptr MoneroWallet::buildTxWithVout(const tools::wallet2::transfer_details& outputW2) const { - throw runtime_error("buildTxWithVout() not implemented"); + shared_ptr MoneroWallet::buildTxWithVout(const tools::wallet2::transfer_details& td) const { + cout << "MoneroWallet::bulidTxWithVout()" << endl; + + // construct block + shared_ptr block = shared_ptr(new MoneroBlock()); + block->height = td.m_block_height; + + // construct tx + shared_ptr tx = shared_ptr(new MoneroTxWallet()); + tx->block = block; + block->txs.push_back(tx); + tx->id = epee::string_tools::pod_to_hex(td.m_txid); + tx->isConfirmed = true; + tx->isFailed = false; + tx->isRelayed = true; + tx->inTxPool = false; + tx->doNotRelay = false; + tx->isDoubleSpend = false; + + // construct vout + shared_ptr vout = shared_ptr(new MoneroOutputWallet()); + vout->tx = tx; + tx->vouts.push_back(vout); + vout->amount = td.amount(); + vout->index = td.m_global_output_index; + vout->accountIndex = td.m_subaddr_index.major; + vout->subaddressIndex = td.m_subaddr_index.minor; + vout->isSpent = td.m_spent; + vout->isUnlocked = wallet2->is_transfer_unlocked(td); + vout->isFrozen = td.m_frozen; + if (td.m_key_image_known) { + vout->keyImage = shared_ptr(new MoneroKeyImage()); + vout->keyImage.get()->hex = epee::string_tools::pod_to_hex(td.m_key_image); + } + + // return pointer to new tx + return tx; } }