mirror of
https://github.com/monero-project/monero.git
synced 2024-11-18 10:01:02 +00:00
cn_deserialize: check for raw tx_extra
This commit is contained in:
parent
6ed314854c
commit
30ce8c5926
1 changed files with 22 additions and 12 deletions
|
@ -41,6 +41,22 @@ using namespace epee;
|
||||||
|
|
||||||
using namespace cryptonote;
|
using namespace cryptonote;
|
||||||
|
|
||||||
|
static void print_extra_fields(const std::vector<cryptonote::tx_extra_field> &fields)
|
||||||
|
{
|
||||||
|
std::cout << "tx_extra has " << fields.size() << " field(s)" << std::endl;
|
||||||
|
for (size_t n = 0; n < fields.size(); ++n)
|
||||||
|
{
|
||||||
|
std::cout << "field " << n << ": ";
|
||||||
|
if (typeid(cryptonote::tx_extra_padding) == fields[n].type()) std::cout << "extra padding: " << boost::get<cryptonote::tx_extra_padding>(fields[n]).size << " bytes";
|
||||||
|
else if (typeid(cryptonote::tx_extra_pub_key) == fields[n].type()) std::cout << "extra pub key: " << boost::get<cryptonote::tx_extra_pub_key>(fields[n]).pub_key;
|
||||||
|
else if (typeid(cryptonote::tx_extra_nonce) == fields[n].type()) std::cout << "extra nonce: " << epee::string_tools::buff_to_hex_nodelimer(boost::get<cryptonote::tx_extra_nonce>(fields[n]).nonce);
|
||||||
|
else if (typeid(cryptonote::tx_extra_merge_mining_tag) == fields[n].type()) std::cout << "extra merge mining tag: depth " << boost::get<cryptonote::tx_extra_merge_mining_tag>(fields[n]).depth << ", merkle root " << boost::get<cryptonote::tx_extra_merge_mining_tag>(fields[n]).merkle_root;
|
||||||
|
else if (typeid(cryptonote::tx_extra_mysterious_minergate) == fields[n].type()) std::cout << "extra minergate custom: " << epee::string_tools::buff_to_hex_nodelimer(boost::get<cryptonote::tx_extra_mysterious_minergate>(fields[n]).data);
|
||||||
|
else std::cout << "unknown";
|
||||||
|
std::cout << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
uint32_t log_level = 0;
|
uint32_t log_level = 0;
|
||||||
|
@ -160,24 +176,18 @@ int main(int argc, char* argv[])
|
||||||
|
|
||||||
if (!fields.empty())
|
if (!fields.empty())
|
||||||
{
|
{
|
||||||
std::cout << "tx_extra has " << fields.size() << " field(s)" << std::endl;
|
print_extra_fields(fields);
|
||||||
for (size_t n = 0; n < fields.size(); ++n)
|
|
||||||
{
|
|
||||||
std::cout << "field " << n << ": ";
|
|
||||||
if (typeid(cryptonote::tx_extra_padding) == fields[n].type()) std::cout << "extra padding: " << boost::get<cryptonote::tx_extra_padding>(fields[n]).size << " bytes";
|
|
||||||
else if (typeid(cryptonote::tx_extra_pub_key) == fields[n].type()) std::cout << "extra pub key: " << boost::get<cryptonote::tx_extra_pub_key>(fields[n]).pub_key;
|
|
||||||
else if (typeid(cryptonote::tx_extra_nonce) == fields[n].type()) std::cout << "extra nonce: " << epee::string_tools::buff_to_hex_nodelimer(boost::get<cryptonote::tx_extra_nonce>(fields[n]).nonce);
|
|
||||||
else if (typeid(cryptonote::tx_extra_merge_mining_tag) == fields[n].type()) std::cout << "extra merge mining tag: depth " << boost::get<cryptonote::tx_extra_merge_mining_tag>(fields[n]).depth << ", merkle root " << boost::get<cryptonote::tx_extra_merge_mining_tag>(fields[n]).merkle_root;
|
|
||||||
else if (typeid(cryptonote::tx_extra_mysterious_minergate) == fields[n].type()) std::cout << "extra minergate custom: " << epee::string_tools::buff_to_hex_nodelimer(boost::get<cryptonote::tx_extra_mysterious_minergate>(fields[n]).data);
|
|
||||||
else std::cout << "unknown";
|
|
||||||
std::cout << std::endl;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::cout << "No fields were found in tx_extra" << std::endl;
|
std::cout << "No fields were found in tx_extra" << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (cryptonote::parse_tx_extra(std::vector<uint8_t>(blob.begin(), blob.end()), fields) && !fields.empty())
|
||||||
|
{
|
||||||
|
std::cout << "Parsed tx_extra:" << std::endl;
|
||||||
|
print_extra_fields(fields);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::cerr << "Not a recognized CN type" << std::endl;
|
std::cerr << "Not a recognized CN type" << std::endl;
|
||||||
|
|
Loading…
Reference in a new issue