From aa90f715fdb6395f6ea1e9086cb381a3005ff860 Mon Sep 17 00:00:00 2001 From: Vlad Dobromyslov Date: Sun, 30 Oct 2022 02:30:21 +0000 Subject: [PATCH] #467 - fix create_primary_wallet_transaction signers --- .../sidechain_net_handler_bitcoin.cpp | 5 ++++- .../sidechain_net_handler_ethereum.cpp | 21 ++++++++++++++++++- .../sidechain_net_handler_hive.cpp | 4 ++++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/libraries/plugins/peerplays_sidechain/sidechain_net_handler_bitcoin.cpp b/libraries/plugins/peerplays_sidechain/sidechain_net_handler_bitcoin.cpp index cace6fb3..a2dfa750 100644 --- a/libraries/plugins/peerplays_sidechain/sidechain_net_handler_bitcoin.cpp +++ b/libraries/plugins/peerplays_sidechain/sidechain_net_handler_bitcoin.cpp @@ -706,6 +706,10 @@ void sidechain_net_handler_bitcoin::process_primary_wallet() { const auto &active_sw = swi.rbegin(); if (active_sw != swi.rend()) { + const auto &prev_sw = std::next(active_sw); + if (prev_sw != swi.rend() && active_sw->sons.at(sidechain) == prev_sw->sons.at(sidechain)) + return; + if ((active_sw->addresses.find(sidechain) == active_sw->addresses.end()) || (active_sw->addresses.at(sidechain).empty())) { @@ -742,7 +746,6 @@ void sidechain_net_handler_bitcoin::process_primary_wallet() { proposal_op.proposed_ops.emplace_back(swu_op); - const auto &prev_sw = std::next(active_sw); if (prev_sw != swi.rend()) { std::string new_pw_address = active_pw_pt.get("result.address"); std::string tx_str = create_primary_wallet_transaction(*prev_sw, new_pw_address); diff --git a/libraries/plugins/peerplays_sidechain/sidechain_net_handler_ethereum.cpp b/libraries/plugins/peerplays_sidechain/sidechain_net_handler_ethereum.cpp index 066c9dd8..22b933ca 100644 --- a/libraries/plugins/peerplays_sidechain/sidechain_net_handler_ethereum.cpp +++ b/libraries/plugins/peerplays_sidechain/sidechain_net_handler_ethereum.cpp @@ -399,6 +399,10 @@ void sidechain_net_handler_ethereum::process_primary_wallet() { const auto &active_sw = swi.rbegin(); if (active_sw != swi.rend()) { + const auto &prev_sw = std::next(active_sw); + if (prev_sw != swi.rend() && active_sw->sons.at(sidechain) == prev_sw->sons.at(sidechain)) + return; + if ((active_sw->addresses.find(sidechain) == active_sw->addresses.end()) || (active_sw->addresses.at(sidechain).empty())) { @@ -423,6 +427,21 @@ void sidechain_net_handler_ethereum::process_primary_wallet() { swu_op.address = wallet_contract_address; proposal_op.proposed_ops.emplace_back(swu_op); + const auto signers = [this, &prev_sw, &active_sw, &swi] { + std::vector signers; + //! Check if we don't have any previous set of active SONs use the current one + if (prev_sw != swi.rend()) { + if (!prev_sw->sons.at(sidechain).empty()) + signers = prev_sw->sons.at(sidechain); + else + signers = active_sw->sons.at(sidechain); + } else { + signers = active_sw->sons.at(sidechain); + } + + return signers; + }(); + std::string tx_str = create_primary_wallet_transaction(gpo.active_sons.at(sidechain), active_sw->id.operator std::string()); if (!tx_str.empty()) { sidechain_transaction_create_operation stc_op; @@ -430,7 +449,7 @@ void sidechain_net_handler_ethereum::process_primary_wallet() { stc_op.object_id = active_sw->id; stc_op.sidechain = sidechain; stc_op.transaction = tx_str; - stc_op.signers = gpo.active_sons.at(sidechain); + stc_op.signers = signers; proposal_op.proposed_ops.emplace_back(stc_op); } diff --git a/libraries/plugins/peerplays_sidechain/sidechain_net_handler_hive.cpp b/libraries/plugins/peerplays_sidechain/sidechain_net_handler_hive.cpp index 7d3c4de9..a5d266fd 100644 --- a/libraries/plugins/peerplays_sidechain/sidechain_net_handler_hive.cpp +++ b/libraries/plugins/peerplays_sidechain/sidechain_net_handler_hive.cpp @@ -478,6 +478,10 @@ void sidechain_net_handler_hive::process_primary_wallet() { const auto &active_sw = swi.rbegin(); if (active_sw != swi.rend()) { + const auto &prev_sw = std::next(active_sw); + if (prev_sw != swi.rend() && active_sw->sons.at(sidechain) == prev_sw->sons.at(sidechain)) + return; + if ((active_sw->addresses.find(sidechain) == active_sw->addresses.end()) || (active_sw->addresses.at(sidechain).empty())) {