burn BTC asset after withdraw

This commit is contained in:
gladcow 2020-04-02 13:22:45 +03:00
parent 981049ccd0
commit 740243e7df
3 changed files with 23 additions and 9 deletions

View file

@ -428,10 +428,6 @@ bool peerplays_sidechain_plugin_impl::is_valid_son_proposal(const chain::proposa
return true;
}
if (op_idx_0 == chain::operation::tag<chain::son_wallet_withdraw_process_operation>::value) {
return true;
}
if (op_idx_0 == chain::operation::tag<chain::sidechain_transaction_create_operation>::value) {
return true;
}
@ -440,9 +436,14 @@ bool peerplays_sidechain_plugin_impl::is_valid_son_proposal(const chain::proposa
int32_t op_idx_1 = proposal.proposed_transaction.operations[1].which();
if ((op_idx_0 == chain::operation::tag<chain::son_wallet_deposit_process_operation>::value) &&
(op_idx_1 == chain::operation::tag<chain::transfer_operation>::value)) {
(op_idx_1 == chain::operation::tag<chain::asset_issue_operation>::value)) {
return true;
}
if ((op_idx_0 == chain::operation::tag<chain::son_wallet_withdraw_process_operation>::value) &&
(op_idx_1 == chain::operation::tag<chain::asset_reserve_operation>::value)) {
return true;
}
}
return false;

View file

@ -166,16 +166,22 @@ void sidechain_net_handler::process_deposits() {
swdp_op.payer = gpo.parameters.son_account();
swdp_op.son_wallet_deposit_id = swdo.id;
transfer_operation t_op;
/* transfer_operation t_op;
t_op.fee = asset(2000000);
t_op.from = swdo.peerplays_to; // gpo.parameters.son_account()
t_op.to = swdo.peerplays_from;
t_op.amount = swdo.peerplays_asset;
*/
asset_issue_operation i_op;
i_op.fee = asset(2000000);
i_op.issuer = gpo.parameters.son_account();
i_op.asset_to_issue = swdo.peerplays_asset;
i_op.issue_to_account = swdo.peerplays_to;
proposal_create_operation proposal_op;
proposal_op.fee_paying_account = plugin.get_current_son_object().son_account;
proposal_op.proposed_ops.emplace_back(swdp_op);
proposal_op.proposed_ops.emplace_back(t_op);
proposal_op.proposed_ops.emplace_back(i_op);
uint32_t lifetime = (gpo.parameters.block_interval * gpo.active_witnesses.size()) * 3;
proposal_op.expiration_time = time_point_sec(database.head_block_time().sec_since_epoch() + lifetime);
@ -215,9 +221,16 @@ void sidechain_net_handler::process_withdrawals() {
swwp_op.payer = gpo.parameters.son_account();
swwp_op.son_wallet_withdraw_id = swwo.id;
asset_reserve_operation r_op;
r_op.fee = asset(200000);
r_op.payer = gpo.parameters.son_account();
asset_object btc_asset_obj = gpo.parameters.btc_asset()(database);
r_op.amount_to_reserve = btc_asset_obj.amount(swwo.withdraw_amount);
proposal_create_operation proposal_op;
proposal_op.fee_paying_account = plugin.get_current_son_object().son_account;
proposal_op.proposed_ops.emplace_back(swwp_op);
proposal_op.proposed_ops.emplace_back(r_op);
uint32_t lifetime = (gpo.parameters.block_interval * gpo.active_witnesses.size()) * 3;
proposal_op.expiration_time = time_point_sec(database.head_block_time().sec_since_epoch() + lifetime);

View file

@ -1410,8 +1410,8 @@ void sidechain_net_handler_bitcoin::handle_event(const std::string &event_data)
sed.sidechain_to = v.address;
sed.sidechain_currency = "BTC";
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_from = database.get_global_properties().parameters.son_account();
sed.peerplays_to = addr_itr->sidechain_address_account;
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);