Use BTC asset for deposits and withdraws
This commit is contained in:
parent
5bf245ee6c
commit
981049ccd0
3 changed files with 10 additions and 6 deletions
|
|
@ -68,7 +68,7 @@ void sidechain_net_handler::sidechain_event_data_received(const sidechain_event_
|
|||
const chain::global_property_object &gpo = database.get_global_properties();
|
||||
|
||||
// Deposit request
|
||||
if ((sed.peerplays_to == gpo.parameters.son_account()) && (sed.sidechain_currency.compare("1.3.0") != 0)) {
|
||||
if ((sed.peerplays_to == gpo.parameters.son_account()) && (sed.sidechain == sidechain_type::bitcoin)) {
|
||||
|
||||
for (son_id_type son_id : plugin.get_sons()) {
|
||||
if (plugin.is_active_son(son_id)) {
|
||||
|
|
@ -102,7 +102,7 @@ void sidechain_net_handler::sidechain_event_data_received(const sidechain_event_
|
|||
}
|
||||
|
||||
// Withdrawal request
|
||||
if ((sed.peerplays_to == gpo.parameters.son_account()) && (sed.sidechain_currency.compare("1.3.0") == 0)) {
|
||||
if ((sed.peerplays_to == gpo.parameters.son_account()) && (sed.sidechain == sidechain_type::peerplays)) {
|
||||
// BTC Payout only (for now)
|
||||
const auto &sidechain_addresses_idx = database.get_index_type<sidechain_address_index>().indices().get<by_account_and_sidechain>();
|
||||
const auto &addr_itr = sidechain_addresses_idx.find(std::make_tuple(sed.peerplays_from, sidechain_type::bitcoin));
|
||||
|
|
@ -124,7 +124,7 @@ void sidechain_net_handler::sidechain_event_data_received(const sidechain_event_
|
|||
op.withdraw_sidechain = sidechain_type::bitcoin; // BTC payout only (for now)
|
||||
op.withdraw_address = addr_itr->withdraw_address; // BTC payout only (for now)
|
||||
op.withdraw_currency = "BTC"; // BTC payout only (for now)
|
||||
op.withdraw_amount = sed.peerplays_asset.amount * 1000; // BTC payout only (for now)
|
||||
op.withdraw_amount = sed.peerplays_asset.amount; // BTC payout only (for now)
|
||||
|
||||
signed_transaction trx = database.create_signed_transaction(plugin.get_private_key(son_id), op);
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -1412,7 +1412,9 @@ void sidechain_net_handler_bitcoin::handle_event(const std::string &event_data)
|
|||
sed.sidechain_amount = v.out.amount;
|
||||
sed.peerplays_from = addr_itr->sidechain_address_account;
|
||||
sed.peerplays_to = database.get_global_properties().parameters.son_account();
|
||||
sed.peerplays_asset = asset(sed.sidechain_amount / 1000); // For Bitcoin, the exchange rate is 1:1, for others, get the exchange rate from market
|
||||
asset_id_type btc_asset_id = database.get_global_properties().parameters.btc_asset();
|
||||
asset_object btc_asset = btc_asset_id(database);
|
||||
sed.peerplays_asset = btc_asset.amount(sed.sidechain_amount);
|
||||
sidechain_event_data_received(sed);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,6 +61,9 @@ void sidechain_net_handler_peerplays::on_applied_block(const signed_block &b) {
|
|||
if (transfer_op.to != plugin.database().get_global_properties().parameters.son_account()) {
|
||||
continue;
|
||||
}
|
||||
// only bitcoin withdraws acepted for now
|
||||
if (transfer_op.amount.asset_id != plugin.database().get_global_properties().parameters.btc_asset())
|
||||
continue;
|
||||
|
||||
std::stringstream ss;
|
||||
ss << "peerplays"
|
||||
|
|
@ -78,8 +81,7 @@ void sidechain_net_handler_peerplays::on_applied_block(const signed_block &b) {
|
|||
sed.sidechain_amount = transfer_op.amount.amount;
|
||||
sed.peerplays_from = transfer_op.from;
|
||||
sed.peerplays_to = transfer_op.to;
|
||||
// We should calculate exchange rate between CORE/TEST and other Peerplays asset
|
||||
sed.peerplays_asset = asset(transfer_op.amount.amount / transfer_op.amount.asset_id(database).options.core_exchange_rate.quote.amount);
|
||||
sed.peerplays_asset = transfer_op.amount.amount;
|
||||
sidechain_event_data_received(sed);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue