Fix transaction verification
This commit is contained in:
parent
2d079cacf6
commit
bc25f6d20d
1 changed files with 31 additions and 23 deletions
|
|
@ -17,7 +17,8 @@
|
||||||
#include <graphene/chain/son_info.hpp>
|
#include <graphene/chain/son_info.hpp>
|
||||||
#include <graphene/chain/son_wallet_object.hpp>
|
#include <graphene/chain/son_wallet_object.hpp>
|
||||||
|
|
||||||
namespace graphene { namespace peerplays_sidechain {
|
namespace graphene {
|
||||||
|
namespace peerplays_sidechain {
|
||||||
|
|
||||||
// =============================================================================
|
// =============================================================================
|
||||||
|
|
||||||
|
|
@ -46,7 +47,7 @@ std::string bitcoin_rpc_client::addmultisigaddress(const uint32_t nrequired, con
|
||||||
params = params + pubkeys + std::string("]");
|
params = params + pubkeys + std::string("]");
|
||||||
body = body + params + std::string(", null, \"p2sh-segwit\"] }");
|
body = body + params + std::string(", null, \"p2sh-segwit\"] }");
|
||||||
|
|
||||||
const auto reply = send_post_request(body, true);
|
const auto reply = send_post_request(body);
|
||||||
|
|
||||||
if (reply.body.empty()) {
|
if (reply.body.empty()) {
|
||||||
wlog("Bitcoin RPC call ${function} failed", ("function", __FUNCTION__));
|
wlog("Bitcoin RPC call ${function} failed", ("function", __FUNCTION__));
|
||||||
|
|
@ -115,7 +116,7 @@ std::string bitcoin_rpc_client::createmultisig(const uint32_t nrequired, const s
|
||||||
params = params + pubkeys + std::string("]");
|
params = params + pubkeys + std::string("]");
|
||||||
body = body + params + std::string(", \"p2sh-segwit\" ] }");
|
body = body + params + std::string(", \"p2sh-segwit\" ] }");
|
||||||
|
|
||||||
const auto reply = send_post_request(body, true);
|
const auto reply = send_post_request(body);
|
||||||
|
|
||||||
if (reply.body.empty()) {
|
if (reply.body.empty()) {
|
||||||
wlog("Bitcoin RPC call ${function} failed", ("function", __FUNCTION__));
|
wlog("Bitcoin RPC call ${function} failed", ("function", __FUNCTION__));
|
||||||
|
|
@ -341,7 +342,7 @@ uint64_t bitcoin_rpc_client::estimatesmartfee(uint16_t conf_target) {
|
||||||
"\"method\": \"estimatesmartfee\", \"params\": [" +
|
"\"method\": \"estimatesmartfee\", \"params\": [" +
|
||||||
std::to_string(conf_target) + std::string("] }"));
|
std::to_string(conf_target) + std::string("] }"));
|
||||||
|
|
||||||
const auto reply = send_post_request(body, true);
|
const auto reply = send_post_request(body);
|
||||||
|
|
||||||
if (reply.body.empty()) {
|
if (reply.body.empty()) {
|
||||||
wlog("Bitcoin RPC call ${function} failed", ("function", __FUNCTION__));
|
wlog("Bitcoin RPC call ${function} failed", ("function", __FUNCTION__));
|
||||||
|
|
@ -460,7 +461,7 @@ std::string bitcoin_rpc_client::gettransaction(const std::string &txid, const bo
|
||||||
"\"gettransaction\", \"params\": [\"" +
|
"\"gettransaction\", \"params\": [\"" +
|
||||||
txid + "\"] }");
|
txid + "\"] }");
|
||||||
|
|
||||||
const auto reply = send_post_request(body, true);
|
const auto reply = send_post_request(body);
|
||||||
|
|
||||||
if (reply.body.empty()) {
|
if (reply.body.empty()) {
|
||||||
wlog("Bitcoin RPC call ${function} failed", ("function", __FUNCTION__));
|
wlog("Bitcoin RPC call ${function} failed", ("function", __FUNCTION__));
|
||||||
|
|
@ -928,12 +929,14 @@ bool sidechain_net_handler_bitcoin::process_proposal(const proposal_object &po)
|
||||||
switch (op_idx_0) {
|
switch (op_idx_0) {
|
||||||
|
|
||||||
case chain::operation::tag<chain::son_wallet_update_operation>::value: {
|
case chain::operation::tag<chain::son_wallet_update_operation>::value: {
|
||||||
|
|
||||||
bool address_ok = false;
|
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;
|
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 &idx = database.get_index_type<son_wallet_index>().indices().get<by_id>();
|
||||||
const auto swo = idx.find(swo_id);
|
const auto swo = idx.find(swo_id);
|
||||||
if (swo != idx.end()) {
|
if (swo != idx.end()) {
|
||||||
|
|
||||||
auto active_sons = gpo.active_sons;
|
auto active_sons = gpo.active_sons;
|
||||||
vector<son_info> wallet_sons = swo->sons;
|
vector<son_info> wallet_sons = swo->sons;
|
||||||
|
|
||||||
|
|
@ -961,13 +964,13 @@ bool sidechain_net_handler_bitcoin::process_proposal(const proposal_object &po)
|
||||||
if (active_pw_pt.count("error") && active_pw_pt.get_child("error").empty()) {
|
if (active_pw_pt.count("error") && active_pw_pt.get_child("error").empty()) {
|
||||||
std::stringstream res;
|
std::stringstream res;
|
||||||
boost::property_tree::json_parser::write_json(res, active_pw_pt.get_child("result"));
|
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());
|
address_ok = (op_obj_idx_0.get<son_wallet_update_operation>().address == res.str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
bool transaction_ok = false;
|
if (po.proposed_transaction.operations.size() >= 2) {
|
||||||
object_id_type object_id = op_obj_idx_1.get<sidechain_transaction_create_operation>().object_id;
|
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;
|
std::string op_tx_str = op_obj_idx_1.get<sidechain_transaction_create_operation>().transaction;
|
||||||
|
|
||||||
|
|
@ -981,12 +984,17 @@ bool sidechain_net_handler_bitcoin::process_proposal(const proposal_object &po)
|
||||||
const auto &idx = database.get_index_type<son_wallet_index>().indices().get<by_id>();
|
const auto &idx = database.get_index_type<son_wallet_index>().indices().get<by_id>();
|
||||||
const auto swo = idx.find(object_id);
|
const auto swo = idx.find(object_id);
|
||||||
if (swo != idx.end()) {
|
if (swo != idx.end()) {
|
||||||
tx_str = op_tx_str; //create_primary_wallet_transaction();
|
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);
|
transaction_ok = (op_tx_str == tx_str);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
transaction_ok = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
should_approve = address_ok &&
|
should_approve = address_ok &&
|
||||||
transaction_ok;
|
transaction_ok;
|
||||||
|
|
@ -1803,5 +1811,5 @@ void sidechain_net_handler_bitcoin::on_changed_objects_cb(const vector<object_id
|
||||||
}
|
}
|
||||||
|
|
||||||
// =============================================================================
|
// =============================================================================
|
||||||
|
}
|
||||||
}} // namespace graphene::peerplays_sidechain
|
} // namespace graphene::peerplays_sidechain
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue