From 34b69aa0954b0d9334d5e84613bf7aa9291b2753 Mon Sep 17 00:00:00 2001 From: woodser Date: Fri, 28 Jun 2019 23:08:15 -0400 Subject: [PATCH] try catch unecessary because exception handled externally --- src/wallet/MoneroWallet.cpp | 59 +++++++++++++++++++++++++++---------- 1 file changed, 43 insertions(+), 16 deletions(-) diff --git a/src/wallet/MoneroWallet.cpp b/src/wallet/MoneroWallet.cpp index de90f45..9e6b8d5 100644 --- a/src/wallet/MoneroWallet.cpp +++ b/src/wallet/MoneroWallet.cpp @@ -1119,21 +1119,17 @@ namespace monero { } // TODO: *** HERE *** - try { +// try { - // prepare parameters for wallet2 create_transactions_2 - uint64_t mixin = wallet2->adjust_mixin(request.ringSize == boost::none ? 0 : request.ringSize.get() - 1); - uint32_t priority = wallet2->adjust_priority(request.priority == boost::none ? 0 : request.priority.get()); - uint64_t unlockTime = request.unlockTime == boost::none ? 0 : request.unlockTime.get(); - uint32_t accountIndex = 0; // TODO - std::set subaddressIndices; // TODO + // prepare parameters for wallet2 create_transactions_2 + uint64_t mixin = wallet2->adjust_mixin(request.ringSize == boost::none ? 0 : request.ringSize.get() - 1); + uint32_t priority = wallet2->adjust_priority(request.priority == boost::none ? 0 : request.priority.get()); + uint64_t unlockTime = request.unlockTime == boost::none ? 0 : request.unlockTime.get(); + uint32_t accountIndex = 0; // TODO + std::set subaddressIndices; // TODO - - //if (request.priority != boost::none) wallet2->adjust_priority((uint32_t) request.priority.get()); - - - vector ptx_vector = wallet2->create_transactions_2(dsts, mixin, unlockTime, priority, extra, accountIndex, subaddressIndices); - cout << "CREATED " << ptx_vector.size() << " PENDING TXS" << endl; + vector ptx_vector = wallet2->create_transactions_2(dsts, mixin, unlockTime, priority, extra, accountIndex, subaddressIndices); + cout << "CREATED " << ptx_vector.size() << " PENDING TXS" << endl; // // if (ptx_vector.empty()) { // er.code = WALLET_RPC_ERROR_CODE_TX_NOT_POSSIBLE; @@ -1149,9 +1145,40 @@ namespace monero { // } // // return fill_response(wallet2, ptx_vector, req.get_tx_key, res.tx_key, res.amount, res.fee, res.multisig_txset, res.unsigned_txset, req.do_not_relay, res.tx_hash, req.get_tx_hex, res.tx_blob, req.get_tx_metadata, res.tx_metadata, er); - } catch (const std::exception& e) { - throw runtime_error("Need to handle exception"); // TODO - } + + + // config for fill_response() + bool getTxKeys = true; + bool getTxHex = true; + bool getTxMetadata = true; + bool doNotRelay = request.doNotRelay == boost::none ? false : request.doNotRelay.get(); + + // initialize tx data using fill_response() + list txKeys; + list txAmounts; + list txFees; + string multisigTxSet; + string unsignedTxSet; + list txIds; + list txBlobs; + list txMetadatas; + fill_response(wallet2.get(), ptx_vector, getTxKeys, txKeys, txAmounts, txFees, multisigTxSet, unsignedTxSet, doNotRelay, txIds, getTxHex, txBlobs, getTxMetadata, txMetadatas, err); + + for (const auto& txKey : txKeys) cout << txKey << endl; + + // build txs from filled data + + + + //return fill_response(wallet2, ptx_vector, req.get_tx_key, res.tx_key, res.amount, res.fee, res.multisig_txset, res.unsigned_txset, req.do_not_relay, res.tx_hash, req.get_tx_hex, res.tx_blob, req.get_tx_metadata, res.tx_metadata, er); + + // return fill_response(wallet2, ptx_vector, req.get_tx_keys, res.tx_key_list, res.amount_list, res.fee_list, res.multisig_txset, res.unsigned_txset, req.do_not_relay, + // res.tx_hash_list, req.get_tx_hex, res.tx_blob_list, req.get_tx_metadata, res.tx_metadata_list, er); +// } catch (const std::exception& e) { +// throw runtime_error(e.what()); +// //cout << "Caught exception: " << e.what() << endl; +// //throw runtime_error(e.); // TODO +// }