SON261 - Bitcoin deposit, withdrawal, PW transfer (#287)
* Extend GPO.active_sons to contain votes and all public keys
* Introduce son_wallet_object
* son_wallet_object operations
* son_wallet_object operations
* son_wallet_object operations completed, basic tests added
* Create son_wallet_object on new set of SONs, to initiate primary wallet recreation
* son_wallet_object API and cli wallet commands
* Send RPC command to bitcoin node to recreate multisig wallet
* Send RPC command to bitcoin node to recreate multisig wallet
* Send RPC command to bitcoin node to recreate multisig wallet
* Wallet recreation by scheduled SON only, some cosmetic refactoring
* Wallet recreation by scheduled SON only, some cosmetic refactoring
* Updating wallet info through operation instead through database.modify() for persistance
* SON wallet transfer object and operations, for tracking assets deposit/withdrawal
* Update libraries/chain/include/graphene/chain/protocol/son_wallet.hpp
Co-Authored-By: gladcow <jahr@yandex.ru>
* Update libraries/chain/include/graphene/chain/protocol/son_wallet.hpp
Co-Authored-By: gladcow <jahr@yandex.ru>
* Fix #include <graphene/chain/son_wallet_transfer_object.hpp>
* SON wallet transfer object and operations, for tracking assets deposit/withdrawal
* SON wallet transfer object and operations, for tracking assets deposit/withdrawal
* Refactor primary wallet recreation
* Refactor primary wallet recreation
* PW recreation refactoring, prevent duplicated recreations, update wallet address through proposal
* PW recreation refactoring, prevent duplicated recreations, update wallet address through proposal
* Quickfix for checking payer in evaluator
* Quickfix for checking payer in evaluator
* Fix failing son_wallet_tests
- Check for son_btc_account is temporarely disabled
* Remove redundant file
* Squashed commit of the following:
commit a688bb93ed4e16232a907aa8c76e240c83c771bf
Author: obucinac <obucinac@users.noreply.github.com>
Date: Tue Feb 4 19:31:45 2020 +0100
son_wallet_object operations and multisig wallet recreation by RPC (#263)
* Extend GPO.active_sons to contain votes and all public keys
* Introduce son_wallet_object
* son_wallet_object operations
* Create son_wallet_object on new set of SONs, to initiate primary wallet recreation
* son_wallet_object API and cli wallet commands
* Send RPC command to bitcoin node to recreate multisig wallet
* Updating wallet info through operation instead through database.modify() for persistance
* Update libraries/chain/include/graphene/chain/protocol/son_wallet.hpp
* Update libraries/chain/include/graphene/chain/protocol/son_wallet.hpp
* Fix #include <graphene/chain/son_wallet_transfer_object.hpp>
* Refactor primary wallet recreation
* PW recreation refactoring, prevent duplicated recreations, update wallet address through proposal
* Quickfix for checking payer in evaluator
* Fix failing son_wallet_tests
- Check for son_btc_account is temporarely disabled
* Remove redundant file
Co-authored-by: gladcow <jahr@yandex.ru>
commit 6e61d6b055eb276757e426245a3a7c23a61b3854
Author: satyakoneru <satyakoneru.iiith@gmail.com>
Date: Tue Feb 4 00:14:39 2020 +1100
SON233 - Provide correct downtime metrics to user (#278)
* Remove duplicated item in CMakeLists.txt
* Issue tokens to the user who deposited Bitcoin, WIP...
* Add son_wallet_transfer_process_operation
* Issue tokens to the user who deposited Bitcoin, WIP...
* Support multiple SON nodes per software instance
* Add is_active_son guards for sidechain events processing
* Add is_active_son guards, fix sending proposals and aprovals
* Managing GRAPHENE_SON_ACCOUNT and issuing assets on Bitcoin deposit
* Fix bad param
* Fix aprovals on already approved or invalid proposals
* Move transfer inside son_wallet_transfer_process_operation
* Fix merging issue
* Add cmake command line option SUPPORT_MULTIPLE_SONS
* Skeleton of sidechain_net_handler_peerplays
* Skeleton of Peerplays network listener
* SON261 - Deposit transfer ( user address -> PW ) and Withdrawal transfer ( PW -> user address ) for m-of-n multisig
* Temoprary disable account history tests for tracking accounts
* Full Peerplays listener, use GRAPHENE_SON_ACCOUNT instead son_btc_account
* Renaming son_wallet_transfer* to son_wallet_deposit*, introducing son_wallet_withdrawal*
* Extend sidechain_address_object to contain withdrawal addresses
- Withdrawal address is the address where system will send sidechain currencies
* Rename son_wallet_withdrawal* to son_wallet_withdraw*
* Some refactoring
* SON261 - Withdrawal transfer ( PW -> user address ), addition of bitcoin public private key to config.ini for multiple sons mode
* Withdrawal refactoring
* Withdrawal refactoring
* SON261 - Fix prepare_tx
* SON261 - Add PW->PW Transfer and Code reorg
* Fix file permissions
Co-authored-by: obucinac <obucinac@users.noreply.github.com>
Co-authored-by: gladcow <jahr@yandex.ru>
2020-02-24 02:04:54 +00:00
|
|
|
#include <graphene/chain/sidechain_transaction_evaluator.hpp>
|
|
|
|
|
|
|
|
|
|
#include <graphene/chain/database.hpp>
|
|
|
|
|
#include <graphene/chain/sidechain_transaction_object.hpp>
|
|
|
|
|
#include <graphene/chain/son_object.hpp>
|
|
|
|
|
#include <graphene/chain/proposal_object.hpp>
|
|
|
|
|
#include <graphene/chain/hardfork.hpp>
|
|
|
|
|
|
|
|
|
|
namespace graphene
|
|
|
|
|
{
|
|
|
|
|
namespace chain
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
void_result bitcoin_transaction_send_evaluator::do_evaluate(const bitcoin_transaction_send_operation &op)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
FC_ASSERT(db().head_block_time() >= HARDFORK_SON_TIME, "Not allowed until SON HARDFORK");
|
|
|
|
|
FC_ASSERT( op.payer == GRAPHENE_SON_ACCOUNT, "SON paying account must be set as payer." );
|
|
|
|
|
return void_result();
|
|
|
|
|
}
|
|
|
|
|
FC_CAPTURE_AND_RETHROW((op))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
object_id_type bitcoin_transaction_send_evaluator::do_apply(const bitcoin_transaction_send_operation &op)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
const auto &new_bitcoin_transaction_object = db().create<bitcoin_transaction_object>([&](bitcoin_transaction_object &obj) {
|
|
|
|
|
obj.processed = false;
|
|
|
|
|
obj.signatures = op.signatures;
|
|
|
|
|
});
|
|
|
|
|
return new_bitcoin_transaction_object.id;
|
|
|
|
|
}
|
|
|
|
|
FC_CAPTURE_AND_RETHROW((op))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void_result bitcoin_transaction_sign_evaluator::do_evaluate(const bitcoin_transaction_sign_operation &op)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
FC_ASSERT(db().head_block_time() >= HARDFORK_SON_TIME, "Not allowed until SON HARDFORK"); // can be removed after HF date pass
|
|
|
|
|
const auto &proposal_idx = db().get_index_type<proposal_index>().indices().get<by_id>();
|
|
|
|
|
const auto &proposal_itr = proposal_idx.find(op.proposal_id);
|
|
|
|
|
FC_ASSERT(proposal_idx.end() != proposal_itr, "proposal not found");
|
|
|
|
|
// Checks can this SON approve this proposal
|
|
|
|
|
auto can_this_son_approve_this_proposal = [&]() {
|
|
|
|
|
const auto &sidx = db().get_index_type<son_index>().indices().get<graphene::chain::by_account>();
|
|
|
|
|
auto son_obj = sidx.find(op.payer);
|
|
|
|
|
if (son_obj == sidx.end())
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
// TODO: Check if the SON is included in the PW script.
|
|
|
|
|
return true;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
FC_ASSERT(can_this_son_approve_this_proposal(), "Invalid approval received");
|
|
|
|
|
return void_result();
|
|
|
|
|
}
|
|
|
|
|
FC_CAPTURE_AND_RETHROW((op))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
object_id_type bitcoin_transaction_sign_evaluator::do_apply(const bitcoin_transaction_sign_operation &op)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
const auto &proposal = op.proposal_id(db());
|
|
|
|
|
const auto &sidx = db().get_index_type<son_index>().indices().get<graphene::chain::by_account>();
|
|
|
|
|
auto son_obj = sidx.find(op.payer);
|
|
|
|
|
|
|
|
|
|
db().modify(proposal, [&](proposal_object &po) {
|
|
|
|
|
auto bitcoin_transaction_send_op = po.proposed_transaction.operations[0].get<bitcoin_transaction_send_operation>();
|
|
|
|
|
bitcoin_transaction_send_op.signatures[son_obj->id] = op.signatures;
|
|
|
|
|
po.proposed_transaction.operations[0] = bitcoin_transaction_send_op;
|
|
|
|
|
});
|
|
|
|
|
|
2020-03-04 15:21:15 +00:00
|
|
|
db().modify( son_obj->statistics( db() ), [&]( son_statistics_object& sso ) {
|
|
|
|
|
sso.txs_signed += 1;
|
|
|
|
|
} );
|
|
|
|
|
|
SON261 - Bitcoin deposit, withdrawal, PW transfer (#287)
* Extend GPO.active_sons to contain votes and all public keys
* Introduce son_wallet_object
* son_wallet_object operations
* son_wallet_object operations
* son_wallet_object operations completed, basic tests added
* Create son_wallet_object on new set of SONs, to initiate primary wallet recreation
* son_wallet_object API and cli wallet commands
* Send RPC command to bitcoin node to recreate multisig wallet
* Send RPC command to bitcoin node to recreate multisig wallet
* Send RPC command to bitcoin node to recreate multisig wallet
* Wallet recreation by scheduled SON only, some cosmetic refactoring
* Wallet recreation by scheduled SON only, some cosmetic refactoring
* Updating wallet info through operation instead through database.modify() for persistance
* SON wallet transfer object and operations, for tracking assets deposit/withdrawal
* Update libraries/chain/include/graphene/chain/protocol/son_wallet.hpp
Co-Authored-By: gladcow <jahr@yandex.ru>
* Update libraries/chain/include/graphene/chain/protocol/son_wallet.hpp
Co-Authored-By: gladcow <jahr@yandex.ru>
* Fix #include <graphene/chain/son_wallet_transfer_object.hpp>
* SON wallet transfer object and operations, for tracking assets deposit/withdrawal
* SON wallet transfer object and operations, for tracking assets deposit/withdrawal
* Refactor primary wallet recreation
* Refactor primary wallet recreation
* PW recreation refactoring, prevent duplicated recreations, update wallet address through proposal
* PW recreation refactoring, prevent duplicated recreations, update wallet address through proposal
* Quickfix for checking payer in evaluator
* Quickfix for checking payer in evaluator
* Fix failing son_wallet_tests
- Check for son_btc_account is temporarely disabled
* Remove redundant file
* Squashed commit of the following:
commit a688bb93ed4e16232a907aa8c76e240c83c771bf
Author: obucinac <obucinac@users.noreply.github.com>
Date: Tue Feb 4 19:31:45 2020 +0100
son_wallet_object operations and multisig wallet recreation by RPC (#263)
* Extend GPO.active_sons to contain votes and all public keys
* Introduce son_wallet_object
* son_wallet_object operations
* Create son_wallet_object on new set of SONs, to initiate primary wallet recreation
* son_wallet_object API and cli wallet commands
* Send RPC command to bitcoin node to recreate multisig wallet
* Updating wallet info through operation instead through database.modify() for persistance
* Update libraries/chain/include/graphene/chain/protocol/son_wallet.hpp
* Update libraries/chain/include/graphene/chain/protocol/son_wallet.hpp
* Fix #include <graphene/chain/son_wallet_transfer_object.hpp>
* Refactor primary wallet recreation
* PW recreation refactoring, prevent duplicated recreations, update wallet address through proposal
* Quickfix for checking payer in evaluator
* Fix failing son_wallet_tests
- Check for son_btc_account is temporarely disabled
* Remove redundant file
Co-authored-by: gladcow <jahr@yandex.ru>
commit 6e61d6b055eb276757e426245a3a7c23a61b3854
Author: satyakoneru <satyakoneru.iiith@gmail.com>
Date: Tue Feb 4 00:14:39 2020 +1100
SON233 - Provide correct downtime metrics to user (#278)
* Remove duplicated item in CMakeLists.txt
* Issue tokens to the user who deposited Bitcoin, WIP...
* Add son_wallet_transfer_process_operation
* Issue tokens to the user who deposited Bitcoin, WIP...
* Support multiple SON nodes per software instance
* Add is_active_son guards for sidechain events processing
* Add is_active_son guards, fix sending proposals and aprovals
* Managing GRAPHENE_SON_ACCOUNT and issuing assets on Bitcoin deposit
* Fix bad param
* Fix aprovals on already approved or invalid proposals
* Move transfer inside son_wallet_transfer_process_operation
* Fix merging issue
* Add cmake command line option SUPPORT_MULTIPLE_SONS
* Skeleton of sidechain_net_handler_peerplays
* Skeleton of Peerplays network listener
* SON261 - Deposit transfer ( user address -> PW ) and Withdrawal transfer ( PW -> user address ) for m-of-n multisig
* Temoprary disable account history tests for tracking accounts
* Full Peerplays listener, use GRAPHENE_SON_ACCOUNT instead son_btc_account
* Renaming son_wallet_transfer* to son_wallet_deposit*, introducing son_wallet_withdrawal*
* Extend sidechain_address_object to contain withdrawal addresses
- Withdrawal address is the address where system will send sidechain currencies
* Rename son_wallet_withdrawal* to son_wallet_withdraw*
* Some refactoring
* SON261 - Withdrawal transfer ( PW -> user address ), addition of bitcoin public private key to config.ini for multiple sons mode
* Withdrawal refactoring
* Withdrawal refactoring
* SON261 - Fix prepare_tx
* SON261 - Add PW->PW Transfer and Code reorg
* Fix file permissions
Co-authored-by: obucinac <obucinac@users.noreply.github.com>
Co-authored-by: gladcow <jahr@yandex.ru>
2020-02-24 02:04:54 +00:00
|
|
|
update_proposal(op);
|
|
|
|
|
}
|
|
|
|
|
FC_CAPTURE_AND_RETHROW((op))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void bitcoin_transaction_sign_evaluator::update_proposal(const bitcoin_transaction_sign_operation &op)
|
|
|
|
|
{
|
|
|
|
|
database &d = db();
|
|
|
|
|
proposal_update_operation update_op;
|
|
|
|
|
|
|
|
|
|
update_op.fee_paying_account = op.payer;
|
|
|
|
|
update_op.proposal = op.proposal_id;
|
|
|
|
|
update_op.active_approvals_to_add = {op.payer};
|
|
|
|
|
|
|
|
|
|
bool skip_fee_old = trx_state->skip_fee;
|
|
|
|
|
bool skip_fee_schedule_check_old = trx_state->skip_fee_schedule_check;
|
|
|
|
|
trx_state->skip_fee = true;
|
|
|
|
|
trx_state->skip_fee_schedule_check = true;
|
|
|
|
|
|
|
|
|
|
d.apply_operation(*trx_state, update_op);
|
|
|
|
|
|
|
|
|
|
trx_state->skip_fee = skip_fee_old;
|
|
|
|
|
trx_state->skip_fee_schedule_check = skip_fee_schedule_check_old;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void_result bitcoin_send_transaction_process_evaluator::do_evaluate(const bitcoin_send_transaction_process_operation &op)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
FC_ASSERT(db().head_block_time() >= HARDFORK_SON_TIME, "Not allowed until SON HARDFORK");
|
|
|
|
|
FC_ASSERT( op.payer == GRAPHENE_SON_ACCOUNT, "SON paying account must be set as payer." );
|
|
|
|
|
const auto& btidx = db().get_index_type<bitcoin_transaction_index>().indices().get<by_id>();
|
|
|
|
|
const auto btobj = btidx.find(op.bitcoin_transaction_id);
|
|
|
|
|
FC_ASSERT(btobj != btidx.end(), "Bitcoin Transaction Object not found");
|
|
|
|
|
FC_ASSERT(btobj->processed == false, "Bitcoin Transaction already processed");
|
|
|
|
|
return void_result();
|
|
|
|
|
}
|
|
|
|
|
FC_CAPTURE_AND_RETHROW((op))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
object_id_type bitcoin_send_transaction_process_evaluator::do_apply(const bitcoin_send_transaction_process_operation &op)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
const auto &btidx = db().get_index_type<bitcoin_transaction_index>().indices().get<by_id>();
|
|
|
|
|
auto btobj = btidx.find(op.bitcoin_transaction_id);
|
|
|
|
|
if (btobj != btidx.end())
|
|
|
|
|
{
|
|
|
|
|
db().modify(*btobj, [&op](bitcoin_transaction_object &bto) {
|
|
|
|
|
bto.processed = true;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
return op.bitcoin_transaction_id;
|
|
|
|
|
}
|
|
|
|
|
FC_CAPTURE_AND_RETHROW((op))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace chain
|
|
|
|
|
} // namespace graphene
|