xmreg::make_tx_from_json started

master
moneroexamples 8 years ago
parent 66caaea4dd
commit df57d2b203

@ -4016,9 +4016,34 @@ private:
} }
else else
{ {
// @TODO make tx_info from json // if dont have tx_blob member, construct tx
// if dont have tx_blob member, construct tx_info
// from json obtained from the rpc call // from json obtained from the rpc call
for (size_t i = 0; i < mempool_txs.size(); ++i)
{
// get transaction info of the tx in the mempool
tx_info _tx_info = mempool_txs.at(i);
crypto::hash mem_tx_hash = null_hash;
if (hex_to_pod(_tx_info.id_hash, mem_tx_hash))
{
// @TODO need to make this tx from _tx_info.tx_json
transaction tx;
if (!xmreg::make_tx_from_json(_tx_info.tx_json, tx))
{
cerr << "Cant make tx from _tx_info.tx_json" << endl;
continue;
}
if (tx_hash == mem_tx_hash)
{
found_txs.push_back(make_pair(_tx_info, tx));
break;
}
}
}
} }
return found_txs; return found_txs;

@ -101,6 +101,7 @@ namespace xmreg
return false; return false;
} }
mempool_txs = res.transactions; mempool_txs = res.transactions;
return true; return true;

@ -1013,5 +1013,25 @@ get_real_output_for_key_image(const key_image& ki,
return false; return false;
} }
bool
make_tx_from_json(const string& json_str, transaction& tx)
{
json j;
try
{
j = json::parse(json_str);
}
catch (std::invalid_argument& e)
{
cerr << "make_tx_from_json: cant parse json string: " << e.what() << endl;
return false;
}
return true;
}
} }

@ -275,6 +275,9 @@ get_real_output_for_key_image(const key_image& ki,
uint64_t output_idx, uint64_t output_idx,
public_key output_pub_key); public_key output_pub_key);
bool
make_tx_from_json(const string& json_str, transaction& tx);
} }
#endif //XMREG01_TOOLS_H #endif //XMREG01_TOOLS_H

Loading…
Cancel
Save