aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRiccardo Spagni <ric@spagni.net>2019-04-06 16:01:44 +0200
committerRiccardo Spagni <ric@spagni.net>2019-04-06 16:01:44 +0200
commit18ceac9ca5849fa46bab066e5e7f1a384a3f8bcf (patch)
tree45967275bbd979d73f932840b632d6074cdc9a2d
parentMerge pull request #5350 (diff)
parentrpc.gettransactions: fill as_json with partial tx in pruned mode (diff)
downloadmonero-18ceac9ca5849fa46bab066e5e7f1a384a3f8bcf.tar.xz
Merge pull request #5351
a299dc96 rpc.gettransactions: fill as_json with partial tx in pruned mode (stoffu)
-rw-r--r--src/rpc/core_rpc_server.cpp55
1 files changed, 43 insertions, 12 deletions
diff --git a/src/rpc/core_rpc_server.cpp b/src/rpc/core_rpc_server.cpp
index f5f1a2f9a..2e7ef3e1b 100644
--- a/src/rpc/core_rpc_server.cpp
+++ b/src/rpc/core_rpc_server.cpp
@@ -646,30 +646,61 @@ namespace cryptonote
e.prunable_hash = epee::string_tools::pod_to_hex(std::get<2>(tx));
if (req.split || req.prune || std::get<3>(tx).empty())
{
+ // use splitted form with pruned and prunable (filled only when prune=false and the daemon has it), leaving as_hex as empty
e.pruned_as_hex = string_tools::buff_to_hex_nodelimer(std::get<1>(tx));
if (!req.prune)
e.prunable_as_hex = string_tools::buff_to_hex_nodelimer(std::get<3>(tx));
- }
- else
- {
- cryptonote::blobdata tx_data;
- if (req.prune)
- tx_data = std::get<1>(tx);
- else
- tx_data = std::get<1>(tx) + std::get<3>(tx);
- e.as_hex = string_tools::buff_to_hex_nodelimer(tx_data);
- if (req.decode_as_json && !tx_data.empty())
+ if (req.decode_as_json)
{
+ cryptonote::blobdata tx_data;
cryptonote::transaction t;
- if (cryptonote::parse_and_validate_tx_from_blob(tx_data, t))
+ if (req.prune || std::get<3>(tx).empty())
{
- if (req.prune)
+ // decode pruned tx to JSON
+ tx_data = std::get<1>(tx);
+ if (cryptonote::parse_and_validate_tx_base_from_blob(tx_data, t))
{
pruned_transaction pruned_tx{t};
e.as_json = obj_to_json_str(pruned_tx);
}
else
+ {
+ res.status = "Failed to parse and validate pruned tx from blob";
+ return true;
+ }
+ }
+ else
+ {
+ // decode full tx to JSON
+ tx_data = std::get<1>(tx) + std::get<3>(tx);
+ if (cryptonote::parse_and_validate_tx_from_blob(tx_data, t))
+ {
e.as_json = obj_to_json_str(t);
+ }
+ else
+ {
+ res.status = "Failed to parse and validate tx from blob";
+ return true;
+ }
+ }
+ }
+ }
+ else
+ {
+ // use non-splitted form, leaving pruned_as_hex and prunable_as_hex as empty
+ cryptonote::blobdata tx_data = std::get<1>(tx) + std::get<3>(tx);
+ e.as_hex = string_tools::buff_to_hex_nodelimer(tx_data);
+ if (req.decode_as_json)
+ {
+ cryptonote::transaction t;
+ if (cryptonote::parse_and_validate_tx_from_blob(tx_data, t))
+ {
+ e.as_json = obj_to_json_str(t);
+ }
+ else
+ {
+ res.status = "Failed to parse and validate tx from blob";
+ return true;
}
}
}