wallet: transfer RPC can now return tx metadata (pending_tx)

This commit is contained in:
moneromooo-monero 2017-11-10 19:39:09 +00:00
parent 83fa9047d8
commit 01dc829784
No known key found for this signature in database
GPG key ID: 686F07454D6CEFC3
4 changed files with 100 additions and 3 deletions

View file

@ -30,6 +30,7 @@
#include <boost/format.hpp>
#include <boost/asio/ip/address.hpp>
#include <boost/filesystem/operations.hpp>
#include <boost/algorithm/string.hpp>
#include <cstdint>
#include "include_base_utils.h"
using namespace epee;
@ -635,6 +636,13 @@ namespace tools
tx_to_blob(ptx_vector.back().tx, blob);
res.tx_blob = epee::string_tools::buff_to_hex_nodelimer(blob);
}
if (req.get_tx_metadata)
{
std::ostringstream oss;
binary_archive<true> ar(oss);
::serialization::serialize(ar, ptx_vector.back());
res.tx_metadata = epee::string_tools::buff_to_hex_nodelimer(oss.str());
}
return true;
}
catch (const std::exception& e)
@ -682,7 +690,7 @@ namespace tools
}
// populate response with tx hashes
for (auto & ptx : ptx_vector)
for (const 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)
@ -705,6 +713,13 @@ namespace tools
tx_to_blob(ptx.tx, blob);
res.tx_blob_list.push_back(epee::string_tools::buff_to_hex_nodelimer(blob));
}
if (req.get_tx_metadata)
{
std::ostringstream oss;
binary_archive<true> ar(oss);
::serialization::serialize(ar, const_cast<tools::wallet2::pending_tx&>(ptx));
res.tx_metadata_list.push_back(epee::string_tools::buff_to_hex_nodelimer(oss.str()));
}
}
return true;
@ -735,7 +750,7 @@ namespace tools
m_wallet->commit_tx(ptx_vector);
// populate response with tx hashes
for (auto & ptx : ptx_vector)
for (const 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)
@ -749,6 +764,13 @@ namespace tools
tx_to_blob(ptx.tx, blob);
res.tx_blob_list.push_back(epee::string_tools::buff_to_hex_nodelimer(blob));
}
if (req.get_tx_metadata)
{
std::ostringstream oss;
binary_archive<true> ar(oss);
::serialization::serialize(ar, const_cast<tools::wallet2::pending_tx&>(ptx));
res.tx_metadata_list.push_back(epee::string_tools::buff_to_hex_nodelimer(oss.str()));
}
}
return true;
@ -793,7 +815,7 @@ namespace tools
m_wallet->commit_tx(ptx_vector);
// populate response with tx hashes
for (auto & ptx : ptx_vector)
for (const 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)
@ -806,6 +828,13 @@ namespace tools
tx_to_blob(ptx.tx, blob);
res.tx_blob_list.push_back(epee::string_tools::buff_to_hex_nodelimer(blob));
}
if (req.get_tx_metadata)
{
std::ostringstream oss;
binary_archive<true> ar(oss);
::serialization::serialize(ar, const_cast<tools::wallet2::pending_tx&>(ptx));
res.tx_metadata_list.push_back(epee::string_tools::buff_to_hex_nodelimer(oss.str()));
}
}
return true;
@ -889,6 +918,13 @@ namespace tools
tx_to_blob(ptx.tx, blob);
res.tx_blob = epee::string_tools::buff_to_hex_nodelimer(blob);
}
if (req.get_tx_metadata)
{
std::ostringstream oss;
binary_archive<true> ar(oss);
::serialization::serialize(ar, const_cast<tools::wallet2::pending_tx&>(ptx));
res.tx_metadata = epee::string_tools::buff_to_hex_nodelimer(oss.str());
}
return true;
}