aboutsummaryrefslogtreecommitdiff
path: root/src/rpc
diff options
context:
space:
mode:
authorRiccardo Spagni <ric@spagni.net>2018-04-12 13:49:33 +0200
committerRiccardo Spagni <ric@spagni.net>2018-04-12 13:49:33 +0200
commit5e08fd89ea9cd36ad00b7f6ba17be75f27e5c57e (patch)
tree021dbac2b39076edf90a26c94f474460caa01c0d /src/rpc
parentMerge pull request #3609 (diff)
parentwallet2: request transactions in slices when scanning for known rings (diff)
downloadmonero-5e08fd89ea9cd36ad00b7f6ba17be75f27e5c57e.tar.xz
Merge pull request #3549
73951cbd wallet2: request transactions in slices when scanning for known rings (moneromooo-monero) 25fe67e4 rpc: allow getting pruned blocks from gettransactions (moneromooo-monero)
Diffstat (limited to 'src/rpc')
-rw-r--r--src/rpc/core_rpc_server.cpp20
-rw-r--r--src/rpc/core_rpc_server_commands_defs.h2
2 files changed, 14 insertions, 8 deletions
diff --git a/src/rpc/core_rpc_server.cpp b/src/rpc/core_rpc_server.cpp
index 69e527fd8..79792e387 100644
--- a/src/rpc/core_rpc_server.cpp
+++ b/src/rpc/core_rpc_server.cpp
@@ -209,6 +209,15 @@ namespace cryptonote
return true;
}
//------------------------------------------------------------------------------------------------------------------------------
+ static cryptonote::blobdata get_pruned_tx_blob(cryptonote::transaction &tx)
+ {
+ std::stringstream ss;
+ binary_archive<true> ba(ss);
+ bool r = tx.serialize_base(ba);
+ CHECK_AND_ASSERT_MES(r, cryptonote::blobdata(), "Failed to serialize rct signatures base");
+ return ss.str();
+ }
+ //------------------------------------------------------------------------------------------------------------------------------
static cryptonote::blobdata get_pruned_tx_blob(const cryptonote::blobdata &blobdata)
{
cryptonote::transaction tx;
@@ -216,14 +225,9 @@ namespace cryptonote
if (!cryptonote::parse_and_validate_tx_from_blob(blobdata, tx))
{
MERROR("Failed to parse and validate tx from blob");
- return blobdata;
+ return cryptonote::blobdata();
}
-
- std::stringstream ss;
- binary_archive<true> ba(ss);
- bool r = tx.serialize_base(ba);
- CHECK_AND_ASSERT_MES(r, blobdata, "Failed to serialize rct signatures base");
- return ss.str();
+ return get_pruned_tx_blob(tx);
}
//------------------------------------------------------------------------------------------------------------------------------
bool core_rpc_server::on_get_blocks(const COMMAND_RPC_GET_BLOCKS_FAST::request& req, COMMAND_RPC_GET_BLOCKS_FAST::response& res)
@@ -633,7 +637,7 @@ namespace cryptonote
crypto::hash tx_hash = *vhi++;
e.tx_hash = *txhi++;
- blobdata blob = t_serializable_object_to_blob(tx);
+ blobdata blob = req.prune ? get_pruned_tx_blob(tx) : t_serializable_object_to_blob(tx);
e.as_hex = string_tools::buff_to_hex_nodelimer(blob);
if (req.decode_as_json)
e.as_json = obj_to_json_str(tx);
diff --git a/src/rpc/core_rpc_server_commands_defs.h b/src/rpc/core_rpc_server_commands_defs.h
index 660fb7889..df5b4893f 100644
--- a/src/rpc/core_rpc_server_commands_defs.h
+++ b/src/rpc/core_rpc_server_commands_defs.h
@@ -563,10 +563,12 @@ namespace cryptonote
{
std::list<std::string> txs_hashes;
bool decode_as_json;
+ bool prune;
BEGIN_KV_SERIALIZE_MAP()
KV_SERIALIZE(txs_hashes)
KV_SERIALIZE(decode_as_json)
+ KV_SERIALIZE_OPT(prune, false)
END_KV_SERIALIZE_MAP()
};