Hotfix - Save deposit address redeem and witness script into sidechain address object
This commit is contained in:
parent
072906b3fd
commit
984000f63e
6 changed files with 22 additions and 10 deletions
|
|
@ -16,6 +16,7 @@ namespace graphene { namespace chain {
|
|||
sidechain_type sidechain;
|
||||
string deposit_public_key;
|
||||
string deposit_address;
|
||||
string deposit_address_data;
|
||||
string withdraw_public_key;
|
||||
string withdraw_address;
|
||||
|
||||
|
|
@ -35,6 +36,7 @@ namespace graphene { namespace chain {
|
|||
sidechain_type sidechain;
|
||||
optional<string> deposit_public_key;
|
||||
optional<string> deposit_address;
|
||||
optional<string> deposit_address_data;
|
||||
optional<string> withdraw_public_key;
|
||||
optional<string> withdraw_address;
|
||||
|
||||
|
|
@ -61,12 +63,16 @@ namespace graphene { namespace chain {
|
|||
|
||||
FC_REFLECT(graphene::chain::sidechain_address_add_operation::fee_parameters_type, (fee) )
|
||||
FC_REFLECT(graphene::chain::sidechain_address_add_operation, (fee)(payer)
|
||||
(sidechain_address_account)(sidechain)(deposit_public_key)(deposit_address)(withdraw_public_key)(withdraw_address) )
|
||||
(sidechain_address_account)(sidechain)
|
||||
(deposit_public_key)(deposit_address)(deposit_address_data)
|
||||
(withdraw_public_key)(withdraw_address) )
|
||||
|
||||
FC_REFLECT(graphene::chain::sidechain_address_update_operation::fee_parameters_type, (fee) )
|
||||
FC_REFLECT(graphene::chain::sidechain_address_update_operation, (fee)(payer)
|
||||
(sidechain_address_id)
|
||||
(sidechain_address_account)(sidechain)(deposit_public_key)(deposit_address)(withdraw_public_key)(withdraw_address) )
|
||||
(sidechain_address_account)(sidechain)
|
||||
(deposit_public_key)(deposit_address)(deposit_address_data)
|
||||
(withdraw_public_key)(withdraw_address) )
|
||||
|
||||
FC_REFLECT(graphene::chain::sidechain_address_delete_operation::fee_parameters_type, (fee) )
|
||||
FC_REFLECT(graphene::chain::sidechain_address_delete_operation, (fee)(payer)
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ namespace graphene { namespace chain {
|
|||
sidechain_type sidechain;
|
||||
string deposit_public_key;
|
||||
string deposit_address;
|
||||
string deposit_address_data;
|
||||
string withdraw_public_key;
|
||||
string withdraw_address;
|
||||
|
||||
|
|
@ -78,4 +79,6 @@ namespace graphene { namespace chain {
|
|||
} } // graphene::chain
|
||||
|
||||
FC_REFLECT_DERIVED( graphene::chain::sidechain_address_object, (graphene::db::object),
|
||||
(sidechain_address_account) (sidechain) (deposit_public_key) (deposit_address) (withdraw_public_key) (withdraw_address) )
|
||||
(sidechain_address_account) (sidechain)
|
||||
(deposit_public_key) (deposit_address) (deposit_address_data)
|
||||
(withdraw_public_key) (withdraw_address) )
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ object_id_type add_sidechain_address_evaluator::do_apply(const sidechain_address
|
|||
obj.sidechain = op.sidechain;
|
||||
obj.deposit_public_key = op.deposit_public_key;
|
||||
obj.deposit_address = op.deposit_address;
|
||||
obj.deposit_address_data = op.deposit_address_data;
|
||||
obj.withdraw_public_key = op.withdraw_public_key;
|
||||
obj.withdraw_address = op.withdraw_address;
|
||||
});
|
||||
|
|
@ -44,6 +45,7 @@ object_id_type update_sidechain_address_evaluator::do_apply(const sidechain_addr
|
|||
db().modify(*itr, [&op](sidechain_address_object &sao) {
|
||||
if(op.deposit_public_key.valid()) sao.deposit_public_key = *op.deposit_public_key;
|
||||
if(op.deposit_address.valid()) sao.deposit_address = *op.deposit_address;
|
||||
if(op.deposit_address_data.valid()) sao.deposit_address_data = *op.deposit_address_data;
|
||||
if(op.withdraw_public_key.valid()) sao.withdraw_public_key = *op.withdraw_public_key;
|
||||
if(op.withdraw_address.valid()) sao.withdraw_address = *op.withdraw_address;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -413,17 +413,15 @@ void btc_one_or_weighted_multisig_address::create_segwit_address() {
|
|||
address = segwit_addr::encode(hrp, 0, hash_data);
|
||||
}
|
||||
|
||||
btc_timelocked_one_or_weighted_multisig_address::btc_timelocked_one_or_weighted_multisig_address(const fc::ecc::public_key &user_key_data, uint32_t latency, const std::vector<std::pair<fc::ecc::public_key, uint16_t> > &keys_data, bitcoin_address::network ntype) :
|
||||
btc_one_or_weighted_multisig_address(user_key_data, keys_data, ntype),
|
||||
latency_(latency)
|
||||
{
|
||||
btc_timelocked_one_or_weighted_multisig_address::btc_timelocked_one_or_weighted_multisig_address(const fc::ecc::public_key &user_key_data, uint32_t latency, const std::vector<std::pair<fc::ecc::public_key, uint16_t>> &keys_data, bitcoin_address::network ntype) :
|
||||
btc_one_or_weighted_multisig_address(user_key_data, keys_data, ntype),
|
||||
latency_(latency) {
|
||||
create_redeem_script(user_key_data, keys_data);
|
||||
create_witness_script();
|
||||
create_segwit_address();
|
||||
}
|
||||
|
||||
void btc_timelocked_one_or_weighted_multisig_address::create_redeem_script(const fc::ecc::public_key &user_key_data, const std::vector<std::pair<fc::ecc::public_key, uint16_t> > &keys_data)
|
||||
{
|
||||
void btc_timelocked_one_or_weighted_multisig_address::create_redeem_script(const fc::ecc::public_key &user_key_data, const std::vector<std::pair<fc::ecc::public_key, uint16_t>> &keys_data) {
|
||||
script_builder builder;
|
||||
builder << user_key_data.serialize();
|
||||
builder << op::CHECKSIG;
|
||||
|
|
|
|||
|
|
@ -212,7 +212,7 @@ class btc_timelocked_one_or_weighted_multisig_address : public btc_one_or_weight
|
|||
public:
|
||||
btc_timelocked_one_or_weighted_multisig_address() = default;
|
||||
btc_timelocked_one_or_weighted_multisig_address(const fc::ecc::public_key &user_key_data, uint32_t latency, const std::vector<std::pair<fc::ecc::public_key, uint16_t>> &keys_data,
|
||||
network network_type = network::regtest);
|
||||
network network_type = network::regtest);
|
||||
|
||||
private:
|
||||
void create_redeem_script(const fc::ecc::public_key &user_key_data, const std::vector<std::pair<fc::ecc::public_key, uint16_t>> &keys_data);
|
||||
|
|
|
|||
|
|
@ -1310,6 +1310,8 @@ void sidechain_net_handler_bitcoin::process_sidechain_addresses() {
|
|||
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);
|
||||
std::string address_data = "{ \"redeemScript\": \"" + fc::to_hex(addr.get_redeem_script()) +
|
||||
"\", \"witnessScript\": \"" + fc::to_hex(addr.get_witness_script()) + "\" }";
|
||||
|
||||
if (addr.get_address() != sao.deposit_address) {
|
||||
sidechain_address_update_operation op;
|
||||
|
|
@ -1319,6 +1321,7 @@ void sidechain_net_handler_bitcoin::process_sidechain_addresses() {
|
|||
op.sidechain = sao.sidechain;
|
||||
op.deposit_public_key = sao.deposit_public_key;
|
||||
op.deposit_address = addr.get_address();
|
||||
op.deposit_address_data = address_data;
|
||||
op.withdraw_public_key = sao.withdraw_public_key;
|
||||
op.withdraw_address = sao.withdraw_address;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue