43 lines
1.1 KiB
C++
43 lines
1.1 KiB
C++
#include <graphene/peerplays_sidechain/ethereum/transaction.hpp>
|
|
|
|
#include <boost/property_tree/json_parser.hpp>
|
|
#include <boost/property_tree/ptree.hpp>
|
|
|
|
namespace graphene { namespace peerplays_sidechain { namespace ethereum {
|
|
|
|
const transaction& transaction::sign(std::string private_key) const
|
|
{
|
|
/* v = "signed";
|
|
r = "transaction";
|
|
s = "signed-transaction";
|
|
return v + "|" + r + "|" + s;*/
|
|
return *this;
|
|
}
|
|
|
|
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();
|
|
}
|
|
|
|
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");
|
|
}
|
|
|
|
}}} // namespace graphene::peerplays_sidechain::ethereum
|