Merge remote-tracking branch 'clemahieu/master'

This commit is contained in:
James Coxon 2017-04-16 20:31:24 +01:00 committed by clemahieu
commit 1b8849a803
16 changed files with 356 additions and 44 deletions

View file

@ -3,7 +3,7 @@ project (rai)
set (CPACK_PACKAGE_VERSION_MAJOR "7")
set (CPACK_PACKAGE_VERSION_MINOR "8")
set (CPACK_PACKAGE_VERSION_PATCH "3")
set (CPACK_PACKAGE_VERSION_PATCH "4")
set (RAIBLOCKS_GUI OFF CACHE BOOL "")
set (RAIBLOCKS_TEST OFF CACHE BOOL "")

View file

@ -54,8 +54,8 @@ TEST (message, publish_serialization)
ASSERT_EQ (8, bytes.size ());
ASSERT_EQ (0x52, bytes [0]);
ASSERT_EQ (0x41, bytes [1]);
ASSERT_EQ (0x01, bytes [2]);
ASSERT_EQ (0x01, bytes [3]);
ASSERT_EQ (0x02, bytes [2]);
ASSERT_EQ (0x02, bytes [3]);
ASSERT_EQ (0x01, bytes [4]);
ASSERT_EQ (static_cast <uint8_t> (rai::message_type::publish), bytes [5]);
ASSERT_EQ (0x02, bytes [6]);
@ -68,8 +68,8 @@ TEST (message, publish_serialization)
std::bitset <16> extensions;
ASSERT_FALSE (rai::message::read_header (stream, version_max, version_using, version_min, type, extensions));
ASSERT_EQ (0x01, version_min);
ASSERT_EQ (0x01, version_using);
ASSERT_EQ (0x01, version_max);
ASSERT_EQ (0x02, version_using);
ASSERT_EQ (0x02, version_max);
ASSERT_EQ (rai::message_type::publish, type);
}

View file

@ -1296,3 +1296,22 @@ TEST (node, no_voting)
}
ASSERT_EQ (0, node1.network.confirm_ack_count);
}
TEST (node, start_observer)
{
rai::node_init init;
auto service (boost::make_shared <boost::asio::io_service> ());
rai::alarm alarm (*service);
auto path (rai::unique_path ());
rai::logging logging (path);
rai::work_pool work (std::numeric_limits <unsigned>::max (), nullptr);
auto node (std::make_shared <rai::node> (init, *service, 0, path, alarm, logging, work));
auto started (false);
node->observers.started.add([&started] ()
{
started = true;
});
node->start ();
ASSERT_TRUE (started);
node->stop ();
}

View file

