* Bring in the bitcoin utils code into plugin * Add tx creation, signing and tests * tx deserialization fix * add 10-of-14 multisig address test * Add signing and verification tests and sign_transaction_standalone * Add send_transaction_standalone function * Debug logs and additional tests * Fix for son deletion in the middle * Extend script_builder * Witness script for weighted wallet * btc_weighted_multisig_address implementation * Fix for bad-txns-nonstandard-inputs * Weighted multisignature address test * Create test tx with weighted multisig wallet * Fix the issues with tx signing * End to End test weighted multi sig * 1 or m-of-n deposit address support * Move network_type enum to the base class * btc_one_or_weighted_multisig_address implementation * Simplify redeem script * Fix error in redeem_script * btc_one_or_weighted_multisig_address tests * Refactor sidechain address mapping * CLANG code format * CLANG code format sidechain tests * Integration of deposit and rest of weighted wallets, withdrawal fee fix, whole code refactoring * Move util functions to Utils file * Add proper checks for withdraw fee * Deposit address creation, import deposit/withdraw addresses, some code cleanup Co-authored-by: satyakoneru <15652887+satyakoneru@users.noreply.github.com> Co-authored-by: gladcow <s.gladkov@pbsa.info> Co-authored-by: Srdjan Obucina <obucinac@gmail.com>
72 lines
3.3 KiB
C++
72 lines
3.3 KiB
C++
#include <graphene/chain/sidechain_address_evaluator.hpp>
|
|
|
|
#include <graphene/chain/database.hpp>
|
|
#include <graphene/chain/sidechain_address_object.hpp>
|
|
#include <graphene/chain/hardfork.hpp>
|
|
|
|
namespace graphene { namespace chain {
|
|
|
|
void_result add_sidechain_address_evaluator::do_evaluate(const sidechain_address_add_operation& op)
|
|
{ try{
|
|
|
|
const auto& idx = db().get_index_type<sidechain_address_index>().indices().get<by_account_and_sidechain>();
|
|
FC_ASSERT( idx.find(boost::make_tuple(op.sidechain_address_account, op.sidechain)) == idx.end(), "Duplicated item" );
|
|
return void_result();
|
|
} FC_CAPTURE_AND_RETHROW( (op) ) }
|
|
|
|
object_id_type add_sidechain_address_evaluator::do_apply(const sidechain_address_add_operation& op)
|
|
{ try {
|
|
const auto& new_sidechain_address_object = db().create<sidechain_address_object>( [&]( sidechain_address_object& obj ){
|
|
obj.sidechain_address_account = op.sidechain_address_account;
|
|
obj.sidechain = op.sidechain;
|
|
obj.deposit_public_key = op.deposit_public_key;
|
|
obj.deposit_address = op.deposit_address;
|
|
obj.withdraw_public_key = op.withdraw_public_key;
|
|
obj.withdraw_address = op.withdraw_address;
|
|
});
|
|
return new_sidechain_address_object.id;
|
|
} FC_CAPTURE_AND_RETHROW( (op) ) }
|
|
|
|
void_result update_sidechain_address_evaluator::do_evaluate(const sidechain_address_update_operation& op)
|
|
{ try {
|
|
FC_ASSERT(db().get(op.sidechain_address_id).sidechain_address_account == op.sidechain_address_account);
|
|
const auto& idx = db().get_index_type<sidechain_address_index>().indices().get<by_id>();
|
|
FC_ASSERT( idx.find(op.sidechain_address_id) != idx.end() );
|
|
return void_result();
|
|
} FC_CAPTURE_AND_RETHROW( (op) ) }
|
|
|
|
object_id_type update_sidechain_address_evaluator::do_apply(const sidechain_address_update_operation& op)
|
|
{ try {
|
|
const auto& idx = db().get_index_type<sidechain_address_index>().indices().get<by_id>();
|
|
auto itr = idx.find(op.sidechain_address_id);
|
|
if(itr != idx.end())
|
|
{
|
|
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.withdraw_public_key.valid()) sao.withdraw_public_key = *op.withdraw_public_key;
|
|
if(op.withdraw_address.valid()) sao.withdraw_address = *op.withdraw_address;
|
|
});
|
|
}
|
|
return op.sidechain_address_id;
|
|
} FC_CAPTURE_AND_RETHROW( (op) ) }
|
|
|
|
void_result delete_sidechain_address_evaluator::do_evaluate(const sidechain_address_delete_operation& op)
|
|
{ try {
|
|
FC_ASSERT(db().get(op.sidechain_address_id).sidechain_address_account == op.sidechain_address_account);
|
|
const auto& idx = db().get_index_type<sidechain_address_index>().indices().get<by_id>();
|
|
FC_ASSERT( idx.find(op.sidechain_address_id) != idx.end() );
|
|
return void_result();
|
|
} FC_CAPTURE_AND_RETHROW( (op) ) }
|
|
|
|
void_result delete_sidechain_address_evaluator::do_apply(const sidechain_address_delete_operation& op)
|
|
{ try {
|
|
const auto& idx = db().get_index_type<sidechain_address_index>().indices().get<by_id>();
|
|
auto sidechain_address = idx.find(op.sidechain_address_id);
|
|
if(sidechain_address != idx.end()) {
|
|
db().remove(*sidechain_address);
|
|
}
|
|
return void_result();
|
|
} FC_CAPTURE_AND_RETHROW( (op) ) }
|
|
|
|
} } // namespace graphene::chain
|