remove bitcoin-specific fields from son wallet
This commit is contained in:
parent
a06af5bf17
commit
d710b320c0
5 changed files with 18 additions and 10 deletions
|
|
@ -27,7 +27,6 @@ namespace graphene { namespace chain {
|
||||||
son_wallet_id_type son_wallet_id;
|
son_wallet_id_type son_wallet_id;
|
||||||
graphene::peerplays_sidechain::sidechain_type sidechain;
|
graphene::peerplays_sidechain::sidechain_type sidechain;
|
||||||
string address;
|
string address;
|
||||||
graphene::peerplays_sidechain::bytes redeem_script;
|
|
||||||
|
|
||||||
account_id_type fee_payer()const { return payer; }
|
account_id_type fee_payer()const { return payer; }
|
||||||
share_type calculate_fee(const fee_parameters_type& k)const { return 0; }
|
share_type calculate_fee(const fee_parameters_type& k)const { return 0; }
|
||||||
|
|
@ -38,4 +37,4 @@ namespace graphene { namespace chain {
|
||||||
FC_REFLECT(graphene::chain::son_wallet_recreate_operation::fee_parameters_type, (fee) )
|
FC_REFLECT(graphene::chain::son_wallet_recreate_operation::fee_parameters_type, (fee) )
|
||||||
FC_REFLECT(graphene::chain::son_wallet_recreate_operation, (fee)(payer)(sons) )
|
FC_REFLECT(graphene::chain::son_wallet_recreate_operation, (fee)(payer)(sons) )
|
||||||
FC_REFLECT(graphene::chain::son_wallet_update_operation::fee_parameters_type, (fee) )
|
FC_REFLECT(graphene::chain::son_wallet_update_operation::fee_parameters_type, (fee) )
|
||||||
FC_REFLECT(graphene::chain::son_wallet_update_operation, (fee)(payer)(son_wallet_id)(sidechain)(address)(redeem_script) )
|
FC_REFLECT(graphene::chain::son_wallet_update_operation, (fee)(payer)(son_wallet_id)(sidechain)(address) )
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,6 @@ namespace graphene { namespace chain {
|
||||||
time_point_sec expires;
|
time_point_sec expires;
|
||||||
|
|
||||||
flat_map<peerplays_sidechain::sidechain_type, string> addresses;
|
flat_map<peerplays_sidechain::sidechain_type, string> addresses;
|
||||||
flat_map<peerplays_sidechain::sidechain_type, peerplays_sidechain::bytes> redeem_scripts;
|
|
||||||
vector<son_info> sons;
|
vector<son_info> sons;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -45,4 +44,4 @@ namespace graphene { namespace chain {
|
||||||
} } // graphene::chain
|
} } // graphene::chain
|
||||||
|
|
||||||
FC_REFLECT_DERIVED( graphene::chain::son_wallet_object, (graphene::db::object),
|
FC_REFLECT_DERIVED( graphene::chain::son_wallet_object, (graphene::db::object),
|
||||||
(valid_from) (expires) (addresses) (redeem_scripts) (sons) )
|
(valid_from) (expires) (addresses) (sons) )
|
||||||
|
|
|
||||||
|
|
@ -72,7 +72,6 @@ object_id_type update_son_wallet_evaluator::do_apply(const son_wallet_update_ope
|
||||||
if (itr->addresses.find(op.sidechain) == itr->addresses.end()) {
|
if (itr->addresses.find(op.sidechain) == itr->addresses.end()) {
|
||||||
db().modify(*itr, [&op](son_wallet_object &swo) {
|
db().modify(*itr, [&op](son_wallet_object &swo) {
|
||||||
swo.addresses[op.sidechain] = op.address;
|
swo.addresses[op.sidechain] = op.address;
|
||||||
swo.redeem_scripts[op.sidechain] = op.redeem_script;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -105,7 +105,7 @@ private:
|
||||||
std::string send_transaction(const std::string &transaction);
|
std::string send_transaction(const std::string &transaction);
|
||||||
std::string sign_and_send_transaction_with_wallet(const std::string &tx_json);
|
std::string sign_and_send_transaction_with_wallet(const std::string &tx_json);
|
||||||
std::string create_weighted_multisignature_wallet( const std::vector<std::pair<std::string, uint64_t>>& public_keys );
|
std::string create_weighted_multisignature_wallet( const std::vector<std::pair<std::string, uint64_t>>& public_keys );
|
||||||
void transfer_all_btc(const std::string& from_address, const bytes& from_redeem_script, const vector<son_info>& from_sons, const std::string& to_address);
|
void transfer_all_btc(const std::string& from_address, const vector<son_info>& from_sons, const std::string& to_address);
|
||||||
std::string transfer_deposit_to_primary_wallet(const son_wallet_deposit_object &swdo);
|
std::string transfer_deposit_to_primary_wallet(const son_wallet_deposit_object &swdo);
|
||||||
std::string transfer_withdrawal_from_primary_wallet(const son_wallet_withdraw_object &swwo);
|
std::string transfer_withdrawal_from_primary_wallet(const son_wallet_withdraw_object &swwo);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -637,7 +637,6 @@ void sidechain_net_handler_bitcoin::recreate_primary_wallet() {
|
||||||
op.son_wallet_id = (*active_sw).id;
|
op.son_wallet_id = (*active_sw).id;
|
||||||
op.sidechain = sidechain_type::bitcoin;
|
op.sidechain = sidechain_type::bitcoin;
|
||||||
op.address = address;
|
op.address = address;
|
||||||
op.redeem_script = redeem_script;
|
|
||||||
|
|
||||||
proposal_create_operation proposal_op;
|
proposal_create_operation proposal_op;
|
||||||
proposal_op.fee_paying_account = plugin.get_son_object(plugin.get_current_son_id()).son_account;
|
proposal_op.fee_paying_account = plugin.get_son_object(plugin.get_current_son_id()).son_account;
|
||||||
|
|
@ -659,9 +658,8 @@ void sidechain_net_handler_bitcoin::recreate_primary_wallet() {
|
||||||
if (prev_sw != swi.rend()) {
|
if (prev_sw != swi.rend()) {
|
||||||
std::string prev_pw_address = prev_sw->addresses.at(sidechain_type::bitcoin);
|
std::string prev_pw_address = prev_sw->addresses.at(sidechain_type::bitcoin);
|
||||||
std::string active_pw_address = address;
|
std::string active_pw_address = address;
|
||||||
bytes prev_redeem_script = prev_sw->redeem_scripts.at(sidechain_type::bitcoin);
|
|
||||||
vector<son_info> sons = prev_sw->sons;
|
vector<son_info> sons = prev_sw->sons;
|
||||||
transfer_all_btc(prev_pw_address, prev_redeem_script, sons, active_pw_address);
|
transfer_all_btc(prev_pw_address, sons, active_pw_address);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -726,7 +724,7 @@ std::string sidechain_net_handler_bitcoin::sign_and_send_transaction_with_wallet
|
||||||
return reply_str;
|
return reply_str;
|
||||||
}
|
}
|
||||||
|
|
||||||
void sidechain_net_handler_bitcoin::transfer_all_btc(const std::string& from_address, const bytes& from_redeem_script, const vector<son_info>& from_sons, const std::string& to_address)
|
void sidechain_net_handler_bitcoin::transfer_all_btc(const std::string& from_address, const vector<son_info>& from_sons, const std::string& to_address)
|
||||||
{
|
{
|
||||||
uint64_t fee_rate = bitcoin_client->estimatesmartfee();
|
uint64_t fee_rate = bitcoin_client->estimatesmartfee();
|
||||||
uint64_t min_fee_rate = 1000;
|
uint64_t min_fee_rate = 1000;
|
||||||
|
|
@ -762,6 +760,19 @@ void sidechain_net_handler_bitcoin::transfer_all_btc(const std::string& from_add
|
||||||
}
|
}
|
||||||
tx.vout.push_back(btc_out(to_address, uint64_t((total_amount - min_amount) * 100000000.0)));
|
tx.vout.push_back(btc_out(to_address, uint64_t((total_amount - min_amount) * 100000000.0)));
|
||||||
|
|
||||||
|
std::vector<std::pair<fc::ecc::public_key, uint64_t> > key_data;
|
||||||
|
for(auto si: from_sons)
|
||||||
|
{
|
||||||
|
fc::ecc::public_key pk = si.signing_key;
|
||||||
|
key_data.push_back(std::make_pair(pk, si.total_votes));
|
||||||
|
}
|
||||||
|
std::sort(key_data.begin(), key_data.end(),
|
||||||
|
[](std::pair<fc::ecc::public_key, uint64_t> p1, std::pair<fc::ecc::public_key, uint64_t> p2){
|
||||||
|
return (p1.second > p2.second);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
bytes from_redeem_script = generate_redeem_script(key_data);
|
||||||
|
|
||||||
bitcoin_transaction_send_operation op;
|
bitcoin_transaction_send_operation op;
|
||||||
op.payer = GRAPHENE_SON_ACCOUNT;
|
op.payer = GRAPHENE_SON_ACCOUNT;
|
||||||
op.redeem_script = from_redeem_script;
|
op.redeem_script = from_redeem_script;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue