new json based sum_money_in_outputs started

This commit is contained in:
moneroexamples 2016-12-02 08:09:09 +08:00
parent a34ed83efe
commit 1fd68550d0
3 changed files with 29 additions and 0 deletions

View file

@ -690,6 +690,8 @@ public:
pair<uint64_t, uint64_t> sum_inputs = sum_xmr_inputs(_tx_info.tx_json);
pair<uint64_t, uint64_t> sum_outputs = sum_xmr_outputs(_tx_info.tx_json);
sum_money_in_outputs(_tx_info.tx_json);
// get mixin number in each transaction
vector<uint64_t> mixin_numbers = get_mixin_no_in_txs(_tx_info.tx_json);

View file

@ -306,7 +306,28 @@ sum_money_in_outputs(const transaction& tx)
return sum_xmr;
}
pair<uint64_t, uint64_t>
sum_money_in_outputs(const string& json_str)
{
pair<uint64_t, uint64_t> sum_xmr {0, 0};
cout << json_str << endl;
json j;
try
{
j = json::parse( json_str);
}
catch (std::invalid_argument& e)
{
cerr << "sum_money_in_outputs: " << e.what() << endl;
}
cout << j.dump() << endl;
return sum_xmr;
};
uint64_t
sum_money_in_inputs(const transaction& tx)

View file

@ -47,6 +47,7 @@ namespace pt = boost::posix_time;
namespace gt = boost::gregorian;
namespace lt = boost::local_time;
using json = nlohmann::json;
struct outputs_visitor
{
@ -126,12 +127,17 @@ get_blockchain_path(const boost::optional<string>& bc_path,
uint64_t
sum_money_in_outputs(const transaction& tx);
pair<uint64_t, uint64_t>
sum_money_in_outputs(const string& json_str);
uint64_t
sum_money_in_inputs(const transaction& tx);
array<uint64_t, 2>
sum_money_in_tx(const transaction& tx);
array<uint64_t, 2>
sum_money_in_txs(const vector<transaction>& txs);