Skip to content

Commit

Permalink
add parse_trx
Browse files Browse the repository at this point in the history
  • Loading branch information
sinev-valentine committed Mar 15, 2019
1 parent 17b6246 commit 10f74f2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions keychain_lib/include/keychain_lib/keychain_commands.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ enum struct sign_te {
fc_light::variant create_secmod_signhex_cmd(const std::vector<unsigned char>& raw, blockchain_te blockchain, std::string from, int unlock_time, const std::string& keyname, bool no_password);
fc_light::variant create_secmod_signhash_cmd(const std::string& raw, std::string from, const std::string& keyname, bool no_password);
fc_light::variant create_secmod_unlock_cmd(const std::string& keyname, int unlock_time, bool no_password);
std::string parse_trx(std::string&);

class streambuf_derived : public std::basic_streambuf<char>
{
Expand Down
14 changes: 14 additions & 0 deletions keychain_lib/src/keychain_commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,20 @@ dev::Secret keychain_base::get_private_key(const dev::Public& public_key, int un
return result_secret;
}

std::string parse_trx(std::string& trx)
{
namespace sm_cmd = keychain_app::secmod_commands;
std::vector<unsigned char> raw(trx.length());
auto res = keychain_app::from_hex(trx, raw.data(), raw.size());
raw.resize(res);

auto cmd = create_secmod_signhex_cmd(raw, blockchain_te::ethereum, "", 0, "", false);
auto params = cmd.as<secmod_commands::secmod_command>().params;
auto sing_trx_params = params.as<sm_cmd::secmod_event<secmod_commands::events_te::sign_trx>::params_t>();
auto trx_view = sing_trx_params.trx_view;
return fc_light::json::to_pretty_string(trx_view);
}

}

using namespace keychain_app;
Expand Down

0 comments on commit 10f74f2

Please sign in to comment.