peerplays_migrated/libraries/plugins/peerplays_sidechain/ethereum/transaction.cpp

44 lines
1.1 KiB
C++
Raw Normal View History

2022-06-09 08:19:14 +00:00
#include <graphene/peerplays_sidechain/ethereum/transaction.hpp>
2022-08-04 10:06:53 +00:00
#include <boost/property_tree/json_parser.hpp>
#include <boost/property_tree/ptree.hpp>
2022-06-09 08:19:14 +00:00
namespace graphene { namespace peerplays_sidechain { namespace ethereum {
2022-08-04 10:06:53 +00:00
const transaction& transaction::sign(std::string private_key) const
{
/* v = "signed";
r = "transaction";
s = "signed-transaction";
2022-08-04 10:06:53 +00:00
return v + "|" + r + "|" + s;*/
return *this;
2022-06-09 08:19:14 +00:00
}
2022-08-04 10:06:53 +00:00
std::string transaction::serialize() const
{
boost::property_tree::ptree pt;
pt.put("from", from);
pt.put("to", to);
pt.put("data", data);
std::stringstream ss;
boost::property_tree::json_parser::write_json(ss, pt);
return ss.str();
2022-06-09 08:19:14 +00:00
}
2022-08-04 10:06:53 +00:00
void transaction::deserialize(std::string raw_tx)
{
std::stringstream ss_tx(raw_tx);
boost::property_tree::ptree tx_json;
boost::property_tree::read_json(ss_tx, tx_json);
if(tx_json.count("from"))
from = tx_json.get<std::string>("from");
if(tx_json.count("to"))
to = tx_json.get<std::string>("to");
if(tx_json.count("data"))
data = tx_json.get<std::string>("data");
2022-06-09 08:19:14 +00:00
}
}}} // namespace graphene::peerplays_sidechain::ethereum