Fix sidechain address generation
This commit is contained in:
parent
536e07d726
commit
939a076e08
1 changed files with 30 additions and 26 deletions
|
|
@ -1360,37 +1360,41 @@ void sidechain_net_handler_bitcoin::process_sidechain_addresses() {
|
||||||
std::for_each(sidechain_addresses_by_sidechain_range.first, sidechain_addresses_by_sidechain_range.second,
|
std::for_each(sidechain_addresses_by_sidechain_range.first, sidechain_addresses_by_sidechain_range.second,
|
||||||
[&](const sidechain_address_object &sao) {
|
[&](const sidechain_address_object &sao) {
|
||||||
bool retval = true;
|
bool retval = true;
|
||||||
if (sao.expires == time_point_sec::maximum()) {
|
try {
|
||||||
auto usr_pubkey = fc::ecc::public_key(create_public_key_data(parse_hex(sao.deposit_public_key)));
|
if (sao.expires == time_point_sec::maximum()) {
|
||||||
|
auto usr_pubkey = fc::ecc::public_key(create_public_key_data(parse_hex(sao.deposit_public_key)));
|
||||||
|
|
||||||
btc_one_or_weighted_multisig_address addr(usr_pubkey, pubkeys, network_type);
|
btc_one_or_weighted_multisig_address addr(usr_pubkey, pubkeys, network_type);
|
||||||
std::string address_data = "{ \"redeemScript\": \"" + fc::to_hex(addr.get_redeem_script()) +
|
std::string address_data = "{ \"redeemScript\": \"" + fc::to_hex(addr.get_redeem_script()) +
|
||||||
"\", \"witnessScript\": \"" + fc::to_hex(addr.get_witness_script()) + "\" }";
|
"\", \"witnessScript\": \"" + fc::to_hex(addr.get_witness_script()) + "\" }";
|
||||||
|
|
||||||
if (addr.get_address() != sao.deposit_address) {
|
if (addr.get_address() != sao.deposit_address) {
|
||||||
sidechain_address_update_operation op;
|
sidechain_address_update_operation op;
|
||||||
op.payer = plugin.get_current_son_object().son_account;
|
op.payer = plugin.get_current_son_object().son_account;
|
||||||
op.sidechain_address_id = sao.id;
|
op.sidechain_address_id = sao.id;
|
||||||
op.sidechain_address_account = sao.sidechain_address_account;
|
op.sidechain_address_account = sao.sidechain_address_account;
|
||||||
op.sidechain = sao.sidechain;
|
op.sidechain = sao.sidechain;
|
||||||
op.deposit_public_key = sao.deposit_public_key;
|
op.deposit_public_key = sao.deposit_public_key;
|
||||||
op.deposit_address = addr.get_address();
|
op.deposit_address = addr.get_address();
|
||||||
op.deposit_address_data = address_data;
|
op.deposit_address_data = address_data;
|
||||||
op.withdraw_public_key = sao.withdraw_public_key;
|
op.withdraw_public_key = sao.withdraw_public_key;
|
||||||
op.withdraw_address = sao.withdraw_address;
|
op.withdraw_address = sao.withdraw_address;
|
||||||
|
|
||||||
signed_transaction trx = database.create_signed_transaction(plugin.get_private_key(plugin.get_current_son_id()), op);
|
signed_transaction trx = database.create_signed_transaction(plugin.get_private_key(plugin.get_current_son_id()), op);
|
||||||
try {
|
try {
|
||||||
trx.validate();
|
trx.validate();
|
||||||
database.push_transaction(trx, database::validation_steps::skip_block_size_check);
|
database.push_transaction(trx, database::validation_steps::skip_block_size_check);
|
||||||
if (plugin.app().p2p_node())
|
if (plugin.app().p2p_node())
|
||||||
plugin.app().p2p_node()->broadcast(net::trx_message(trx));
|
plugin.app().p2p_node()->broadcast(net::trx_message(trx));
|
||||||
retval = true;
|
retval = true;
|
||||||
} catch (fc::exception &e) {
|
} catch (fc::exception &e) {
|
||||||
elog("Sending transaction for sidechain address update operation failed with exception ${e}", ("e", e.what()));
|
elog("Sending transaction for sidechain address update operation failed with exception ${e}", ("e", e.what()));
|
||||||
retval = false;
|
retval = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (fc::exception &e) {
|
||||||
|
retval = false;
|
||||||
}
|
}
|
||||||
return retval;
|
return retval;
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue