mirror of
https://codeberg.org/anoncontributorxmr/monero.git
synced 2024-11-30 03:03:17 +00:00
rpc.gettransactions: fill as_json with partial tx in pruned mode
This commit is contained in:
parent
fe3403c8f0
commit
a299dc96f7
1 changed files with 43 additions and 12 deletions
|
@ -646,31 +646,62 @@ namespace cryptonote
|
||||||
e.prunable_hash = epee::string_tools::pod_to_hex(std::get<2>(tx));
|
e.prunable_hash = epee::string_tools::pod_to_hex(std::get<2>(tx));
|
||||||
if (req.split || req.prune || std::get<3>(tx).empty())
|
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));
|
e.pruned_as_hex = string_tools::buff_to_hex_nodelimer(std::get<1>(tx));
|
||||||
if (!req.prune)
|
if (!req.prune)
|
||||||
e.prunable_as_hex = string_tools::buff_to_hex_nodelimer(std::get<3>(tx));
|
e.prunable_as_hex = string_tools::buff_to_hex_nodelimer(std::get<3>(tx));
|
||||||
}
|
if (req.decode_as_json)
|
||||||
else
|
|
||||||
{
|
{
|
||||||
cryptonote::blobdata tx_data;
|
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())
|
|
||||||
{
|
|
||||||
cryptonote::transaction t;
|
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};
|
pruned_transaction pruned_tx{t};
|
||||||
e.as_json = obj_to_json_str(pruned_tx);
|
e.as_json = obj_to_json_str(pruned_tx);
|
||||||
}
|
}
|
||||||
else
|
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);
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
e.in_pool = pool_tx_hashes.find(tx_hash) != pool_tx_hashes.end();
|
e.in_pool = pool_tx_hashes.find(tx_hash) != pool_tx_hashes.end();
|
||||||
|
|
Loading…
Reference in a new issue