Allow deposit from Hive to account with no registered sidechain address
This commit is contained in:
parent
e8238f1cb4
commit
acb1432509
6 changed files with 26 additions and 18 deletions
|
|
@ -4,7 +4,6 @@
|
||||||
|
|
||||||
#include <boost/program_options.hpp>
|
#include <boost/program_options.hpp>
|
||||||
|
|
||||||
#include <fc/signals.hpp>
|
|
||||||
#include <graphene/chain/proposal_object.hpp>
|
#include <graphene/chain/proposal_object.hpp>
|
||||||
#include <graphene/chain/sidechain_address_object.hpp>
|
#include <graphene/chain/sidechain_address_object.hpp>
|
||||||
#include <graphene/chain/sidechain_transaction_object.hpp>
|
#include <graphene/chain/sidechain_transaction_object.hpp>
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,14 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <graphene/peerplays_sidechain/bitcoin/bitcoin_address.hpp>
|
|
||||||
#include <graphene/peerplays_sidechain/sidechain_net_handler.hpp>
|
#include <graphene/peerplays_sidechain/sidechain_net_handler.hpp>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <zmq.hpp>
|
#include <zmq.hpp>
|
||||||
|
|
||||||
|
#include <boost/signals2.hpp>
|
||||||
|
|
||||||
#include <fc/network/http/connection.hpp>
|
#include <fc/network/http/connection.hpp>
|
||||||
#include <fc/signals.hpp>
|
#include <graphene/peerplays_sidechain/bitcoin/bitcoin_address.hpp>
|
||||||
|
|
||||||
namespace graphene { namespace peerplays_sidechain {
|
namespace graphene { namespace peerplays_sidechain {
|
||||||
|
|
||||||
|
|
@ -68,7 +69,7 @@ class zmq_listener {
|
||||||
public:
|
public:
|
||||||
zmq_listener(std::string _ip, uint32_t _zmq);
|
zmq_listener(std::string _ip, uint32_t _zmq);
|
||||||
|
|
||||||
fc::signal<void(const std::string &)> event_received;
|
boost::signals2::signal<void(const std::string &)> event_received;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void handle_zmq();
|
void handle_zmq();
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,9 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include <fc/network/http/connection.hpp>
|
#include <boost/signals2.hpp>
|
||||||
#include <fc/signals.hpp>
|
|
||||||
|
|
||||||
|
#include <fc/network/http/connection.hpp>
|
||||||
#include <graphene/peerplays_sidechain/common/rpc_client.hpp>
|
#include <graphene/peerplays_sidechain/common/rpc_client.hpp>
|
||||||
#include <graphene/peerplays_sidechain/hive/types.hpp>
|
#include <graphene/peerplays_sidechain/hive/types.hpp>
|
||||||
|
|
||||||
|
|
@ -57,13 +57,9 @@ private:
|
||||||
hive::chain_id_type chain_id;
|
hive::chain_id_type chain_id;
|
||||||
hive::network network_type;
|
hive::network network_type;
|
||||||
|
|
||||||
std::string create_primary_wallet_transaction(const son_wallet_object &prev_swo, std::string new_sw_address);
|
|
||||||
std::string create_deposit_transaction(const son_wallet_deposit_object &swdo);
|
|
||||||
std::string create_withdrawal_transaction(const son_wallet_withdraw_object &swwo);
|
|
||||||
|
|
||||||
uint64_t last_block_received;
|
uint64_t last_block_received;
|
||||||
fc::future<void> _listener_task;
|
fc::future<void> _listener_task;
|
||||||
fc::signal<void(const std::string &)> event_received;
|
boost::signals2::signal<void(const std::string &)> event_received;
|
||||||
void schedule_hive_listener();
|
void schedule_hive_listener();
|
||||||
void hive_listener_loop();
|
void hive_listener_loop();
|
||||||
void handle_event(const std::string &event_data);
|
void handle_event(const std::string &event_data);
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,6 @@
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include <fc/signals.hpp>
|
|
||||||
|
|
||||||
namespace graphene { namespace peerplays_sidechain {
|
namespace graphene { namespace peerplays_sidechain {
|
||||||
|
|
||||||
class sidechain_net_handler_peerplays : public sidechain_net_handler {
|
class sidechain_net_handler_peerplays : public sidechain_net_handler {
|
||||||
|
|
|
||||||
|
|
@ -415,7 +415,11 @@ void sidechain_net_handler::process_deposits() {
|
||||||
const auto &sidechain_addresses_idx = database.get_index_type<sidechain_address_index>().indices().get<by_sidechain_and_deposit_address_and_expires>();
|
const auto &sidechain_addresses_idx = database.get_index_type<sidechain_address_index>().indices().get<by_sidechain_and_deposit_address_and_expires>();
|
||||||
const auto &addr_itr = sidechain_addresses_idx.find(std::make_tuple(sidechain, swdo.sidechain_from, time_point_sec::maximum()));
|
const auto &addr_itr = sidechain_addresses_idx.find(std::make_tuple(sidechain, swdo.sidechain_from, time_point_sec::maximum()));
|
||||||
if (addr_itr == sidechain_addresses_idx.end()) {
|
if (addr_itr == sidechain_addresses_idx.end()) {
|
||||||
return;
|
const auto &account_idx = database.get_index_type<account_index>().indices().get<by_name>();
|
||||||
|
const auto &account_itr = account_idx.find(swdo.sidechain_from);
|
||||||
|
if (account_itr == account_idx.end()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ilog("Deposit to process: ${swdo}", ("swdo", swdo));
|
ilog("Deposit to process: ${swdo}", ("swdo", swdo));
|
||||||
|
|
|
||||||
|
|
@ -883,8 +883,18 @@ void sidechain_net_handler_hive::handle_event(const std::string &event_data) {
|
||||||
if (to == "son-account") {
|
if (to == "son-account") {
|
||||||
const auto &sidechain_addresses_idx = database.get_index_type<sidechain_address_index>().indices().get<by_sidechain_and_deposit_address_and_expires>();
|
const auto &sidechain_addresses_idx = database.get_index_type<sidechain_address_index>().indices().get<by_sidechain_and_deposit_address_and_expires>();
|
||||||
const auto &addr_itr = sidechain_addresses_idx.find(std::make_tuple(sidechain, from, time_point_sec::maximum()));
|
const auto &addr_itr = sidechain_addresses_idx.find(std::make_tuple(sidechain, from, time_point_sec::maximum()));
|
||||||
if (addr_itr == sidechain_addresses_idx.end())
|
account_id_type accn = account_id_type();
|
||||||
continue;
|
if (addr_itr == sidechain_addresses_idx.end()) {
|
||||||
|
const auto &account_idx = database.get_index_type<account_index>().indices().get<by_name>();
|
||||||
|
const auto &account_itr = account_idx.find(from);
|
||||||
|
if (account_itr == account_idx.end()) {
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
accn = account_itr->id;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
accn = addr_itr->sidechain_address_account;
|
||||||
|
}
|
||||||
|
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << "hive"
|
ss << "hive"
|
||||||
|
|
@ -894,14 +904,14 @@ void sidechain_net_handler_hive::handle_event(const std::string &event_data) {
|
||||||
sidechain_event_data sed;
|
sidechain_event_data sed;
|
||||||
sed.timestamp = database.head_block_time();
|
sed.timestamp = database.head_block_time();
|
||||||
sed.block_num = database.head_block_num();
|
sed.block_num = database.head_block_num();
|
||||||
sed.sidechain = addr_itr->sidechain;
|
sed.sidechain = sidechain;
|
||||||
sed.sidechain_uid = sidechain_uid;
|
sed.sidechain_uid = sidechain_uid;
|
||||||
sed.sidechain_transaction_id = transaction_id;
|
sed.sidechain_transaction_id = transaction_id;
|
||||||
sed.sidechain_from = from;
|
sed.sidechain_from = from;
|
||||||
sed.sidechain_to = to;
|
sed.sidechain_to = to;
|
||||||
sed.sidechain_currency = sidechain_currency;
|
sed.sidechain_currency = sidechain_currency;
|
||||||
sed.sidechain_amount = amount;
|
sed.sidechain_amount = amount;
|
||||||
sed.peerplays_from = addr_itr->sidechain_address_account;
|
sed.peerplays_from = accn;
|
||||||
sed.peerplays_to = database.get_global_properties().parameters.son_account();
|
sed.peerplays_to = database.get_global_properties().parameters.son_account();
|
||||||
sed.peerplays_asset = asset(sed.sidechain_amount * sidechain_currency_price.base.amount / sidechain_currency_price.quote.amount);
|
sed.peerplays_asset = asset(sed.sidechain_amount * sidechain_currency_price.base.amount / sidechain_currency_price.quote.amount);
|
||||||
sidechain_event_data_received(sed);
|
sidechain_event_data_received(sed);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue