diff --git a/src/wallet/monero_wallet.cpp b/src/wallet/monero_wallet.cpp index b509c6c..63aad05 100644 --- a/src/wallet/monero_wallet.cpp +++ b/src/wallet/monero_wallet.cpp @@ -1712,8 +1712,21 @@ namespace monero { return create_tx(req); } - vector> monero_wallet::create_txs(const monero_send_request& request) { - throw new runtime_error("not implemented"); + vector> monero_wallet::create_txs(monero_send_request& request) { + + // modify request to not relay + boost::optional requested_do_not_relay = request.m_do_not_relay; + request.m_do_not_relay = true; + + // invoke common method which doesn't relay + vector> created_txs = send_split(request); + + // restore doNotRelay of request and txs + request.m_do_not_relay = requested_do_not_relay; + for (const shared_ptr& tx : created_txs) tx->m_do_not_relay = requested_do_not_relay; + + // return results + return created_txs; } string monero_wallet::relay_tx(const string& tx_metadata) { @@ -1764,20 +1777,28 @@ namespace monero { return m_tx_ids; } - vector monero_wallet::relay_txs(const vector& txs) { - throw new runtime_error("relay_txs not implemented"); + vector monero_wallet::relay_txs(const vector>& txs) { + vector tx_hexes; + for (const shared_ptr& tx : txs) tx_hexes.push_back(tx->m_metadata.get()); + return relay_txs(tx_hexes); } shared_ptr monero_wallet::send(monero_send_request& request) { - throw new runtime_error("send not implemented"); + if (request.m_can_split != boost::none && request.m_can_split.get()) throw runtime_error("Cannot request split transactions with send() which prevents splitting; use sendSplit() instead"); + request.m_can_split = false; + return send_split(request)[0]; } shared_ptr monero_wallet::send(uint32_t account_index, string address, uint64_t amount) { - throw new runtime_error("send not implemented"); + return send(account_index, address, amount, monero_send_priority::NORMAL); } shared_ptr monero_wallet::send(uint32_t account_index, string address, uint64_t amount, monero_send_priority priority) { - throw new runtime_error("send not implemented"); + monero_send_request req; + req.m_account_index = account_index; + req.m_destinations.push_back(make_shared(address, amount)); + req.m_priority = priority; + return send(req); } vector> monero_wallet::send_split(const monero_send_request& request) { diff --git a/src/wallet/monero_wallet.h b/src/wallet/monero_wallet.h index d55a6ba..28ae564 100644 --- a/src/wallet/monero_wallet.h +++ b/src/wallet/monero_wallet.h @@ -784,7 +784,7 @@ namespace monero { * @param request configures the transactions to create * @return the created transactions */ - vector> create_txs(const monero_send_request& request); + vector> create_txs(monero_send_request& request); /** * Relay a transaction previously created without relaying. @@ -816,7 +816,7 @@ namespace monero { * @param txs are the transactions to relay * @return the ids of the relayed txs */ - vector relay_txs(const vector& txs); + vector relay_txs(const vector>& txs); /** * Create and relay a transaction to transfer funds from this wallet diff --git a/todo.txt b/todo.txt index 77a113e..0267b8d 100644 --- a/todo.txt +++ b/todo.txt @@ -5,6 +5,7 @@ sample code including readme monero_wallet_listener should be a class? MEDIUM PRIORITY +separate wallet default impl from must impl create_tx and send_tx request arg should be const; need to copy should not need wallet.h / wallet.cpp as dependency, why are GUI deps needed? make model fields private and use accessors / mutators?