Skip to content

Commit

Permalink
new json based sum_money_in_outputs started
Browse files Browse the repository at this point in the history
  • Loading branch information
moneroexamples committed Dec 2, 2016
1 parent a34ed83 commit 1fd6855
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/page.h
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,8 @@ class page {
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);

Expand Down
21 changes: 21 additions & 0 deletions src/tools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions src/tools.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 1fd6855

Please sign in to comment.