@ -1741,3 +1741,102 @@ TEST (rpc, bootstrap)
ASSERT_GT (200, iterations);
}
}
TEST (rpc, account_remove)
{
rai::system system0 (24000, 1);
auto key1 (system0.wallet (0)->deterministic_insert ());
ASSERT_TRUE (system0.wallet (0)->exists (key1));
rai::rpc rpc (system0.service, *system0.nodes [0], rai::rpc_config (true));
rpc.start ();
boost::property_tree::ptree request;
request.put ("action", "account_remove");
request.put ("wallet", system0.nodes [0]->wallets.items.begin ()->first.to_string ());
request.put ("account", key1.to_account ());
test_response response (request, rpc, system0.service);
while (response.status == 0)
{
system0.poll ();
}
ASSERT_FALSE (system0.wallet (0)->exists (key1));
}
TEST (rpc, representatives)
{
rai::system system0 (24000, 1);
rai::rpc rpc (system0.service, *system0.nodes [0], rai::rpc_config (true));
rpc.start ();
boost::property_tree::ptree request;
request.put ("action", "representatives");
test_response response (request, rpc, system0.service);
while (response.status == 0)
{
system0.poll ();
}
ASSERT_EQ (200, response.status);
auto & representatives_node (response.json.get_child ("representatives"));
std::vector <rai::account> representatives;
for (auto i (representatives_node.begin ()), n (representatives_node.end ()); i != n; ++i)
{
rai::account account;
ASSERT_FALSE (account.decode_account (i->first));
representatives.push_back (account);
}
ASSERT_EQ (1, representatives.size ());
ASSERT_EQ (rai::genesis_account, representatives [0]);
}
TEST (rpc, wallet_change_seed)
{
rai::system system0 (24000, 1);
rai::keypair seed;
{
rai::transaction transaction (system0.nodes [0]->store.environment, nullptr, false);
rai::raw_key seed0;
system0.wallet (0)->store.seed (seed0, transaction);
ASSERT_NE (seed.pub, seed0.data);
}
rai::rpc rpc (system0.service, *system0.nodes [0], rai::rpc_config (true));
rpc.start ();
boost::property_tree::ptree request;
request.put ("action", "wallet_change_seed");
request.put ("wallet", system0.nodes [0]->wallets.items.begin ()->first.to_string ());
request.put ("seed", seed.pub.to_string ());
test_response response (request, rpc, system0.service);
while (response.status == 0)
{
system0.poll ();
}
ASSERT_EQ (200, response.status);
{
rai::transaction transaction (system0.nodes [0]->store.environment, nullptr, false);
rai::raw_key seed0;
system0.wallet (0)->store.seed (seed0, transaction);
ASSERT_EQ (seed.pub, seed0.data);
}
}
TEST (rpc, wallet_frontiers)
{
rai::system system0 (24000, 1);
system0.wallet (0)->insert_adhoc (rai::test_genesis_key.prv);
rai::rpc rpc (system0.service, *system0.nodes [0], rai::rpc_config (true));
rpc.start ();
boost::property_tree::ptree request;
request.put ("action", "wallet_frontiers");
request.put ("wallet", system0.nodes [0]->wallets.items.begin ()->first.to_string ());
test_response response (request, rpc, system0.service);
while (response.status == 0)
{
system0.poll ();
}
ASSERT_EQ (200, response.status);
auto & frontiers_node (response.json.get_child ("frontiers"));
std::vector <rai::account> frontiers;
for (auto i (frontiers_node.begin ()), n (frontiers_node.end ()); i != n; ++i)
{
frontiers.push_back (rai::block_hash (i->second.get <std::string> ("")));
}
ASSERT_EQ (1, frontiers.size ());
ASSERT_EQ (system0.nodes [0]->latest (rai::genesis_account), frontiers [0]);
}

View file

@ -8,8 +8,8 @@ size_t constexpr rai::message::bootstrap_server_position;
std::bitset <16> constexpr rai::message::block_type_mask;
rai::message::message (rai::message_type type_a) :
version_max (0x01),
version_using (0x01),
version_max (0x02),
version_using (0x02),
version_min (0x01),
type (type_a)
{

View file

@ -1552,6 +1552,7 @@ void rai::node::start ()
active.announce_votes ();
port_mapping.start ();
add_initial_peers ();
observers.started ();
}
void rai::node::stop ()

View file

