diff --git a/rai/qt/qt.cpp b/rai/qt/qt.cpp index 67870b90..cb455ef7 100644 --- a/rai/qt/qt.cpp +++ b/rai/qt/qt.cpp @@ -6,7 +6,7 @@ #include -rai_qt::client::client (QApplication & application_a, rai::node & node_a, rai::uint256_union const & wallet_a) : +rai_qt::wallet::wallet (QApplication & application_a, rai::node & node_a, rai::uint256_union const & wallet_a) : node (node_a), password_change (*this), enter_password (*this), @@ -34,10 +34,10 @@ send_count (new QLineEdit), send_blocks_send (new QPushButton ("Send")), send_blocks_back (new QPushButton ("Back")) { - wallet = node.wallets.open (wallet_a); - if (wallet == nullptr) + wallet_m = node.wallets.open (wallet_a); + if (wallet_m == nullptr) { - wallet = node.wallets.create (wallet_a); + wallet_m = node.wallets.create (wallet_a); } send_blocks_layout->addWidget (send_account_label); send_blocks_layout->addWidget (send_account); @@ -105,7 +105,7 @@ send_blocks_back (new QPushButton ("Back")) auto parse_error (account.decode_base58check (account_text_narrow)); if (!parse_error) { - auto send_error (wallet->send (account, coins)); + auto send_error (wallet_m->send (account, coins)); if (!send_error) { QPalette palette; @@ -154,26 +154,26 @@ send_blocks_back (new QPushButton ("Back")) QObject::connect (wallet_add_account, &QPushButton::released, [this] () { rai::keypair key; - wallet->store.insert (key.prv); + wallet_m->store.insert (key.prv); refresh_wallet (); }); node.send_observers.push_back ([this] (rai::send_block const &, rai::account const & account_a, rai::amount const &) { - if (wallet->store.exists (account_a)) + if (wallet_m->store.exists (account_a)) { refresh_wallet (); } }); node.receive_observers.push_back ([this] (rai::receive_block const &, rai::account const & account_a, rai::amount const &) { - if (wallet->store.exists (account_a)) + if (wallet_m->store.exists (account_a)) { refresh_wallet (); } }); node.open_observers.push_back ([this] (rai::open_block const &, rai::account const & account_a, rai::amount const &, rai::account const &) { - if (wallet->store.exists (account_a)) + if (wallet_m->store.exists (account_a)) { refresh_wallet (); } @@ -181,11 +181,11 @@ send_blocks_back (new QPushButton ("Back")) refresh_wallet (); } -void rai_qt::client::refresh_wallet () +void rai_qt::wallet::refresh_wallet () { rai::uint128_t balance; wallet_model->removeRows (0, wallet_model->rowCount ()); - for (auto i (wallet->store.begin ()), j (wallet->store.end ()); i != j; ++i) + for (auto i (wallet_m->store.begin ()), j (wallet_m->store.end ()); i != j; ++i) { QList items; std::string account; @@ -201,17 +201,17 @@ void rai_qt::client::refresh_wallet () balance_label->setText (QString ((std::string ("Balance: ") + std::to_string (rai::scale_down (balance))).c_str ())); } -rai_qt::client::~client () +rai_qt::wallet::~wallet () { } -void rai_qt::client::push_main_stack (QWidget * widget_a) +void rai_qt::wallet::push_main_stack (QWidget * widget_a) { main_stack->addWidget (widget_a); main_stack->setCurrentIndex (main_stack->count () - 1); } -void rai_qt::client::pop_main_stack () +void rai_qt::wallet::pop_main_stack () { main_stack->removeWidget (main_stack->currentWidget ()); } @@ -224,7 +224,7 @@ void rai_qt::password_change::clear () retype->clear (); } -rai_qt::password_change::password_change (rai_qt::client & client_a) : +rai_qt::password_change::password_change (rai_qt::wallet & wallet_a) : window (new QWidget), layout (new QVBoxLayout), password_label (new QLabel ("New password:")), @@ -233,7 +233,7 @@ retype_label (new QLabel ("Retype password:")), retype (new QLineEdit), change (new QPushButton ("Change password")), back (new QPushButton ("Back")), -client (client_a) +wallet (wallet_a) { password->setEchoMode (QLineEdit::EchoMode::Password); layout->addWidget (password_label); @@ -248,11 +248,11 @@ client (client_a) window->setLayout (layout); QObject::connect (change, &QPushButton::released, [this] () { - if (client.wallet->store.valid_password ()) + if (wallet.wallet_m->store.valid_password ()) { if (password->text () == retype->text ()) { - client.wallet->store.rekey (std::string (password->text ().toLocal8Bit ())); + wallet.wallet_m->store.rekey (std::string (password->text ().toLocal8Bit ())); clear (); } else @@ -265,11 +265,11 @@ client (client_a) QObject::connect (back, &QPushButton::released, [this] () { clear (); - client.pop_main_stack (); + wallet.pop_main_stack (); }); } -rai_qt::enter_password::enter_password (rai_qt::client & client_a) : +rai_qt::enter_password::enter_password (rai_qt::wallet & wallet_a) : window (new QWidget), layout (new QVBoxLayout), valid (new QLabel), @@ -277,7 +277,7 @@ password (new QLineEdit), unlock (new QPushButton ("Unlock")), lock (new QPushButton ("Lock")), back (new QPushButton ("Back")), -client (client_a) +wallet (wallet_a) { password->setEchoMode (QLineEdit::EchoMode::Password); layout->addWidget (valid); @@ -289,32 +289,32 @@ client (client_a) window->setLayout (layout); QObject::connect (back, &QPushButton::released, [this] () { - assert (client.main_stack->currentWidget () == window); - client.pop_main_stack (); + assert (wallet.main_stack->currentWidget () == window); + wallet.pop_main_stack (); }); QObject::connect (unlock, &QPushButton::released, [this] () { - client.wallet->store.enter_password (std::string (password->text ().toLocal8Bit ())); + wallet.wallet_m->store.enter_password (std::string (password->text ().toLocal8Bit ())); update_label (); }); QObject::connect (lock, &QPushButton::released, [this] () { rai::uint256_union empty; empty.clear (); - client.wallet->store.password.value_set (empty); + wallet.wallet_m->store.password.value_set (empty); update_label (); }); } void rai_qt::enter_password::activate () { - client.push_main_stack (window); + wallet.push_main_stack (window); update_label (); } void rai_qt::enter_password::update_label () { - if (client.wallet->store.valid_password ()) + if (wallet.wallet_m->store.valid_password ()) { valid->setStyleSheet ("QLabel { color: black }"); valid->setText ("Password: Valid"); @@ -327,7 +327,7 @@ void rai_qt::enter_password::update_label () } } -rai_qt::advanced_actions::advanced_actions (rai_qt::client & client_a) : +rai_qt::advanced_actions::advanced_actions (rai_qt::wallet & wallet_a) : window (new QWidget), layout (new QVBoxLayout), enter_password (new QPushButton ("Enter Password")), @@ -354,7 +354,7 @@ peers_model (new QStringListModel), peers_view (new QListView), peers_refresh (new QPushButton ("Refresh")), peers_back (new QPushButton ("Back")), -client (client_a) +wallet (wallet_a) { ledger_model->setHorizontalHeaderItem (0, new QStandardItem ("Account")); ledger_model->setHorizontalHeaderItem (1, new QStandardItem ("Balance")); @@ -396,31 +396,31 @@ client (client_a) QObject::connect (enter_password, &QPushButton::released, [this] () { - client.enter_password.activate (); + wallet.enter_password.activate (); }); QObject::connect (change_password, &QPushButton::released, [this] () { - client.push_main_stack (client.password_change.window); + wallet.push_main_stack (wallet.password_change.window); }); QObject::connect (wallet_refresh, &QPushButton::released, [this] () { - client.refresh_wallet (); + wallet.refresh_wallet (); }); QObject::connect (show_peers, &QPushButton::released, [this] () { - client.push_main_stack (peers_window); + wallet.push_main_stack (peers_window); }); QObject::connect (show_ledger, &QPushButton::released, [this] () { - client.push_main_stack (ledger_window); + wallet.push_main_stack (ledger_window); }); QObject::connect (back, &QPushButton::released, [this] () { - client.pop_main_stack (); + wallet.pop_main_stack (); }); QObject::connect (peers_back, &QPushButton::released, [this] () { - client.pop_main_stack (); + wallet.pop_main_stack (); }); QObject::connect (peers_refresh, &QPushButton::released, [this] () { @@ -432,7 +432,7 @@ client (client_a) }); QObject::connect (ledger_back, &QPushButton::released, [this] () { - client.pop_main_stack (); + wallet.pop_main_stack (); }); QObject::connect (wallet_add_key_button, &QPushButton::released, [this] () { @@ -445,8 +445,8 @@ client (client_a) palette.setColor (QPalette::Text, Qt::black); wallet_key_line->setPalette (palette); wallet_key_line->clear (); - client.wallet->store.insert (key); - client.refresh_wallet (); + wallet.wallet_m->store.insert (key); + wallet.refresh_wallet (); } else { @@ -457,15 +457,15 @@ client (client_a) }); QObject::connect (search_for_receivables, &QPushButton::released, [this] () { - client.node.processor.search_pending (); + wallet.node.processor.search_pending (); }); QObject::connect (create_block, &QPushButton::released, [this] () { - client.push_main_stack (client.block_creation.window); + wallet.push_main_stack (wallet.block_creation.window); }); QObject::connect (enter_block, &QPushButton::released, [this] () { - client.push_main_stack (client.block_entry.window); + wallet.push_main_stack (wallet.block_entry.window); }); refresh_ledger (); } @@ -473,7 +473,7 @@ client (client_a) void rai_qt::advanced_actions::refresh_peers () { QStringList peers; - for (auto i: client.node.peers.list ()) + for (auto i: wallet.node.peers.list ()) { std::stringstream endpoint; endpoint << i.endpoint.address ().to_string (); @@ -492,13 +492,13 @@ void rai_qt::advanced_actions::refresh_peers () void rai_qt::advanced_actions::refresh_ledger () { ledger_model->removeRows (0, ledger_model->rowCount ()); - for (auto i (client.node.ledger.store.latest_begin()), j (client.node.ledger.store.latest_end ()); i != j; ++i) + for (auto i (wallet.node.ledger.store.latest_begin()), j (wallet.node.ledger.store.latest_end ()); i != j; ++i) { QList items; std::string account; i->first.encode_base58check (account); items.push_back (new QStandardItem (QString (account.c_str ()))); - items.push_back (new QStandardItem (QString (std::to_string (rai::scale_down (client.node.ledger.balance (i->second.hash))).c_str ()))); + items.push_back (new QStandardItem (QString (std::to_string (rai::scale_down (wallet.node.ledger.balance (i->second.hash))).c_str ()))); std::string block_hash; i->second.hash.encode_hex (block_hash); items.push_back (new QStandardItem (QString (block_hash.c_str ()))); @@ -506,14 +506,14 @@ void rai_qt::advanced_actions::refresh_ledger () } } -rai_qt::block_entry::block_entry (rai_qt::client & client_a) : +rai_qt::block_entry::block_entry (rai_qt::wallet & wallet_a) : window (new QWidget), layout (new QVBoxLayout), block (new QPlainTextEdit), status (new QLabel), process (new QPushButton ("Process")), back (new QPushButton ("Back")), -client (client_a) +wallet (wallet_a) { layout->addWidget (block); layout->addWidget (status); @@ -531,7 +531,7 @@ client (client_a) auto block_l (rai::deserialize_block_json (tree)); if (block_l != nullptr) { - client.node.processor.process_receive_republish (std::move (block_l)); + wallet.node.processor.process_receive_republish (std::move (block_l)); } else { @@ -547,11 +547,11 @@ client (client_a) }); QObject::connect (back, &QPushButton::released, [this] () { - client.pop_main_stack (); + wallet.pop_main_stack (); }); } -rai_qt::block_creation::block_creation (rai_qt::client & client_a) : +rai_qt::block_creation::block_creation (rai_qt::wallet & wallet_a) : window (new QWidget), layout (new QVBoxLayout), group (new QButtonGroup), @@ -574,7 +574,7 @@ block (new QPlainTextEdit), status (new QLabel), create (new QPushButton ("Create")), back (new QPushButton ("Back")), -client (client_a) +wallet (wallet_a) { group->addButton (send); group->addButton (receive); @@ -661,7 +661,7 @@ client (client_a) }); QObject::connect (back, &QPushButton::released, [this] () { - client.pop_main_stack (); + wallet.pop_main_stack (); }); send->click (); } @@ -727,13 +727,13 @@ void rai_qt::block_creation::create_send () if (!error) { rai::private_key key; - if (!client.wallet->store.fetch (account_l, key)) + if (!wallet.wallet_m->store.fetch (account_l, key)) { - auto balance (client.node.ledger.account_balance (account_l)); + auto balance (wallet.node.ledger.account_balance (account_l)); if (amount_l.number () <= balance) { rai::frontier frontier; - auto error (client.node.store.latest_get (account_l, frontier)); + auto error (wallet.node.store.latest_get (account_l, frontier)); assert (!error); rai::send_block send; send.hashables.destination = destination_l; @@ -741,7 +741,7 @@ void rai_qt::block_creation::create_send () send.hashables.balance = rai::amount (balance - amount_l.number ()); rai::sign_message (key, account_l, send.hash (), send.signature); key.clear (); - client.node.work_create (send); + wallet.node.work_create (send); std::string block_l; send.serialize_json (block_l); block->setPlainText (QString (block_l.c_str ())); @@ -786,14 +786,14 @@ void rai_qt::block_creation::create_receive () if (!error) { rai::receivable receivable; - if (!client.node.store.pending_get (source_l, receivable)) + if (!wallet.node.store.pending_get (source_l, receivable)) { rai::frontier frontier; - auto error (client.node.store.latest_get (receivable.destination, frontier)); + auto error (wallet.node.store.latest_get (receivable.destination, frontier)); if (!error) { rai::private_key key; - auto error (client.wallet->store.fetch (receivable.destination, key)); + auto error (wallet.wallet_m->store.fetch (receivable.destination, key)); if (!error) { rai::receive_block receive; @@ -801,7 +801,7 @@ void rai_qt::block_creation::create_receive () receive.hashables.source = source_l; rai::sign_message (key, receivable.destination, receive.hash (), receive.signature); key.clear (); - client.node.work_create (receive); + wallet.node.work_create (receive); std::string block_l; receive.serialize_json (block_l); block->setPlainText (QString (block_l.c_str ())); @@ -844,16 +844,16 @@ void rai_qt::block_creation::create_change () if (!error) { rai::frontier frontier; - auto error (client.node.store.latest_get (account_l, frontier)); + auto error (wallet.node.store.latest_get (account_l, frontier)); if (!error) { rai::private_key key; - auto error (client.wallet->store.fetch (account_l, key)); + auto error (wallet.wallet_m->store.fetch (account_l, key)); if (!error) { rai::change_block change (representative_l, frontier.hash, key, account_l); key.clear (); - client.node.work_create (change); + wallet.node.work_create (change); std::string block_l; change.serialize_json (block_l); block->setPlainText (QString (block_l.c_str ())); @@ -896,14 +896,14 @@ void rai_qt::block_creation::create_open () if (!error) { rai::receivable receivable; - if (!client.node.store.pending_get (source_l, receivable)) + if (!wallet.node.store.pending_get (source_l, receivable)) { rai::frontier frontier; - auto error (client.node.store.latest_get (receivable.destination, frontier)); + auto error (wallet.node.store.latest_get (receivable.destination, frontier)); if (error) { rai::private_key key; - auto error (client.wallet->store.fetch (receivable.destination, key)); + auto error (wallet.wallet_m->store.fetch (receivable.destination, key)); if (!error) { rai::open_block open; @@ -911,7 +911,7 @@ void rai_qt::block_creation::create_open () open.hashables.representative = representative_l; rai::sign_message (key, receivable.destination, open.hash (), open.signature); key.clear (); - client.node.work_create (open); + wallet.node.work_create (open); std::string block_l; open.serialize_json (block_l); block->setPlainText (QString (block_l.c_str ())); diff --git a/rai/qt/qt.hpp b/rai/qt/qt.hpp index 7c52249d..d4e9d0bf 100644 --- a/rai/qt/qt.hpp +++ b/rai/qt/qt.hpp @@ -8,11 +8,11 @@ #include namespace rai_qt { - class client; + class wallet; class password_change { public: - password_change (rai_qt::client &); + password_change (rai_qt::wallet &); void clear (); QWidget * window; QVBoxLayout * layout; @@ -22,12 +22,12 @@ namespace rai_qt { QLineEdit * retype; QPushButton * change; QPushButton * back; - rai_qt::client & client; + rai_qt::wallet & wallet; }; class enter_password { public: - enter_password (rai_qt::client &); + enter_password (rai_qt::wallet &); void activate (); void update_label (); QWidget * window; @@ -37,12 +37,12 @@ namespace rai_qt { QPushButton * unlock; QPushButton * lock; QPushButton * back; - rai_qt::client & client; + rai_qt::wallet & wallet; }; class advanced_actions { public: - advanced_actions (rai_qt::client &); + advanced_actions (rai_qt::wallet &); QWidget * window; QVBoxLayout * layout; QPushButton * enter_password; @@ -72,7 +72,7 @@ namespace rai_qt { QPushButton * peers_refresh; QPushButton * peers_back; - rai_qt::client & client; + rai_qt::wallet & wallet; private: void refresh_ledger (); void refresh_peers (); @@ -80,19 +80,19 @@ namespace rai_qt { class block_entry { public: - block_entry (rai_qt::client &); + block_entry (rai_qt::wallet &); QWidget * window; QVBoxLayout * layout; QPlainTextEdit * block; QLabel * status; QPushButton * process; QPushButton * back; - rai_qt::client & client; + rai_qt::wallet & wallet; }; class block_creation { public: - block_creation (rai_qt::client &); + block_creation (rai_qt::wallet &); void deactivate_all (); void activate_send (); void activate_receive (); @@ -124,13 +124,13 @@ namespace rai_qt { QLabel * status; QPushButton * create; QPushButton * back; - rai_qt::client & client; + rai_qt::wallet & wallet; }; - class client + class wallet { public: - client (QApplication &, rai::node &, rai::uint256_union const &); - ~client (); + wallet (QApplication &, rai::node &, rai::uint256_union const &); + ~wallet (); rai::node & node; rai_qt::password_change password_change; rai_qt::enter_password enter_password; @@ -165,6 +165,6 @@ namespace rai_qt { void pop_main_stack (); void push_main_stack (QWidget *); void refresh_wallet (); - std::shared_ptr wallet; + std::shared_ptr wallet_m; }; } \ No newline at end of file diff --git a/rai/qt_system/entry.cpp b/rai/qt_system/entry.cpp index 03b12358..98d6489f 100644 --- a/rai/qt_system/entry.cpp +++ b/rai/qt_system/entry.cpp @@ -8,13 +8,13 @@ int main (int argc, char ** argv) static int count (16); rai::system system (24000, count); std::unique_ptr client_tabs (new QTabWidget); - std::vector > guis; + std::vector > guis; for (auto i (0); i < count; ++i) { rai::uint256_union wallet; rai::random_pool.GenerateBlock (wallet.bytes.data (), wallet.bytes.size ()); - guis.push_back (std::unique_ptr (new rai_qt::client (application, *system.nodes [i], wallet))); - client_tabs->addTab (guis.back ()->client_window, boost::str (boost::format ("Client %1%") % i).c_str ()); + guis.push_back (std::unique_ptr (new rai_qt::wallet (application, *system.nodes [i], wallet))); + client_tabs->addTab (guis.back ()->client_window, boost::str (boost::format ("Wallet %1%") % i).c_str ()); } client_tabs->show (); std::thread network_thread ([&system] () diff --git a/rai/qt_test/qt.cpp b/rai/qt_test/qt.cpp index 5313fe21..83ebea78 100644 --- a/rai/qt_test/qt.cpp +++ b/rai/qt_test/qt.cpp @@ -7,57 +7,57 @@ #include #include -TEST (client, construction) +TEST (wallet, construction) { rai::system system (24000, 1); int argc (0); QApplication application (argc, nullptr); - rai_qt::client client (application, *system.nodes [0], rai::uint256_union ()); + rai_qt::wallet wallet (application, *system.nodes [0], rai::uint256_union ()); } -TEST (client, main) +TEST (wallet, main) { rai::system system (24000, 1); int argc (0); QApplication application (argc, nullptr); - rai_qt::client client (application, *system.nodes [0], rai::uint256_union ()); - ASSERT_EQ (client.entry_window, client.main_stack->currentWidget ()); - QTest::mouseClick (client.send_blocks, Qt::LeftButton); - ASSERT_EQ (client.send_blocks_window, client.main_stack->currentWidget ()); - QTest::mouseClick (client.send_blocks_back, Qt::LeftButton); - ASSERT_EQ (client.entry_window, client.main_stack->currentWidget ()); - QTest::mouseClick (client.show_advanced, Qt::LeftButton); - ASSERT_EQ (client.advanced.window, client.main_stack->currentWidget ()); - QTest::mouseClick (client.advanced.change_password, Qt::LeftButton); - ASSERT_EQ (client.password_change.window, client.main_stack->currentWidget ()); - QTest::mouseClick (client.password_change.back, Qt::LeftButton); - QTest::mouseClick (client.advanced.show_ledger, Qt::LeftButton); - ASSERT_EQ (client.advanced.ledger_window, client.main_stack->currentWidget ()); - QTest::mouseClick (client.advanced.ledger_back, Qt::LeftButton); - ASSERT_EQ (client.advanced.window, client.main_stack->currentWidget ()); - QTest::mouseClick (client.advanced.show_peers, Qt::LeftButton); - ASSERT_EQ (client.advanced.peers_window, client.main_stack->currentWidget ()); - QTest::mouseClick (client.advanced.peers_back, Qt::LeftButton); - ASSERT_EQ (client.advanced.window, client.main_stack->currentWidget ()); - QTest::mouseClick (client.advanced.back, Qt::LeftButton); - ASSERT_EQ (client.entry_window, client.main_stack->currentWidget ()); + rai_qt::wallet wallet (application, *system.nodes [0], rai::uint256_union ()); + ASSERT_EQ (wallet.entry_window, wallet.main_stack->currentWidget ()); + QTest::mouseClick (wallet.send_blocks, Qt::LeftButton); + ASSERT_EQ (wallet.send_blocks_window, wallet.main_stack->currentWidget ()); + QTest::mouseClick (wallet.send_blocks_back, Qt::LeftButton); + ASSERT_EQ (wallet.entry_window, wallet.main_stack->currentWidget ()); + QTest::mouseClick (wallet.show_advanced, Qt::LeftButton); + ASSERT_EQ (wallet.advanced.window, wallet.main_stack->currentWidget ()); + QTest::mouseClick (wallet.advanced.change_password, Qt::LeftButton); + ASSERT_EQ (wallet.password_change.window, wallet.main_stack->currentWidget ()); + QTest::mouseClick (wallet.password_change.back, Qt::LeftButton); + QTest::mouseClick (wallet.advanced.show_ledger, Qt::LeftButton); + ASSERT_EQ (wallet.advanced.ledger_window, wallet.main_stack->currentWidget ()); + QTest::mouseClick (wallet.advanced.ledger_back, Qt::LeftButton); + ASSERT_EQ (wallet.advanced.window, wallet.main_stack->currentWidget ()); + QTest::mouseClick (wallet.advanced.show_peers, Qt::LeftButton); + ASSERT_EQ (wallet.advanced.peers_window, wallet.main_stack->currentWidget ()); + QTest::mouseClick (wallet.advanced.peers_back, Qt::LeftButton); + ASSERT_EQ (wallet.advanced.window, wallet.main_stack->currentWidget ()); + QTest::mouseClick (wallet.advanced.back, Qt::LeftButton); + ASSERT_EQ (wallet.entry_window, wallet.main_stack->currentWidget ()); } -TEST (client, password_change) +TEST (wallet, password_change) { rai::system system (24000, 1); int argc (0); QApplication application (argc, nullptr); - rai_qt::client client (application, *system.nodes [0], system.nodes [0]->wallets.items.begin ()->first); - QTest::mouseClick (client.show_advanced, Qt::LeftButton); - QTest::mouseClick (client.advanced.change_password, Qt::LeftButton); + rai_qt::wallet wallet (application, *system.nodes [0], system.nodes [0]->wallets.items.begin ()->first); + QTest::mouseClick (wallet.show_advanced, Qt::LeftButton); + QTest::mouseClick (wallet.advanced.change_password, Qt::LeftButton); ASSERT_NE (system.wallet (0)->store.derive_key ("1"), system.wallet (0)->store.password.value ()); - QTest::keyClicks (client.password_change.password, "1"); - QTest::keyClicks (client.password_change.retype, "1"); - QTest::mouseClick (client.password_change.change, Qt::LeftButton); + QTest::keyClicks (wallet.password_change.password, "1"); + QTest::keyClicks (wallet.password_change.retype, "1"); + QTest::mouseClick (wallet.password_change.change, Qt::LeftButton); ASSERT_EQ (system.wallet (0)->store.derive_key ("1"), system.wallet (0)->store.password.value ()); - ASSERT_EQ ("", client.password_change.password->text ()); - ASSERT_EQ ("", client.password_change.retype->text ()); + ASSERT_EQ ("", wallet.password_change.password->text ()); + ASSERT_EQ ("", wallet.password_change.retype->text ()); } TEST (client, password_nochange) @@ -65,43 +65,43 @@ TEST (client, password_nochange) rai::system system (24000, 1); int argc (0); QApplication application (argc, nullptr); - rai_qt::client client (application, *system.nodes [0], system.nodes [0]->wallets.items.begin ()->first); - QTest::mouseClick (client.show_advanced, Qt::LeftButton); - QTest::mouseClick (client.advanced.change_password, Qt::LeftButton); + rai_qt::wallet wallet (application, *system.nodes [0], system.nodes [0]->wallets.items.begin ()->first); + QTest::mouseClick (wallet.show_advanced, Qt::LeftButton); + QTest::mouseClick (wallet.advanced.change_password, Qt::LeftButton); ASSERT_EQ (system.wallet (0)->store.derive_key (""), system.wallet (0)->store.password.value ()); - QTest::keyClicks (client.password_change.password, "1"); - QTest::keyClicks (client.password_change.retype, "2"); - QTest::mouseClick (client.password_change.change, Qt::LeftButton); + QTest::keyClicks (wallet.password_change.password, "1"); + QTest::keyClicks (wallet.password_change.retype, "2"); + QTest::mouseClick (wallet.password_change.change, Qt::LeftButton); ASSERT_EQ (system.wallet (0)->store.derive_key (""), system.wallet (0)->store.password.value ()); - ASSERT_EQ ("1", client.password_change.password->text ()); - ASSERT_EQ ("2", client.password_change.retype->text ()); + ASSERT_EQ ("1", wallet.password_change.password->text ()); + ASSERT_EQ ("2", wallet.password_change.retype->text ()); } -TEST (client, enter_password) +TEST (wallet, enter_password) { rai::system system (24000, 1); int argc (0); QApplication application (argc, nullptr); - rai_qt::client client (application, *system.nodes [0], system.nodes [0]->wallets.items.begin ()->first); - ASSERT_NE (-1, client.enter_password.layout->indexOf (client.enter_password.valid)); - ASSERT_NE (-1, client.enter_password.layout->indexOf (client.enter_password.password)); - ASSERT_NE (-1, client.enter_password.layout->indexOf (client.enter_password.unlock)); - ASSERT_NE (-1, client.enter_password.layout->indexOf (client.enter_password.lock)); - ASSERT_NE (-1, client.enter_password.layout->indexOf (client.enter_password.back)); + rai_qt::wallet wallet (application, *system.nodes [0], system.nodes [0]->wallets.items.begin ()->first); + ASSERT_NE (-1, wallet.enter_password.layout->indexOf (wallet.enter_password.valid)); + ASSERT_NE (-1, wallet.enter_password.layout->indexOf (wallet.enter_password.password)); + ASSERT_NE (-1, wallet.enter_password.layout->indexOf (wallet.enter_password.unlock)); + ASSERT_NE (-1, wallet.enter_password.layout->indexOf (wallet.enter_password.lock)); + ASSERT_NE (-1, wallet.enter_password.layout->indexOf (wallet.enter_password.back)); ASSERT_FALSE (system.wallet (0)->store.rekey ("abc")); - QTest::mouseClick (client.show_advanced, Qt::LeftButton); - QTest::mouseClick (client.advanced.enter_password, Qt::LeftButton); - QTest::keyClicks (client.enter_password.password, "a"); - QTest::mouseClick (client.enter_password.unlock, Qt::LeftButton); - ASSERT_EQ ("Password: INVALID", client.enter_password.valid->text ()); - client.enter_password.password->setText (""); - QTest::keyClicks (client.enter_password.password, "abc"); - QTest::mouseClick (client.enter_password.unlock, Qt::LeftButton); - ASSERT_EQ ("Password: Valid", client.enter_password.valid->text ()); - ASSERT_EQ ("", client.enter_password.password->text ()); + QTest::mouseClick (wallet.show_advanced, Qt::LeftButton); + QTest::mouseClick (wallet.advanced.enter_password, Qt::LeftButton); + QTest::keyClicks (wallet.enter_password.password, "a"); + QTest::mouseClick (wallet.enter_password.unlock, Qt::LeftButton); + ASSERT_EQ ("Password: INVALID", wallet.enter_password.valid->text ()); + wallet.enter_password.password->setText (""); + QTest::keyClicks (wallet.enter_password.password, "abc"); + QTest::mouseClick (wallet.enter_password.unlock, Qt::LeftButton); + ASSERT_EQ ("Password: Valid", wallet.enter_password.valid->text ()); + ASSERT_EQ ("", wallet.enter_password.password->text ()); } -TEST (client, send) +TEST (wallet, send) { rai::system system (24000, 2); system.wallet (0)->store.insert (rai::test_genesis_key.prv); @@ -111,41 +111,41 @@ TEST (client, send) system.wallet (1)->store.insert (key1.prv); int argc (0); QApplication application (argc, nullptr); - rai_qt::client client (application, *system.nodes [0], system.nodes [0]->wallets.items.begin ()->first); - QTest::mouseClick (client.send_blocks, Qt::LeftButton); - QTest::keyClicks (client.send_account, account.c_str ()); - QTest::keyClicks (client.send_count, "2"); - QTest::mouseClick (client.send_blocks_send, Qt::LeftButton); - while (client.node.ledger.account_balance (key1.pub).is_zero ()) + rai_qt::wallet wallet (application, *system.nodes [0], system.nodes [0]->wallets.items.begin ()->first); + QTest::mouseClick (wallet.send_blocks, Qt::LeftButton); + QTest::keyClicks (wallet.send_account, account.c_str ()); + QTest::keyClicks (wallet.send_count, "2"); + QTest::mouseClick (wallet.send_blocks_send, Qt::LeftButton); + while (wallet.node.ledger.account_balance (key1.pub).is_zero ()) { system.service->poll_one (); system.processor.poll_one (); } - ASSERT_EQ (rai::scale_up (2), client.node.ledger.account_balance (key1.pub)); - QTest::mouseClick (client.send_blocks_back, Qt::LeftButton); - QTest::mouseClick (client.show_advanced, Qt::LeftButton); - QTest::mouseClick (client.advanced.show_ledger, Qt::LeftButton); - QTest::mouseClick (client.advanced.ledger_refresh, Qt::LeftButton); - ASSERT_EQ (2, client.advanced.ledger_model->rowCount ()); - ASSERT_EQ (3, client.advanced.ledger_model->columnCount ()); - auto item (client.advanced.ledger_model->itemFromIndex (client.advanced.ledger_model->index (1, 1))); + ASSERT_EQ (rai::scale_up (2), wallet.node.ledger.account_balance (key1.pub)); + QTest::mouseClick (wallet.send_blocks_back, Qt::LeftButton); + QTest::mouseClick (wallet.show_advanced, Qt::LeftButton); + QTest::mouseClick (wallet.advanced.show_ledger, Qt::LeftButton); + QTest::mouseClick (wallet.advanced.ledger_refresh, Qt::LeftButton); + ASSERT_EQ (2, wallet.advanced.ledger_model->rowCount ()); + ASSERT_EQ (3, wallet.advanced.ledger_model->columnCount ()); + auto item (wallet.advanced.ledger_model->itemFromIndex (wallet.advanced.ledger_model->index (1, 1))); ASSERT_EQ ("2", item->text ().toStdString ()); } -TEST (client, process_block) +TEST (wallet, process_block) { rai::system system (24000, 1); int argc (0); QApplication application (argc, nullptr); - rai_qt::client client (application, *system.nodes [0], system.nodes [0]->wallets.items.begin ()->first); - ASSERT_EQ ("Process", client.block_entry.process->text ()); - ASSERT_EQ ("Back", client.block_entry.back->text ()); + rai_qt::wallet wallet (application, *system.nodes [0], system.nodes [0]->wallets.items.begin ()->first); + ASSERT_EQ ("Process", wallet.block_entry.process->text ()); + ASSERT_EQ ("Back", wallet.block_entry.back->text ()); rai::keypair key1; - ASSERT_EQ (client.entry_window, client.main_stack->currentWidget ()); - QTest::mouseClick (client.show_advanced, Qt::LeftButton); - QTest::mouseClick (client.advanced.enter_block, Qt::LeftButton); - ASSERT_EQ (client.block_entry.window, client.main_stack->currentWidget ()); + ASSERT_EQ (wallet.entry_window, wallet.main_stack->currentWidget ()); + QTest::mouseClick (wallet.show_advanced, Qt::LeftButton); + QTest::mouseClick (wallet.advanced.enter_block, Qt::LeftButton); + ASSERT_EQ (wallet.block_entry.window, wallet.main_stack->currentWidget ()); rai::send_block send; send.hashables.destination = key1.pub; send.hashables.previous = system.nodes [0]->ledger.latest (rai::genesis_account); @@ -161,14 +161,14 @@ TEST (client, process_block) std::string signature; send.signature.encode_hex (signature); auto block_json (boost::str (boost::format ("{\"type\": \"send\", \"previous\": \"%1%\", \"balance\": \"%2%\", \"destination\": \"%3%\", \"work\": \"%4%\", \"signature\": \"%5%\"}") % previous % balance % destination % rai::to_string_hex (send.work) % signature)); - QTest::keyClicks (client.block_entry.block, block_json.c_str ()); - QTest::mouseClick (client.block_entry.process, Qt::LeftButton); + QTest::keyClicks (wallet.block_entry.block, block_json.c_str ()); + QTest::mouseClick (wallet.block_entry.process, Qt::LeftButton); ASSERT_EQ (send.hash (), system.nodes [0]->ledger.latest (rai::genesis_account)); - QTest::mouseClick(client.block_entry.back, Qt::LeftButton); - ASSERT_EQ (client.advanced.window, client.main_stack->currentWidget ()); + QTest::mouseClick(wallet.block_entry.back, Qt::LeftButton); + ASSERT_EQ (wallet.advanced.window, wallet.main_stack->currentWidget ()); } -TEST (client, create_send) +TEST (wallet, create_send) { rai::keypair key; rai::system system (24000, 1); @@ -176,19 +176,19 @@ TEST (client, create_send) system.wallet (0)->store.insert (key.prv); int argc (0); QApplication application (argc, nullptr); - rai_qt::client client (application, *system.nodes [0], system.nodes [0]->wallets.items.begin ()->first); - QTest::mouseClick (client.show_advanced, Qt::LeftButton); - QTest::mouseClick (client.advanced.create_block, Qt::LeftButton); - QTest::mouseClick (client.block_creation.send, Qt::LeftButton); + rai_qt::wallet wallet (application, *system.nodes [0], system.nodes [0]->wallets.items.begin ()->first); + QTest::mouseClick (wallet.show_advanced, Qt::LeftButton); + QTest::mouseClick (wallet.advanced.create_block, Qt::LeftButton); + QTest::mouseClick (wallet.block_creation.send, Qt::LeftButton); std::string account; rai::test_genesis_key.pub.encode_base58check (account); - QTest::keyClicks (client.block_creation.account, account.c_str ()); - QTest::keyClicks (client.block_creation.amount, "56bc75e2d63100000"); + QTest::keyClicks (wallet.block_creation.account, account.c_str ()); + QTest::keyClicks (wallet.block_creation.amount, "56bc75e2d63100000"); std::string destination; key.pub.encode_base58check (destination); - QTest::keyClicks (client.block_creation.destination, destination.c_str ()); - QTest::mouseClick (client.block_creation.create, Qt::LeftButton); - std::string json (client.block_creation.block->toPlainText ().toStdString ()); + QTest::keyClicks (wallet.block_creation.destination, destination.c_str ()); + QTest::mouseClick (wallet.block_creation.create, Qt::LeftButton); + std::string json (wallet.block_creation.block->toPlainText ().toStdString ()); ASSERT_FALSE (json.empty ()); rai::send_block send; boost::property_tree::ptree tree1; diff --git a/rai/qt_wallet/entry.cpp b/rai/qt_wallet/entry.cpp index cbadf170..ec88b781 100644 --- a/rai/qt_wallet/entry.cpp +++ b/rai/qt_wallet/entry.cpp @@ -5,16 +5,16 @@ #include -class qt_client_config +class qt_wallet_config { public: - qt_client_config () : + qt_wallet_config () : peering_port (rai::network::node_port) { bootstrap_peers.push_back ("rai.raiblocks.net"); rai::random_pool.GenerateBlock (wallet.bytes.data (), wallet.bytes.size ()); } - qt_client_config (bool & error_a, std::istream & stream_a) + qt_wallet_config (bool & error_a, std::istream & stream_a) { error_a = false; boost::property_tree::ptree tree; @@ -73,13 +73,13 @@ int main (int argc, char * const * argv) { auto working (boost::filesystem::system_complete (argv[0]).parent_path ()); auto config_error (false); - qt_client_config config; + qt_wallet_config config; auto config_path ((working / "config.json").string ()); std::ifstream config_file; config_file.open (config_path); if (!config_file.fail ()) { - config = qt_client_config (config_error, config_file); + config = qt_wallet_config (config_error, config_file); } else { @@ -105,7 +105,7 @@ int main (int argc, char * const * argv) { node->bootstrap_peers = config.bootstrap_peers; node->start (); - std::unique_ptr gui (new rai_qt::client (application, *node, config.wallet)); + std::unique_ptr gui (new rai_qt::wallet (application, *node, config.wallet)); gui->client_window->show (); std::thread network_thread ([&service] () {