Fix transaction verification

This commit is contained in:
Srdjan Obucina 2020-04-14 07:27:18 +02:00
parent 4507601992
commit 703a13dab4

View file

@ -928,12 +928,14 @@ bool sidechain_net_handler_bitcoin::process_proposal(const proposal_object &po)
switch (op_idx_0) {
case chain::operation::tag<chain::son_wallet_update_operation>::value: {
bool address_ok = false;
bool transaction_ok = false;
std::string new_pw_address = "";
son_wallet_id_type swo_id = op_obj_idx_0.get<son_wallet_update_operation>().son_wallet_id;
const auto &idx = database.get_index_type<son_wallet_index>().indices().get<by_id>();
const auto swo = idx.find(swo_id);
if (swo != idx.end()) {
auto active_sons = gpo.active_sons;
vector<son_info> wallet_sons = swo->sons;
@ -961,31 +963,36 @@ bool sidechain_net_handler_bitcoin::process_proposal(const proposal_object &po)
if (active_pw_pt.count("error") && active_pw_pt.get_child("error").empty()) {
std::stringstream res;
boost::property_tree::json_parser::write_json(res, active_pw_pt.get_child("result"));
new_pw_address = active_pw_pt.get<std::string>("result.address");
address_ok = (op_obj_idx_0.get<son_wallet_update_operation>().address == res.str());
}
}
}
bool transaction_ok = false;
object_id_type object_id = op_obj_idx_1.get<sidechain_transaction_create_operation>().object_id;
std::string op_tx_str = op_obj_idx_1.get<sidechain_transaction_create_operation>().transaction;
if (po.proposed_transaction.operations.size() >= 2) {
object_id_type object_id = op_obj_idx_1.get<sidechain_transaction_create_operation>().object_id;
std::string op_tx_str = op_obj_idx_1.get<sidechain_transaction_create_operation>().transaction;
const auto &st_idx = database.get_index_type<sidechain_transaction_index>().indices().get<by_object_id>();
const auto st = st_idx.find(object_id);
if (st == st_idx.end()) {
const auto &st_idx = database.get_index_type<sidechain_transaction_index>().indices().get<by_object_id>();
const auto st = st_idx.find(object_id);
if (st == st_idx.end()) {
std::string tx_str = "";
std::string tx_str = "";
if (object_id.is<son_wallet_id_type>()) {
const auto &idx = database.get_index_type<son_wallet_index>().indices().get<by_id>();
const auto swo = idx.find(object_id);
if (swo != idx.end()) {
tx_str = op_tx_str; //create_primary_wallet_transaction();
if (object_id.is<son_wallet_id_type>()) {
const auto &idx = database.get_index_type<son_wallet_index>().indices().get<by_id>();
const auto swo = idx.find(object_id);
if (swo != idx.end()) {
const auto prec_swo = std::next(swo);
tx_str = create_primary_wallet_transaction(*prec_swo, new_pw_address);
}
}
transaction_ok = (op_tx_str == tx_str);
}
} else {
transaction_ok = true;
}
transaction_ok = (op_tx_str == tx_str);
}
should_approve = address_ok &&