aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2017-11-10 19:39:09 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2017-11-24 14:03:52 +0000
commit01dc8297847bea646f744f9d777663526f90a94a (patch)
treeb22602c202b404dfa20a979e328d3db182688d79 /src
parentserialization: add std::set and std::unordered_set serialization (diff)
downloadmonero-01dc8297847bea646f744f9d777663526f90a94a.tar.xz
wallet: transfer RPC can now return tx metadata (pending_tx)
Diffstat (limited to 'src')
-rw-r--r--src/cryptonote_core/cryptonote_tx_utils.h14
-rw-r--r--src/wallet/wallet2.h27
-rw-r--r--src/wallet/wallet_rpc_server.cpp42
-rw-r--r--src/wallet/wallet_rpc_server_commands_defs.h20
4 files changed, 100 insertions, 3 deletions
diff --git a/src/cryptonote_core/cryptonote_tx_utils.h b/src/cryptonote_core/cryptonote_tx_utils.h
index 9a3b2484d..8d9a1e332 100644
--- a/src/cryptonote_core/cryptonote_tx_utils.h
+++ b/src/cryptonote_core/cryptonote_tx_utils.h
@@ -53,6 +53,20 @@ namespace cryptonote
rct::key mask; //ringct amount mask
void push_output(uint64_t idx, const crypto::public_key &k, uint64_t amount) { outputs.push_back(std::make_pair(idx, rct::ctkey({rct::pk2rct(k), rct::zeroCommit(amount)}))); }
+
+ BEGIN_SERIALIZE_OBJECT()
+ FIELD(outputs)
+ FIELD(real_output)
+ FIELD(real_out_tx_key)
+ FIELD(real_out_additional_tx_keys)
+ FIELD(real_output_in_tx_index)
+ FIELD(amount)
+ FIELD(rct)
+ FIELD(mask)
+
+ if (real_output >= outputs.size())
+ return false;
+ END_SERIALIZE()
};
struct tx_destination_entry
diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h
index cff10fa11..ed224136d 100644
--- a/src/wallet/wallet2.h
+++ b/src/wallet/wallet2.h
@@ -292,6 +292,19 @@ namespace tools
std::vector<cryptonote::tx_destination_entry> dests; // original setup, does not include change
uint32_t subaddr_account; // subaddress account of your wallet to be used in this transfer
std::set<uint32_t> subaddr_indices; // set of address indices used as inputs in this transfer
+
+ BEGIN_SERIALIZE_OBJECT()
+ FIELD(sources)
+ FIELD(change_dts)
+ FIELD(splitted_dsts)
+ FIELD(selected_transfers)
+ FIELD(extra)
+ FIELD(unlock_time)
+ FIELD(use_rct)
+ FIELD(dests)
+ FIELD(subaddr_account)
+ FIELD(subaddr_indices)
+ END_SERIALIZE()
};
typedef std::vector<transfer_details> transfer_container;
@@ -313,6 +326,20 @@ namespace tools
std::vector<cryptonote::tx_destination_entry> dests;
tx_construction_data construction_data;
+
+ BEGIN_SERIALIZE_OBJECT()
+ FIELD(tx)
+ FIELD(dust)
+ FIELD(fee)
+ FIELD(dust_added_to_fee)
+ FIELD(change_dts)
+ FIELD(selected_transfers)
+ FIELD(key_images)
+ FIELD(tx_key)
+ FIELD(additional_tx_keys)
+ FIELD(dests)
+ FIELD(construction_data)
+ END_SERIALIZE()
};
// The term "Unsigned tx" is not really a tx since it's not signed yet.
diff --git a/src/wallet/wallet_rpc_server.cpp b/src/wallet/wallet_rpc_server.cpp
index cf404543c..af7f2cedf 100644
--- a/src/wallet/wallet_rpc_server.cpp
+++ b/src/wallet/wallet_rpc_server.cpp
@@ -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;
}
diff --git a/src/wallet/wallet_rpc_server_commands_defs.h b/src/wallet/wallet_rpc_server_commands_defs.h
index 2e7c7c76f..97a6c9758 100644
--- a/src/wallet/wallet_rpc_server_commands_defs.h
+++ b/src/wallet/wallet_rpc_server_commands_defs.h
@@ -291,6 +291,7 @@ namespace wallet_rpc
bool get_tx_key;
bool do_not_relay;
bool get_tx_hex;
+ bool get_tx_metadata;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(destinations)
@@ -303,6 +304,7 @@ namespace wallet_rpc
KV_SERIALIZE(get_tx_key)
KV_SERIALIZE_OPT(do_not_relay, false)
KV_SERIALIZE_OPT(get_tx_hex, false)
+ KV_SERIALIZE_OPT(get_tx_metadata, false)
END_KV_SERIALIZE_MAP()
};
@@ -313,6 +315,7 @@ namespace wallet_rpc
std::list<std::string> amount_keys;
uint64_t fee;
std::string tx_blob;
+ std::string tx_metadata;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(tx_hash)
@@ -320,6 +323,7 @@ namespace wallet_rpc
KV_SERIALIZE(amount_keys)
KV_SERIALIZE(fee)
KV_SERIALIZE(tx_blob)
+ KV_SERIALIZE(tx_metadata)
END_KV_SERIALIZE_MAP()
};
};
@@ -338,6 +342,7 @@ namespace wallet_rpc
bool get_tx_keys;
bool do_not_relay;
bool get_tx_hex;
+ bool get_tx_metadata;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(destinations)
@@ -350,6 +355,7 @@ namespace wallet_rpc
KV_SERIALIZE(get_tx_keys)
KV_SERIALIZE_OPT(do_not_relay, false)
KV_SERIALIZE_OPT(get_tx_hex, false)
+ KV_SERIALIZE_OPT(get_tx_metadata, false)
END_KV_SERIALIZE_MAP()
};
@@ -369,6 +375,7 @@ namespace wallet_rpc
std::list<uint64_t> amount_list;
std::list<uint64_t> fee_list;
std::list<std::string> tx_blob_list;
+ std::list<std::string> tx_metadata_list;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(tx_hash_list)
@@ -376,6 +383,7 @@ namespace wallet_rpc
KV_SERIALIZE(amount_list)
KV_SERIALIZE(fee_list)
KV_SERIALIZE(tx_blob_list)
+ KV_SERIALIZE(tx_metadata_list)
END_KV_SERIALIZE_MAP()
};
};
@@ -387,11 +395,13 @@ namespace wallet_rpc
bool get_tx_keys;
bool do_not_relay;
bool get_tx_hex;
+ bool get_tx_metadata;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(get_tx_keys)
KV_SERIALIZE_OPT(do_not_relay, false)
KV_SERIALIZE_OPT(get_tx_hex, false)
+ KV_SERIALIZE_OPT(get_tx_metadata, false)
END_KV_SERIALIZE_MAP()
};
@@ -410,12 +420,14 @@ namespace wallet_rpc
std::list<std::string> tx_key_list;
std::list<uint64_t> fee_list;
std::list<std::string> tx_blob_list;
+ std::list<std::string> tx_metadata_list;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(tx_hash_list)
KV_SERIALIZE(tx_key_list)
KV_SERIALIZE(fee_list)
KV_SERIALIZE(tx_blob_list)
+ KV_SERIALIZE(tx_metadata_list)
END_KV_SERIALIZE_MAP()
};
};
@@ -435,6 +447,7 @@ namespace wallet_rpc
uint64_t below_amount;
bool do_not_relay;
bool get_tx_hex;
+ bool get_tx_metadata;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(address)
@@ -448,6 +461,7 @@ namespace wallet_rpc
KV_SERIALIZE(below_amount)
KV_SERIALIZE_OPT(do_not_relay, false)
KV_SERIALIZE_OPT(get_tx_hex, false)
+ KV_SERIALIZE_OPT(get_tx_metadata, false)
END_KV_SERIALIZE_MAP()
};
@@ -466,12 +480,14 @@ namespace wallet_rpc
std::list<std::string> tx_key_list;
std::list<uint64_t> fee_list;
std::list<std::string> tx_blob_list;
+ std::list<std::string> tx_metadata_list;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(tx_hash_list)
KV_SERIALIZE(tx_key_list)
KV_SERIALIZE(fee_list)
KV_SERIALIZE(tx_blob_list)
+ KV_SERIALIZE(tx_metadata_list)
END_KV_SERIALIZE_MAP()
};
};
@@ -489,6 +505,7 @@ namespace wallet_rpc
std::string key_image;
bool do_not_relay;
bool get_tx_hex;
+ bool get_tx_metadata;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(address)
@@ -500,6 +517,7 @@ namespace wallet_rpc
KV_SERIALIZE(key_image)
KV_SERIALIZE_OPT(do_not_relay, false)
KV_SERIALIZE_OPT(get_tx_hex, false)
+ KV_SERIALIZE_OPT(get_tx_metadata, false)
END_KV_SERIALIZE_MAP()
};
@@ -509,12 +527,14 @@ namespace wallet_rpc
std::string tx_key;
uint64_t fee;
std::string tx_blob;
+ std::string tx_metadata;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(tx_hash)
KV_SERIALIZE(tx_key)
KV_SERIALIZE(fee)
KV_SERIALIZE(tx_blob)
+ KV_SERIALIZE(tx_metadata)
END_KV_SERIALIZE_MAP()
};
};