Commit b5f08e1c authored by Pierre Kim's avatar Pierre Kim

Fix linux build / transfer_split implementation in progress

parent 63754749
......@@ -18,7 +18,7 @@
#include "CryptoNoteCore/Currency.h"
#include "CryptoNoteCore/MinerConfig.h"
#include "CryptoNoteProtocol/CryptoNoteProtocolHandler.h"
#include "BlockchainExplorer\BlockchainExplorerDataBuilder.h"
#include "BlockchainExplorer/BlockchainExplorerDataBuilder.h"
#include "P2p/NetNode.h"
#include "P2p/NetNodeConfig.h"
#include "Rpc/RpcServer.h"
......
......@@ -10,7 +10,7 @@
#include <Logging/LoggerRef.h>
#include "CoreRpcServerCommandsDefinitions.h"
#include "BlockchainExplorer\BlockchainExplorerDataBuilder.h"
#include "BlockchainExplorer/BlockchainExplorerDataBuilder.h"
namespace CryptoNote {
......
......@@ -108,6 +108,7 @@ void wallet_rpc_server::processRequest(const CryptoNote::HttpRequest& request, C
if (api_xmr)
{
s_methods.insert({ "getbalance", makeMemberMethod(&wallet_rpc_server::on_getbalance_xmr) });
s_methods.insert({ "transfer_split", makeMemberMethod(&wallet_rpc_server::on_transfer_split) });
}
else
{
......@@ -209,6 +210,90 @@ bool wallet_rpc_server::on_transfer(const wallet_rpc::COMMAND_RPC_TRANSFER::requ
return true;
}
//------------------------------------------------------------------------------------------------------------------------------
bool wallet_rpc_server::on_transfer_split(const wallet_rpc::COMMAND_RPC_TRANSFER_SPLIT::request& req, wallet_rpc::COMMAND_RPC_TRANSFER_SPLIT::response& res)
{
/*
std::vector<cryptonote::tx_destination_entry> dsts;
std::vector<uint8_t> extra;
if (!m_wallet) return not_open(er);
if (m_wallet->restricted())
{
er.code = WALLET_RPC_ERROR_CODE_DENIED;
er.message = "Command unavailable in restricted mode.";
return false;
}
// validate the transfer requested and populate dsts & extra; RPC_TRANSFER::request and RPC_TRANSFER_SPLIT::request are identical types.
if (!validate_transfer(req.destinations, req.payment_id, dsts, extra, er))
{
return false;
}
try
{
uint64_t mixin = adjust_mixin(req.mixin);
uint64_t ptx_amount;
std::vector<wallet2::pending_tx> ptx_vector;
LOG_PRINT_L2("on_transfer_split calling create_transactions_2");
ptx_vector = m_wallet->create_transactions_2(dsts, mixin, req.unlock_time, req.priority, extra, req.account_index, req.subaddr_indices, m_trusted_daemon);
LOG_PRINT_L2("on_transfer_split called create_transactions_2");
if (!req.do_not_relay)
{
LOG_PRINT_L2("on_transfer_split calling commit_tx");
m_wallet->commit_tx(ptx_vector);
LOG_PRINT_L2("on_transfer_split called commit_tx");
}
// populate response with tx hashes
for (auto & ptx : ptx_vector)
{
res.tx_hash_list.push_back(epee::string_tools::pod_to_hex(cryptonote::get_transaction_hash(ptx.tx)));
if (req.get_tx_keys)
{
res.tx_key_list.push_back(epee::string_tools::pod_to_hex(ptx.tx_key));
}
// Compute amount leaving wallet in tx. By convention dests does not include change outputs
ptx_amount = 0;
for (auto & dt : ptx.dests)
ptx_amount += dt.amount;
res.amount_list.push_back(ptx_amount);
res.fee_list.push_back(ptx.fee);
if (req.get_tx_hex)
{
cryptonote::blobdata blob;
tx_to_blob(ptx.tx, blob);
res.tx_blob_list.push_back(epee::string_tools::buff_to_hex_nodelimer(blob));
}
}
return true;
}
catch (const tools::error::daemon_busy& e)
{
er.code = WALLET_RPC_ERROR_CODE_DAEMON_IS_BUSY;
er.message = e.what();
return false;
}
catch (const std::exception& e)
{
er.code = WALLET_RPC_ERROR_CODE_GENERIC_TRANSFER_ERROR;
er.message = e.what();
return false;
}
catch (...)
{
er.code = WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR;
er.message = "WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR";
return false;
}
return true;
*/
}
//------------------------------------------------------------------------------------------------------------------------------
bool wallet_rpc_server::on_store(const wallet_rpc::COMMAND_RPC_STORE::request& req, wallet_rpc::COMMAND_RPC_STORE::response& res) {
try {
WalletHelper::storeWallet(m_wallet, m_walletFilename);
......
......@@ -58,6 +58,8 @@ namespace Tools
bool on_get_height(const wallet_rpc::COMMAND_RPC_GET_HEIGHT::request& req, wallet_rpc::COMMAND_RPC_GET_HEIGHT::response& res);
bool on_reset(const wallet_rpc::COMMAND_RPC_RESET::request& req, wallet_rpc::COMMAND_RPC_RESET::response& res);
bool on_transfer_split(const wallet_rpc::COMMAND_RPC_TRANSFER_SPLIT::request& req, wallet_rpc::COMMAND_RPC_TRANSFER_SPLIT::response& res);
bool handle_command_line(const boost::program_options::variables_map& vm);
Logging::LoggerRef logger;
......
......@@ -105,6 +105,63 @@ struct COMMAND_RPC_GET_ADDRESS
};
};
struct COMMAND_RPC_TRANSFER_SPLIT
{
struct request
{
std::list<transfer_destination> destinations;
uint32_t account_index;
std::set<uint32_t> subaddr_indices;
uint32_t priority;
uint64_t mixin;
uint64_t unlock_time;
std::string payment_id;
bool get_tx_keys;
bool do_not_relay;
bool get_tx_hex;
void serialize(ISerializer& s) {
KV_MEMBER(destinations)
KV_MEMBER(account_index)
KV_MEMBER(subaddr_indices)
KV_MEMBER(priority)
KV_MEMBER(mixin)
KV_MEMBER(unlock_time)
KV_MEMBER(payment_id)
KV_MEMBER(get_tx_keys)
KV_MEMBER(do_not_relay, false)
KV_MEMBER(get_tx_hex, false)
}
};
struct key_list
{
std::list<std::string> keys;
void serialize(ISerializer& s) {
KV_MEMBER(keys)
}
};
struct response
{
std::list<std::string> tx_hash_list;
std::list<std::string> tx_key_list;
std::list<uint64_t> amount_list;
std::list<uint64_t> fee_list;
std::list<std::string> tx_blob_list;
void serialize(ISerializer& s) {
KV_MEMBER(tx_hash_list)
KV_MEMBER(tx_key_list)
KV_MEMBER(amount_list)
KV_MEMBER(fee_list)
KV_MEMBER(tx_blob_list)
}
};
};
struct COMMAND_RPC_STORE
{
typedef CryptoNote::EMPTY_STRUCT request;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment