Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
e688a5f
Information storage for inputs and outputs
pixelplex-dev Jan 10, 2019
a5695dd
Added rpc and zmq modules for comminication with bitcoin node
pixelplex-dev Jan 10, 2019
58a935a
Added bitcoin address (btc_multisig_address and btc_multisig_segwit_a…
pixelplex-dev Jan 10, 2019
23e63f0
Created functional related to creating and getting bitcoin_address_ob…
pixelplex-dev Jan 12, 2019
6b534b3
Filling I/O queues. Create class bitcoin_address.
pixelplex-dev Jan 12, 2019
edbc86c
Displaced connection check from zmq_listener to sidechain_net_manager
pixelplex-dev Jan 12, 2019
a939473
Added pw_vout_object, pw_vout_manager and tests for pw_vout_manager
pixelplex-dev Jan 18, 2019
229a601
The mechanism for creating a thickening transaction and calculating t…
pixelplex-dev Jan 18, 2019
5810855
Added sidechain_proposal_object
pixelplex-dev Jan 18, 2019
859d2f4
Added mechanism sign bitcoin transaction.
pixelplex-dev Jan 21, 2019
7675b1d
Added bitcoin_transaction_create_operation, evaluator; filled sidecha…
pixelplex-dev Jan 22, 2019
1ecf0a7
Added finalize_bitcoin_transaction, changed bitcoin_transaction_objec…
pixelplex-dev Jan 24, 2019
f687421
Added PW address creation, set sidechain parameters; using PW address…
pixelplex-dev Jan 25, 2019
aee9fbc
Added sign_btc_transaction_operation and sign_btc_transaction_evaluator
pixelplex-dev Jan 25, 2019
37dde2a
Added sidechain_proposal_object creation, changed thread_safe_index a…
pixelplex-dev Jan 28, 2019
3cea6ca
Added mechanism create proposal (send_btc_transaction)
pixelplex-dev Jan 29, 2019
a854227
Made thread_safe_index methods with typename, changed input_withdrawa…
pixelplex-dev Jan 29, 2019
38044e7
Mechanism remove sidechain_proposals
pixelplex-dev Jan 31, 2019
1387f6f
Signature bitcoin transaction and confirmation proposal
pixelplex-dev Jan 31, 2019
ad6dc5f
Filled update_tx_approvals in sidechain_net_manager
pixelplex-dev Jan 31, 2019
0b7e176
Added bitcoin_issue_operation, bitcoin_issue_evaluator with tests
pixelplex-dev Feb 1, 2019
36d60fe
Changed bitcoin_transaction_send_operation. Fixed bugs.
pixelplex-dev Feb 1, 2019
bd6943e
Added creation and approving propose with issue
pixelplex-dev Feb 6, 2019
c1ee56b
Fixed fee bug and bug with info_for_vout
pixelplex-dev Feb 6, 2019
650a424
Added reserve_issue and check_amount_higher_than_fee into withdraw_pb…
pixelplex-dev Feb 6, 2019
aaa2ccb
Changed constant params to dynamic sidechain_parameters
pixelplex-dev Feb 7, 2019
715673a
Added class sidechain_proposal_checker
pixelplex-dev Feb 7, 2019
809e47c
Added bitcoin_transaction_revert_operation with evaluator
pixelplex-dev Feb 7, 2019
6f8ef2a
Added approval proposal checker
pixelplex-dev Feb 7, 2019
a9f2424
Added checking bitcoin inputs
pixelplex-dev Feb 8, 2019
184e0ee
Added creation of bitcoin revert proposals
pixelplex-dev Feb 8, 2019
7522afb
Мade executable for sidechain tests and added bitcoin_transaction_re…
pixelplex-dev Feb 8, 2019
77b16c2
Added resend flag into info_for_vin, changed comparer, made test for …
pixelplex-dev Feb 8, 2019
8219eb0
Added check_bitcoin_transaction_revert_operation
pixelplex-dev Feb 11, 2019
8d4c6e7
Fixed thread_safe_index::remove and thread_safe_index::modify
pixelplex-dev Feb 11, 2019
b75ceb0
Added initializing bitcoin_confirmations when node starts; made corre…
pixelplex-dev Feb 12, 2019
0481361
Added is_max_vouts check for PW before bitcoin transaction creatation
pixelplex-dev Feb 12, 2019
ac7db3e
Add public key verification mechanism.
pixelplex-dev Feb 13, 2019
9259382
Fixed existing tests; add more unit tests for db_sidechain methods
pixelplex-dev Feb 13, 2019
c2be2b1
Fixed issue-11
pixelplex-dev Feb 14, 2019
2cb0130
Fix : Segmentation fault when running several witness nodes on the sa…
pixelplex-dev Feb 14, 2019
c74f294
Fixed revert proposal: multiply createion; fix pw vin delete
pixelplex-dev Feb 20, 2019
5711e44
Private keys management fixed (cli_wallet)
pixelplex-dev Feb 22, 2019
6488f04
Added Boost version control; Added flag for gcc 6.0
pixelplex-dev Feb 25, 2019
4b90eb0
Added control to small input amount
pixelplex-dev Mar 7, 2019
6f579e0
Fix: do_evaluate method incorrect witness
pixelplex-dev Mar 20, 2019
fe62309
Deleted idump in subscribe_to_item; added deleting zero-balance objec…
pixelplex-dev Mar 22, 2019
6f5c558
Added sidechain hardfork time
pixelplex-dev Mar 26, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ tests/chain_bench
tests/chain_test
tests/intense_test
tests/performance_test
tests/betting_test
tests/tournament_test
tests/random_test
tests/sidechain_test
tests/generate_empty_blocks/generate_empty_blocks

doxygen

Expand Down
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ IF( WIN32 )
set(BOOST_ALL_DYN_LINK OFF) # force dynamic linking for all libraries
ENDIF(WIN32)

FIND_PACKAGE(Boost 1.57 REQUIRED COMPONENTS ${BOOST_COMPONENTS})
FIND_PACKAGE(Boost 1.60 REQUIRED COMPONENTS ${BOOST_COMPONENTS})
# For Boost 1.53 on windows, coroutine was not in BOOST_LIBRARYDIR and do not need it to build, but if boost versin >= 1.54, find coroutine otherwise will cause link errors
IF(NOT "${Boost_VERSION}" MATCHES "1.53(.*)")
SET(BOOST_LIBRARIES_TEMP ${Boost_LIBRARIES})
Expand Down Expand Up @@ -132,6 +132,9 @@ else( WIN32 ) # Apple AND Linux

if( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-builtin-memcmp" )
if ( CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 6.0 )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive" )
endif()
elseif( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" )
if( CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 4.0.0 OR CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.0.0 )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-invalid-partial-specialization" )
Expand Down
1 change: 1 addition & 0 deletions libraries/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ add_subdirectory( utilities )
add_subdirectory( app )
add_subdirectory( plugins )
add_subdirectory( wallet )
add_subdirectory( sidechain )
9 changes: 8 additions & 1 deletion libraries/app/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,9 @@ namespace detail {
// you can help the network code out by throwing a block_older_than_undo_history exception.
// when the net code sees that, it will stop trying to push blocks from that chain, but
// leave that peer connected so that they can get sync blocks from us
bool result = _chain_db->push_block(blk_msg.block, (_is_block_producer | _force_validate) ? database::skip_nothing : database::skip_transaction_signatures);
auto skip_nothing_mode = sync_mode ? database::skip_nothing | database::skip_btc_tx_sending : database::skip_nothing;
auto skip_transaction_signatures_mode = sync_mode ? database::skip_transaction_signatures | database::skip_btc_tx_sending : database::skip_transaction_signatures;
bool result = _chain_db->push_block(blk_msg.block, (_is_block_producer | _force_validate) ? skip_nothing_mode : skip_transaction_signatures_mode);

// the block was accepted, so we now know all of the transactions contained in the block
if (!sync_mode)
Expand Down Expand Up @@ -963,6 +965,11 @@ void application::set_program_options(boost::program_options::options_descriptio
("genesis-json", bpo::value<boost::filesystem::path>(), "File to read Genesis State from")
("dbg-init-key", bpo::value<string>(), "Block signing key to use for init witnesses, overrides genesis file")
("api-access", bpo::value<boost::filesystem::path>(), "JSON file specifying API permissions")
("bitcoin-node-ip", bpo::value<string>()->implicit_value("127.0.0.1"), "IP address of Bitcoin node")
("bitcoin-node-zmq-port", bpo::value<uint32_t>()->implicit_value(28332), "ZMQ port of Bitcoin node")
("bitcoin-node-rpc-port", bpo::value<uint32_t>()->implicit_value(18332), "RPC port of Bitcoin node")
("bitcoin-node-rpc-user", bpo::value<string>(), "Bitcoin RPC user")
("bitcoin-node-rpc-password", bpo::value<string>(), "Bitcoin RPC password")
;
command_line_options.add(configuration_file_options);
command_line_options.add_options()
Expand Down
30 changes: 29 additions & 1 deletion libraries/app/database_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ class database_api_impl : public std::enable_shared_from_this<database_api_impl>
vector<tournament_object> get_tournaments_by_state(tournament_id_type stop, unsigned limit, tournament_id_type start, tournament_state state);
vector<tournament_id_type> get_registered_tournaments(account_id_type account_filter, uint32_t limit) const;

//Sidechain
vector<bitcoin_address_object> get_bitcoin_addresses(const account_id_type& acc_id) const;


//private:
template<typename T>
Expand All @@ -172,7 +175,6 @@ class database_api_impl : public std::enable_shared_from_this<database_api_impl>

if( !is_subscribed_to_item(i) )
{
idump((i));
_subscribe_filter.insert( vec.data(), vec.size() );//(vecconst char*)&i, sizeof(i) );
}
}
Expand Down Expand Up @@ -2021,6 +2023,32 @@ vector<tournament_id_type> database_api_impl::get_registered_tournaments(account
return tournament_ids;
}

//////////////////////////////////////////////////////////////////////
// //
// Sidechain //
// //
//////////////////////////////////////////////////////////////////////

vector<bitcoin_address_object> database_api::get_bitcoin_addresses(const account_id_type& acc) const
{
return my->get_bitcoin_addresses(acc);
}

vector<bitcoin_address_object> database_api_impl::get_bitcoin_addresses(const account_id_type& acc) const
{
vector<bitcoin_address_object> result;

const auto& btc_addr_idx = _db.get_index_type<bitcoin_address_index>().indices().get<by_owner>();

auto itr = btc_addr_idx.lower_bound( acc );
while( itr != btc_addr_idx.end() && itr->owner == acc )
{
result.push_back( *itr );
++itr;
}
return result;
}

//////////////////////////////////////////////////////////////////////
// //
// Private methods //
Expand Down
24 changes: 24 additions & 0 deletions libraries/app/impacted.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,30 @@ struct get_impacted_account_visitor
_impacted.insert( op.affiliate );
}
void operator()( const affiliate_referral_payout_operation& op ) { }
void operator()( const withdraw_pbtc_operation& op )
{
_impacted.insert( op.payer );
}
void operator()( const bitcoin_address_create_operation& op )
{
_impacted.insert( op.payer );
}
void operator()( const bitcoin_transaction_send_operation& op )
{
_impacted.insert( op.payer );
}
void operator()( const bitcoin_transaction_sign_operation& op )
{
_impacted.insert( op.payer );
}
void operator()( const bitcoin_issue_operation& op )
{
_impacted.insert( op.payer );
}
void operator()( const bitcoin_transaction_revert_operation& op )
{
_impacted.insert( op.payer );
}
};

void operation_get_impacted_accounts( const operation& op, flat_set<account_id_type>& result )
Expand Down
7 changes: 7 additions & 0 deletions libraries/app/include/graphene/app/database_api.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
#include <graphene/chain/worker_object.hpp>
#include <graphene/chain/witness_object.hpp>
#include <graphene/chain/tournament_object.hpp>
#include <graphene/chain/bitcoin_address_object.hpp>

#include <graphene/market_history/market_history_plugin.hpp>

Expand Down Expand Up @@ -644,6 +645,11 @@ class database_api
* @return the list of tournaments that a given account is registered to play in
*/
vector<tournament_id_type> get_registered_tournaments(account_id_type account_filter, uint32_t limit) const;

/**
* @return the list of bitcoin addresses which belong to acc_id
*/
vector<bitcoin_address_object> get_bitcoin_addresses(const account_id_type& acc_id) const;

private:
std::shared_ptr< database_api_impl > my;
Expand Down Expand Up @@ -765,4 +771,5 @@ FC_API(graphene::app::database_api,
(get_tournaments_by_state)
(get_tournaments )
(get_registered_tournaments)
(get_bitcoin_addresses)
)
8 changes: 7 additions & 1 deletion libraries/chain/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ if( GRAPHENE_DISABLE_UNITY_BUILD )
db_market.cpp
db_update.cpp
db_witness_schedule.cpp
db_sidechain.cpp
)
message( STATUS "Graphene database unity build disabled" )
else( GRAPHENE_DISABLE_UNITY_BUILD )
Expand Down Expand Up @@ -85,6 +86,9 @@ add_library( graphene_chain
confidential_evaluator.cpp
special_authority.cpp
buyback.cpp
bitcoin_address_evaluator.cpp
bitcoin_transaction_evaluator.cpp
sidechain_evaluator.cpp

account_object.cpp
asset_object.cpp
Expand All @@ -110,14 +114,16 @@ add_library( graphene_chain
betting_market_group_object.cpp

affiliate_payout.cpp
withdraw_pbtc_evaluator.cpp

${HEADERS}
${PROTOCOL_HEADERS}
"${CMAKE_CURRENT_BINARY_DIR}/include/graphene/chain/hardfork.hpp"
)

add_dependencies( graphene_chain build_hardfork_hpp )
target_link_libraries( graphene_chain fc graphene_db )

target_link_libraries( graphene_chain fc graphene_db sidechain )
target_include_directories( graphene_chain
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include" "${CMAKE_CURRENT_BINARY_DIR}/include" )

Expand Down
46 changes: 46 additions & 0 deletions libraries/chain/bitcoin_address_evaluator.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#include <graphene/chain/bitcoin_address_evaluator.hpp>
#include <graphene/chain/database.hpp>
#include <graphene/chain/exceptions.hpp>
#include <graphene/chain/bitcoin_address_object.hpp>

namespace graphene { namespace chain {

void_result bitcoin_address_create_evaluator::do_evaluate( const bitcoin_address_create_operation& op )
{
database& d = db();
FC_ASSERT( !d.is_sidechain_fork_needed() );
auto& acc_idx = d.get_index_type<account_index>().indices().get<by_id>();
auto acc_itr = acc_idx.find( op.owner );
FC_ASSERT( acc_itr != acc_idx.end() );
return void_result();
}

object_id_type bitcoin_address_create_evaluator::do_apply( const bitcoin_address_create_operation& op )
{
database& d = db();
const auto pw_obj = d.get_latest_PW();
auto witnesses_keys = pw_obj.address.witnesses_keys;

const auto& new_btc_address = d.create<bitcoin_address_object>( [&]( bitcoin_address_object& a ) {
witnesses_keys.erase( --witnesses_keys.end() );
witnesses_keys.emplace( d.get_sidechain_account_id(), pubkey_from_id( a.id ) );

a.owner = op.owner;
a.address = sidechain::btc_multisig_segwit_address( SIDECHAIN_DEFAULT_NUMBER_SIG_MULTISIG, witnesses_keys );
a.count_invalid_pub_key = 1;
});

return new_btc_address.id;
}

public_key_type bitcoin_address_create_evaluator::pubkey_from_id( object_id_type id )
{
fc::ecc::public_key_data pubkey_data;

pubkey_data.at( 0 ) = 0x02; // version
const auto hash = fc::sha256::hash( std::to_string( id.instance() ) ) ;
std::copy( hash.data(), hash.data() + hash.data_size(), pubkey_data.begin() + 1 );

return public_key_type( pubkey_data );
}
} } // namespace graphene::chain
Loading