@ -378,6 +378,7 @@ public:
rai::observer_set <rai::vote const &, rai::endpoint const &> vote;
rai::observer_set <rai::endpoint const &> endpoint;
rai::observer_set <> disconnect;
rai::observer_set <> started;
};
class vote_processor
{

View file

@ -375,6 +375,66 @@ void rai::rpc_handler::account_move ()
}
}
void rai::rpc_handler::account_remove ()
{
if (rpc.config.enable_control)
{
std::string wallet_text (request.get <std::string> ("wallet"));
std::string account_text (request.get <std::string> ("account"));
rai::uint256_union wallet;
auto error (wallet.decode_hex (wallet_text));
if (!error)
{
auto existing (node.wallets.items.find (wallet));
if (existing != node.wallets.items.end ())
{
auto wallet (existing->second);
rai::transaction transaction (node.store.environment, nullptr, true);
if (existing->second->store.valid_password (transaction))
{
rai::account account_id;
auto error (account_id.decode_account (account_text));
if (!error)
{
auto account (wallet->store.find (transaction, account_id));
if (account != wallet->store.end ())
{
wallet->store.erase (transaction, account_id);
boost::property_tree::ptree response_l;
response_l.put ("removed", "1");
response (response_l);
}
else
{
error_response (response, "Account not found in wallet");
}
}
else
{
error_response (response, "Bad account number");
}
}
else
{
error_response (response, "Wallet locked");
}
}
else
{
error_response (response, "Wallet not found");
}
}
else
{
error_response (response, "Bad wallet number");
}
}
else
{
error_response (response, "RPC control is disabled");
}
}
void rai::rpc_handler::account_representative ()
{
std::string account_text (request.get <std::string> ("account"));
@ -1287,6 +1347,21 @@ void rai::rpc_handler::rai_to_raw ()
}
}
void rai::rpc_handler::representatives ()
{
boost::property_tree::ptree response_l;
boost::property_tree::ptree representatives;
rai::transaction transaction (node.store.environment, nullptr, false);
for (auto i (node.store.representation_begin (transaction)), n (node.store.representation_end ()); i != n; ++i)
{
rai::account account(i->first);
auto amount (node.store.representation_get (transaction, account));
representatives.put (account.to_account (), amount.convert_to <std::string> ());
}
response_l.add_child ("representatives", representatives);
response (response_l);
}
void rai::rpc_handler::search_pending ()
{
if (rpc.config.enable_control)
@ -1470,6 +1545,57 @@ void rai::rpc_handler::wallet_add ()
}
}
void rai::rpc_handler::wallet_change_seed ()
{
if (rpc.config.enable_control)
{
std::string seed_text (request.get <std::string> ("seed"));
std::string wallet_text (request.get <std::string> ("wallet"));
rai::raw_key seed;
auto error (seed.data.decode_hex (seed_text));
if (!error)
{
rai::uint256_union wallet;
auto error (wallet.decode_hex (wallet_text));
if (!error)
{
auto existing (node.wallets.items.find (wallet));
if (existing != node.wallets.items.end ())
{
rai::transaction transaction (node.store.environment, nullptr, true);
if (existing->second->store.valid_password (transaction))
{
existing->second->store.seed_set (transaction, seed);
boost::property_tree::ptree response_l;
response_l.put ("success", "");
response (response_l);
}
else
{
error_response (response, "Wallet locked");
}
}
else
{
error_response (response, "Wallet not found");
}
}
else
{
error_response (response, "Bad wallet number");
}
}
else
{
error_response (response, "Bad seed");
}
}
else
{
error_response (response, "RPC control is disabled");
}
}
void rai::rpc_handler::wallet_contains ()
{
std::string account_text (request.get <std::string> ("account"));
@ -1583,6 +1709,42 @@ void rai::rpc_handler::wallet_export ()
}
}
void rai::rpc_handler::wallet_frontiers ()
{
std::string wallet_text (request.get <std::string> ("wallet"));
rai::uint256_union wallet;
auto error (wallet.decode_hex (wallet_text));
if (!error)
{
auto existing (node.wallets.items.find (wallet));
if (existing != node.wallets.items.end ())
{
boost::property_tree::ptree response_l;
boost::property_tree::ptree frontiers;
rai::transaction transaction (node.store.environment, nullptr, false);
for (auto i (existing->second->store.begin (transaction)), n (existing->second->store.end ()); i != n; ++i)
{
rai::account account(i->first);
auto latest (node.ledger.latest (transaction, account));
if (!latest.is_zero ())
{
frontiers.put (account.to_account (), latest.to_string ());
}
}
response_l.add_child ("frontiers", frontiers);
response (response_l);
}
else
{
error_response (response, "Wallet not found");
}
}
else
{
error_response (response, "Bad wallet number");
}
}
void rai::rpc_handler::wallet_key_valid ()
{
std::string wallet_text (request.get <std::string> ("wallet"));
@ -1844,6 +2006,10 @@ void rai::rpc_handler::process_request ()
{
account_move ();
}
else if (action == "account_remove")
{
account_remove ();
}
else if (action == "account_representative")
{
account_representative ();
@ -1968,6 +2134,10 @@ void rai::rpc_handler::process_request ()
{
rai_to_raw ();
}
else if (action == "representatives")
{
representatives ();
}
else if (action == "search_pending")
{
search_pending ();
@ -1992,6 +2162,10 @@ void rai::rpc_handler::process_request ()
{
wallet_add ();
}
else if (action == "wallet_change_seed")
{
wallet_change_seed ();
}
else if (action == "wallet_contains")
{
wallet_contains ();
@ -2008,6 +2182,10 @@ void rai::rpc_handler::process_request ()
{
wallet_export ();
}
else if (action == "wallet_frontiers")
{
wallet_frontiers ();
}
else if (action == "wallet_key_valid")
{
wallet_key_valid ();

View file

@ -95,6 +95,7 @@ public:
void account_key ();
void account_list ();
void account_move ();
void account_remove ();
void account_representative ();
void account_representative_set ();
void account_weight ();
@ -126,16 +127,19 @@ public:
void process ();
void rai_to_raw ();
void rai_from_raw ();
void representatives ();
void search_pending ();
void send ();
void stop ();
void validate_account_number ();
void version ();
void wallet_add ();
void wallet_change_seed ();
void wallet_contains ();
void wallet_create ();
void wallet_destroy ();
void wallet_export ();
void wallet_frontiers ();
void wallet_key_valid ();
void wallet_representative ();
void wallet_representative_set ();

View file

@ -600,6 +600,7 @@ wallet (wallet_a)
rai_qt::status::status (rai_qt::wallet & wallet_a) :
wallet (wallet_a)
{
wallet.status->setToolTip ("Wallet status, block count (blocks downloaded)");
active.insert (rai_qt::status_types::nominal);
set_text ();
}
@ -622,17 +623,20 @@ void rai_qt::status::set_text ()
{
wallet.status->setText (text ().c_str ());
wallet.status->setStyleSheet ((std::string ("QLabel {") + color () + "}").c_str ());
wallet.status->setToolTip("Wallet status and wallet block count (blocks remaining to sync)");
}
std::string rai_qt::status::text ()
{
assert (!active.empty ());
std::string result;
rai::transaction transaction (wallet.wallet_m->node.store.environment, nullptr, false);
auto size (wallet.wallet_m->node.store.block_count (transaction));
auto unchecked (wallet.wallet_m->node.store.unchecked_count (transaction));
auto count_string (std::to_string (size.sum ()));
size_t unchecked (0);
std::string count_string;
{
rai::transaction transaction (wallet.wallet_m->node.store.environment, nullptr, false);
auto size (wallet.wallet_m->node.store.block_count (transaction));
unchecked = wallet.wallet_m->node.store.unchecked_count (transaction);
count_string = std::to_string (size.sum ());
}
switch (*active.begin ())
{
@ -661,14 +665,14 @@ std::string rai_qt::status::text ()
assert (false);
break;
}
result += ", Block: ";
if (unchecked != 0)
{
count_string += " (" + std::to_string (unchecked) + ")";
}
result += count_string.c_str ();
return result;
}
@ -706,11 +710,12 @@ std::string rai_qt::status::color ()
return result;
}
rai_qt::wallet::wallet (QApplication & application_a, rai::node & node_a, std::shared_ptr <rai::wallet> wallet_a, rai::account & account_a) :
rai_qt::wallet::wallet (QApplication & application_a, rai_qt::eventloop_processor & processor_a, rai::node & node_a, std::shared_ptr <rai::wallet> wallet_a, rai::account & account_a) :
rendering_ratio (rai::Mrai_ratio),
node (node_a),
wallet_m (wallet_a),
account (account_a),
processor (processor_a),
history (node.ledger, account, rendering_ratio),
accounts (*this),
self (*this, account_a),
@ -1328,6 +1333,7 @@ wallet (wallet_a)
});
refresh_ledger ();
refresh_count ();
block_count->setToolTip ("Block count (blocks downloaded)");
}
void rai_qt::advanced_actions::refresh_count ()

View file

@ -275,7 +275,7 @@ namespace rai_qt {
class wallet : public std::enable_shared_from_this <rai_qt::wallet>
{
public:
wallet (QApplication &, rai::node &, std::shared_ptr <rai::wallet>, rai::account &);
wallet (QApplication &, rai_qt::eventloop_processor &, rai::node &, std::shared_ptr <rai::wallet>, rai::account &);
void start ();
void refresh ();
void update_connected ();
@ -284,7 +284,7 @@ namespace rai_qt {
rai::node & node;
std::shared_ptr <rai::wallet> wallet_m;
rai::account & account;
rai_qt::eventloop_processor processor;
rai_qt::eventloop_processor & processor;
rai_qt::history history;
rai_qt::accounts accounts;
rai_qt::self_pane self;

View file

@ -6,6 +6,7 @@
int main (int argc, char ** argv)
{
QApplication application (argc, argv);
rai_qt::eventloop_processor processor;
static int count (16);
rai::system system (24000, count);
std::unique_ptr <QTabWidget> client_tabs (new QTabWidget);
@ -17,7 +18,7 @@ int main (int argc, char ** argv)
auto wallet (system.nodes [i]->wallets.create (wallet_id));
rai::keypair key;
wallet->insert_adhoc (key.prv);
guis.push_back (std::unique_ptr <rai_qt::wallet> (new rai_qt::wallet (application, *system.nodes [i], wallet, key.pub)));
guis.push_back (std::unique_ptr <rai_qt::wallet> (new rai_qt::wallet (application, processor, *system.nodes [i], wallet, key.pub)));
client_tabs->addTab (guis.back ()->client_window, boost::str (boost::format ("Wallet %1%") % i).c_str ());
}
client_tabs->show ();

View file

@ -9,13 +9,14 @@
#include <QTest>
extern QApplication * test_application;
rai_qt::eventloop_processor processor;
TEST (wallet, construction)
{
rai::system system (24000, 1);
auto wallet_l (system.nodes [0]->wallets.create (rai::uint256_union ()));
auto key (wallet_l->deterministic_insert ());
auto wallet (std::make_shared <rai_qt::wallet> (*test_application, *system.nodes [0], wallet_l, key));
auto wallet (std::make_shared <rai_qt::wallet> (*test_application, processor, *system.nodes [0], wallet_l, key));
wallet->start ();
ASSERT_EQ (key.to_account_split (), wallet->self.account_text->text ().toStdString ());
ASSERT_EQ (1, wallet->accounts.model->rowCount ());
@ -29,7 +30,7 @@ TEST (wallet, status)
auto wallet_l (system.nodes [0]->wallets.create (rai::uint256_union ()));
rai::keypair key;
wallet_l->insert_adhoc (key.prv);
auto wallet (std::make_shared <rai_qt::wallet> (*test_application, *system.nodes [0], wallet_l, key.pub));
auto wallet (std::make_shared <rai_qt::wallet> (*test_application, processor, *system.nodes [0], wallet_l, key.pub));
wallet->start ();
ASSERT_EQ ("Status: Disconnected", wallet->status->text ().toStdString ());
system.nodes [0]->peers.insert (rai::endpoint (boost::asio::ip::address_v6::loopback (), 10000));
@ -56,7 +57,7 @@ TEST (wallet, startup_balance)
auto wallet_l (system.nodes [0]->wallets.create (rai::uint256_union ()));
rai::keypair key;
wallet_l->insert_adhoc (key.prv);
auto wallet (std::make_shared <rai_qt::wallet> (*test_application, *system.nodes [0], wallet_l, key.pub));
auto wallet (std::make_shared <rai_qt::wallet> (*test_application, processor, *system.nodes [0], wallet_l, key.pub));
wallet->start ();
ASSERT_EQ ("Balance: 0", wallet->self.balance_label->text().toStdString ());
}
@ -67,7 +68,7 @@ TEST (wallet, select_account)
auto wallet_l (system.nodes [0]->wallets.create (rai::uint256_union ()));
rai::public_key key1 (wallet_l->deterministic_insert ());
rai::public_key key2 (wallet_l->deterministic_insert ());
auto wallet (std::make_shared <rai_qt::wallet> (*test_application, *system.nodes [0], wallet_l, key1));
auto wallet (std::make_shared <rai_qt::wallet> (*test_application, processor, *system.nodes [0], wallet_l, key1));
wallet->start ();
ASSERT_EQ (key1, wallet->account);
QTest::mouseClick (wallet->show_advanced, Qt::LeftButton);
@ -87,7 +88,7 @@ TEST (wallet, main)
auto wallet_l (system.nodes [0]->wallets.create (rai::uint256_union ()));
rai::keypair key;
wallet_l->insert_adhoc (key.prv);
auto wallet (std::make_shared <rai_qt::wallet> (*test_application, *system.nodes [0], wallet_l, key.pub));
auto wallet (std::make_shared <rai_qt::wallet> (*test_application, processor, *system.nodes [0], wallet_l, key.pub));
wallet->start ();
ASSERT_EQ (wallet->entry_window, wallet->main_stack->currentWidget ());
QTest::mouseClick (wallet->send_blocks, Qt::LeftButton);
@ -120,7 +121,7 @@ TEST (wallet, password_change)
rai::transaction transaction (system.nodes [0]->store.environment, nullptr, false);
account = system.account (transaction, 0);
}
auto wallet (std::make_shared <rai_qt::wallet> (*test_application, *system.nodes [0], system.wallet (0), account));
auto wallet (std::make_shared <rai_qt::wallet> (*test_application, processor, *system.nodes [0], system.wallet (0), account));
wallet->start ();
QTest::mouseClick (wallet->settings_button, Qt::LeftButton);
{
@ -155,7 +156,7 @@ TEST (client, password_nochange)
rai::transaction transaction (system.nodes [0]->store.environment, nullptr, false);
account = system.account (transaction, 0);
}
auto wallet (std::make_shared <rai_qt::wallet> (*test_application, *system.nodes [0], system.wallet (0), account));
auto wallet (std::make_shared <rai_qt::wallet> (*test_application, processor, *system.nodes [0], system.wallet (0), account));
wallet->start ();
QTest::mouseClick (wallet->settings_button, Qt::LeftButton);
auto iterations (0);
@ -200,7 +201,7 @@ TEST (wallet, enter_password)
rai::transaction transaction (system.nodes [0]->store.environment, nullptr, false);
account = system.account (transaction, 0);
}
auto wallet (std::make_shared <rai_qt::wallet> (*test_application, *system.nodes [0], system.wallet (0), account));
auto wallet (std::make_shared <rai_qt::wallet> (*test_application, processor, *system.nodes [0], system.wallet (0), account));
wallet->start ();
ASSERT_NE (-1, wallet->settings.layout->indexOf (wallet->settings.password));
ASSERT_NE (-1, wallet->settings.lock_layout->indexOf (wallet->settings.unlock));
@ -233,7 +234,7 @@ TEST (wallet, send)
system.wallet (0)->insert_adhoc (rai::test_genesis_key.prv);
rai::public_key key1 (system.wallet (1)->insert_adhoc (rai::keypair ().prv));
auto account (rai::test_genesis_key.pub);
auto wallet (std::make_shared <rai_qt::wallet> (*test_application, *system.nodes [0], system.wallet (0), account));
auto wallet (std::make_shared <rai_qt::wallet> (*test_application, processor, *system.nodes [0], system.wallet (0), account));
wallet->start ();
QTest::mouseClick (wallet->send_blocks, Qt::LeftButton);
QTest::keyClicks (wallet->send_account, key1.to_account ().c_str ());
@ -265,7 +266,7 @@ TEST (wallet, send_locked)
rai::keypair key1;
system.wallet (0)->enter_password ("0");
auto account (rai::test_genesis_key.pub);
auto wallet (std::make_shared <rai_qt::wallet> (*test_application, *system.nodes [0], system.wallet (0), account));
auto wallet (std::make_shared <rai_qt::wallet> (*test_application, processor, *system.nodes [0], system.wallet (0), account));
wallet->start ();
QTest::mouseClick (wallet->send_blocks, Qt::LeftButton);
QTest::keyClicks (wallet->send_account, key1.pub.to_account ().c_str ());
@ -291,7 +292,7 @@ TEST (wallet, process_block)
rai::transaction transaction (system.nodes [0]->store.environment, nullptr, false);
account = system.account (transaction, 0);
}
auto wallet (std::make_shared <rai_qt::wallet> (*test_application, *system.nodes [0], system.wallet (0), account));
auto wallet (std::make_shared <rai_qt::wallet> (*test_application, processor, *system.nodes [0], system.wallet (0), account));
wallet->start ();
ASSERT_EQ ("Process", wallet->block_entry.process->text ());
ASSERT_EQ ("Back", wallet->block_entry.back->text ());
@ -322,7 +323,7 @@ TEST (wallet, create_send)
system.wallet (0)->insert_adhoc (rai::test_genesis_key.prv);
system.wallet (0)->insert_adhoc (key.prv);
auto account (rai::test_genesis_key.pub);
auto wallet (std::make_shared <rai_qt::wallet> (*test_application, *system.nodes [0], system.wallet (0), account));
auto wallet (std::make_shared <rai_qt::wallet> (*test_application, processor, *system.nodes [0], system.wallet (0), account));
wallet->start ();
wallet->client_window->show ();
QTest::mouseClick (wallet->show_advanced, Qt::LeftButton);
@ -356,7 +357,7 @@ TEST (wallet, create_open_receive)
ASSERT_NE (latest1, latest2);
system.wallet (0)->insert_adhoc (key.prv);
auto account (rai::test_genesis_key.pub);
auto wallet (std::make_shared <rai_qt::wallet> (*test_application, *system.nodes [0], system.wallet (0), account));
auto wallet (std::make_shared <rai_qt::wallet> (*test_application, processor, *system.nodes [0], system.wallet (0), account));
wallet->start ();
wallet->client_window->show ();
QTest::mouseClick (wallet->show_advanced, Qt::LeftButton);
@ -398,7 +399,7 @@ TEST (wallet, create_change)
rai::system system (24000, 1);
system.wallet (0)->insert_adhoc (rai::test_genesis_key.prv);
auto account (rai::test_genesis_key.pub);
auto wallet (std::make_shared <rai_qt::wallet> (*test_application, *system.nodes [0], system.wallet (0), account));
auto wallet (std::make_shared <rai_qt::wallet> (*test_application, processor, *system.nodes [0], system.wallet (0), account));
wallet->start ();
wallet->client_window->show ();
QTest::mouseClick (wallet->show_advanced, Qt::LeftButton);
@ -452,7 +453,7 @@ TEST (wallet, startup_work)
rai::transaction transaction (system.nodes [0]->store.environment, nullptr, false);
account = system.account (transaction, 0);
}
auto wallet (std::make_shared <rai_qt::wallet> (*test_application, *system.nodes [0], system.wallet (0), account));
auto wallet (std::make_shared <rai_qt::wallet> (*test_application, processor, *system.nodes [0], system.wallet (0), account));
wallet->start ();
QTest::mouseClick (wallet->show_advanced, Qt::LeftButton);
uint64_t work1;
@ -485,7 +486,7 @@ TEST (wallet, block_viewer)
rai::transaction transaction (system.nodes [0]->store.environment, nullptr, false);
account = system.account (transaction, 0);
}
auto wallet (std::make_shared <rai_qt::wallet> (*test_application, *system.nodes [0], system.wallet (0), account));
auto wallet (std::make_shared <rai_qt::wallet> (*test_application, processor, *system.nodes [0], system.wallet (0), account));
wallet->start ();
QTest::mouseClick (wallet->show_advanced, Qt::LeftButton);
ASSERT_NE (-1, wallet->advanced.layout->indexOf (wallet->advanced.block_viewer));
@ -517,7 +518,7 @@ TEST (wallet, import)
stream.open (path.string ().c_str ());
stream << json;
}
auto wallet (std::make_shared <rai_qt::wallet> (*test_application, *system.nodes [1], system.wallet (1), key2.pub));
auto wallet (std::make_shared <rai_qt::wallet> (*test_application, processor, *system.nodes [1], system.wallet (1), key2.pub));
wallet->start ();
QTest::mouseClick (wallet->show_advanced, Qt::LeftButton);
ASSERT_EQ (wallet->advanced.window, wallet->main_stack->currentWidget ());
@ -545,7 +546,7 @@ TEST (wallet, republish)
ASSERT_EQ (rai::process_result::progress, system.nodes [0]->ledger.process (transaction, block).code);
}
auto account (rai::test_genesis_key.pub);
auto wallet (std::make_shared <rai_qt::wallet> (*test_application, *system.nodes [0], system.wallet (0), account));
auto wallet (std::make_shared <rai_qt::wallet> (*test_application, processor, *system.nodes [0], system.wallet (0), account));
wallet->start ();
QTest::mouseClick (wallet->show_advanced, Qt::LeftButton);
ASSERT_EQ (wallet->advanced.window, wallet->main_stack->currentWidget ());
@ -568,7 +569,7 @@ TEST (wallet, ignore_empty_adhoc)
rai::system system (24000, 1);
rai::keypair key1;
system.wallet (0)->insert_adhoc (key1.prv);
auto wallet (std::make_shared <rai_qt::wallet> (*test_application, *system.nodes [0], system.wallet (0), key1.pub));
auto wallet (std::make_shared <rai_qt::wallet> (*test_application, processor, *system.nodes [0], system.wallet (0), key1.pub));
wallet->start ();
QTest::mouseClick (wallet->show_advanced, Qt::LeftButton);
ASSERT_EQ (wallet->advanced.window, wallet->main_stack->currentWidget ());
@ -595,7 +596,7 @@ TEST (wallet, change_seed)
rai::raw_key seed3;
system.wallet (0)->store.seed (seed3, rai::transaction (system.wallet (0)->store.environment, nullptr, false));
auto wallet_key (key1);
auto wallet (std::make_shared <rai_qt::wallet> (*test_application, *system.nodes [0], system.wallet (0), wallet_key));
auto wallet (std::make_shared <rai_qt::wallet> (*test_application, processor, *system.nodes [0], system.wallet (0), wallet_key));
wallet->start ();
QTest::mouseClick (wallet->show_advanced, Qt::LeftButton);
ASSERT_EQ (wallet->advanced.window, wallet->main_stack->currentWidget ());
@ -636,7 +637,7 @@ TEST (wallet, seed_work_generation)
{
rai::system system (24000, 1);
auto key1 (system.wallet (0)->deterministic_insert ());
auto wallet (std::make_shared <rai_qt::wallet> (*test_application, *system.nodes [0], system.wallet (0), key1));
auto wallet (std::make_shared <rai_qt::wallet> (*test_application, processor, *system.nodes [0], system.wallet (0), key1));
wallet->start ();
QTest::mouseClick (wallet->show_advanced, Qt::LeftButton);
ASSERT_EQ (wallet->advanced.window, wallet->main_stack->currentWidget ());
@ -667,7 +668,7 @@ TEST (wallet, backup_seed)
{
rai::system system (24000, 1);
auto key1 (system.wallet (0)->deterministic_insert ());
auto wallet (std::make_shared <rai_qt::wallet> (*test_application, *system.nodes [0], system.wallet (0), key1));
auto wallet (std::make_shared <rai_qt::wallet> (*test_application, processor, *system.nodes [0], system.wallet (0), key1));
wallet->start ();
QTest::mouseClick (wallet->show_advanced, Qt::LeftButton);
ASSERT_EQ (wallet->advanced.window, wallet->main_stack->currentWidget ());
@ -684,7 +685,7 @@ TEST (wallet, import_locked)
rai::system system (24000, 1);
auto key1 (system.wallet (0)->deterministic_insert ());
system.wallet (0)->store.rekey (rai::transaction (system.wallet (0)->store.environment, nullptr, true), "1");
auto wallet (std::make_shared <rai_qt::wallet> (*test_application, *system.nodes [0], system.wallet (0), key1));
auto wallet (std::make_shared <rai_qt::wallet> (*test_application, processor, *system.nodes [0], system.wallet (0), key1));
wallet->start ();
QTest::mouseClick (wallet->show_advanced, Qt::LeftButton);
ASSERT_EQ (wallet->advanced.window, wallet->main_stack->currentWidget ());
@ -711,7 +712,7 @@ TEST (wallet, synchronizing)
rai::system system0 (24000, 1);
rai::system system1 (24001, 1);
auto key1 (system0.wallet (0)->deterministic_insert ());
auto wallet (std::make_shared <rai_qt::wallet> (*test_application, *system0.nodes [0], system0.wallet (0), key1));
auto wallet (std::make_shared <rai_qt::wallet> (*test_application, processor, *system0.nodes [0], system0.wallet (0), key1));
wallet->start ();
{
rai::transaction transaction (system1.nodes [0]->store.environment, nullptr, true);

View file

@ -191,6 +191,7 @@ bool update_config (qt_wallet_config & config_a, boost::filesystem::path const &
int run_wallet (QApplication & application, int argc, char * const * argv)
{
rai_qt::eventloop_processor processor;
auto working (rai::working_path ());
boost::filesystem::create_directories (working);
qt_wallet_config config (working);
@ -245,7 +246,7 @@ int run_wallet (QApplication & application, int argc, char * const * argv)
{
rpc.start ();
}
auto gui (std::make_shared <rai_qt::wallet> (application, *node, wallet, config.account));
auto gui (std::make_shared <rai_qt::wallet> (application, processor, *node, wallet, config.account));
gui->start ();
gui->client_window->show ();
rai::thread_runner runner (service, node->config.io_threads);

View file

@ -2299,7 +2299,7 @@ void rai::block_store::representation_put (MDB_txn * transaction_a, rai::account
rai::store_iterator rai::block_store::representation_begin (MDB_txn * transaction_a)
{
rai::store_iterator result(transaction_a, representation);
rai::store_iterator result (transaction_a, representation);
return result;
}

View file

@ -1,6 +1,7 @@
#pragma once
#include <array>
#include <atomic>
#include <condition_variable>
#include <type_traits>