From e0ec9cb3f4156053a8a12c740b303d06d272eabf Mon Sep 17 00:00:00 2001 From: SergiySW Date: Mon, 28 Aug 2017 12:13:16 +0300 Subject: [PATCH 1/3] Feedback to incorrect send & seed import --- rai/qt/qt.cpp | 125 ++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 106 insertions(+), 19 deletions(-) diff --git a/rai/qt/qt.cpp b/rai/qt/qt.cpp index 1c6740f7..b05a2a6c 100755 --- a/rai/qt/qt.cpp +++ b/rai/qt/qt.cpp @@ -435,11 +435,32 @@ wallet (wallet_a) else { show_line_error (*seed); + show_button_error (*import_seed); + if (seed->text ().toStdString ().size () > 64) + { + import_seed->setText ("Incorrect seed. Max 64 characters allowed"); + } + else + { + import_seed->setText ("Incorrect seed. Only HEX characters allowed"); + } + this->wallet.node.alarm.add (std::chrono::system_clock::now () + std::chrono::seconds (5), [this] () + { + show_button_ok (*import_seed); + import_seed->setText ("Import seed"); + }); } } else { show_line_error (*clear_line); + show_button_error (*import_seed); + import_seed->setText ("Type words 'clear keys'"); + this->wallet.node.alarm.add (std::chrono::system_clock::now () + std::chrono::seconds (5), [this] () + { + show_button_ok (*import_seed); + import_seed->setText ("Import seed"); + }); } }); } @@ -934,51 +955,117 @@ void rai_qt::wallet::start () auto parse_error (account_l.decode_account (account_text_narrow)); if (!parse_error) { - this_l->send_blocks_send->setEnabled (false); - this_l->node.background ([this_w, account_l, actual] () + auto balance (this_l->node.balance (this_l->account)); + if (actual <= balance) { - if (auto this_l = this_w.lock ()) + rai::transaction transaction (this_l->wallet_m->store.environment, nullptr, false); + if (this_l->wallet_m->store.valid_password (transaction)) { - this_l->wallet_m->send_async (this_l->account, account_l, actual, [this_w] (std::shared_ptr block_a) + this_l->send_blocks_send->setEnabled (false); + this_l->node.background ([this_w, account_l, actual] () { if (auto this_l = this_w.lock ()) { - auto succeeded (block_a != nullptr); - this_l->application.postEvent (&this_l->processor, new eventloop_event ([this_w, succeeded] () + this_l->wallet_m->send_async (this_l->account, account_l, actual, [this_w] (std::shared_ptr block_a) { if (auto this_l = this_w.lock ()) { - this_l->send_blocks_send->setEnabled (true); - if (succeeded) + auto succeeded (block_a != nullptr); + this_l->application.postEvent (&this_l->processor, new eventloop_event ([this_w, succeeded] () { - this_l->send_count->clear (); - this_l->send_account->clear (); - this_l->accounts.refresh (); - } - else - { - show_line_error (*this_l->send_count); - } + if (auto this_l = this_w.lock ()) + { + this_l->send_blocks_send->setEnabled (true); + if (succeeded) + { + this_l->send_count->clear (); + this_l->send_account->clear (); + this_l->accounts.refresh (); + } + else + { + show_line_error (*this_l->send_count); + } + } + })); } - })); + }); } }); } - }); + else + { + show_button_error (*this_l->send_blocks_send); + this_l->send_blocks_send->setText ("Wallet is locked, unlock it to send"); + this_l->node.alarm.add (std::chrono::system_clock::now () + std::chrono::seconds (5), [this_w] () + { + if (auto this_l = this_w.lock ()) + { + show_button_ok (*this_l->send_blocks_send); + this_l->send_blocks_send->setText ("Send"); + } + }); + } + } + else + { + show_line_error (*this_l->send_count); + show_button_error (*this_l->send_blocks_send); + this_l->send_blocks_send->setText ("Not enough balance"); + this_l->node.alarm.add (std::chrono::system_clock::now () + std::chrono::seconds (5), [this_w] () + { + if (auto this_l = this_w.lock ()) + { + show_button_ok (*this_l->send_blocks_send); + this_l->send_blocks_send->setText ("Send"); + } + }); + } } else { show_line_error (*this_l->send_account); + show_button_error (*this_l->send_blocks_send); + this_l->send_blocks_send->setText ("Bad destination account"); + this_l->node.alarm.add (std::chrono::system_clock::now () + std::chrono::seconds (5), [this_w] () + { + if (auto this_l = this_w.lock ()) + { + show_button_ok (*this_l->send_blocks_send); + this_l->send_blocks_send->setText ("Send"); + } + }); } } else { - show_line_error (*this_l->send_account); + show_line_error (*this_l->send_count); + show_button_error (*this_l->send_blocks_send); + this_l->send_blocks_send->setText ("Invalid amount"); + this_l->node.alarm.add (std::chrono::system_clock::now () + std::chrono::seconds (5), [this_w] () + { + if (auto this_l = this_w.lock ()) + { + show_line_ok (*this_l->send_account); + show_button_ok (*this_l->send_blocks_send); + this_l->send_blocks_send->setText ("Send"); + } + }); } } else { show_line_error (*this_l->send_count); + show_button_error (*this_l->send_blocks_send); + this_l->send_blocks_send->setText ("Invalid amount"); + this_l->node.alarm.add (std::chrono::system_clock::now () + std::chrono::seconds (5), [this_w] () + { + if (auto this_l = this_w.lock ()) + { + show_button_ok (*this_l->send_blocks_send); + this_l->send_blocks_send->setText ("Send"); + } + }); } } }); From 78a5e71de7da660fa24978d405003a7e1a23508d Mon Sep 17 00:00:00 2001 From: SergiySW Date: Tue, 29 Aug 2017 23:47:19 +0300 Subject: [PATCH 2/3] GUI: send amount feedback --- rai/qt/qt.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rai/qt/qt.cpp b/rai/qt/qt.cpp index b05a2a6c..a398d255 100755 --- a/rai/qt/qt.cpp +++ b/rai/qt/qt.cpp @@ -1041,7 +1041,7 @@ void rai_qt::wallet::start () { show_line_error (*this_l->send_count); show_button_error (*this_l->send_blocks_send); - this_l->send_blocks_send->setText ("Invalid amount"); + this_l->send_blocks_send->setText ("Amount too big"); this_l->node.alarm.add (std::chrono::system_clock::now () + std::chrono::seconds (5), [this_w] () { if (auto this_l = this_w.lock ()) @@ -1057,7 +1057,7 @@ void rai_qt::wallet::start () { show_line_error (*this_l->send_count); show_button_error (*this_l->send_blocks_send); - this_l->send_blocks_send->setText ("Invalid amount"); + this_l->send_blocks_send->setText ("Bad amount number"); this_l->node.alarm.add (std::chrono::system_clock::now () + std::chrono::seconds (5), [this_w] () { if (auto this_l = this_w.lock ()) From e26fc46ec070f241f45c7a1927d844d8e3275be9 Mon Sep 17 00:00:00 2001 From: SergiySW Date: Sat, 9 Sep 2017 23:54:54 +0300 Subject: [PATCH 3/3] GUI: unlock wallet with empty password at startup --- rai/qt/qt.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/rai/qt/qt.cpp b/rai/qt/qt.cpp index a398d255..fe87bdf0 100755 --- a/rai/qt/qt.cpp +++ b/rai/qt/qt.cpp @@ -1083,7 +1083,7 @@ void rai_qt::wallet::start () this_l->push_main_stack (this_l->send_blocks_window); } }); - node.observers.blocks.add ([this_w] (rai::block const &, rai::account const & account_a, rai::amount const &) + node.observers.blocks.add ([this_w] (std::shared_ptr , rai::account const & account_a, rai::amount const &) { if (auto this_l = this_w.lock ()) { @@ -1237,9 +1237,10 @@ void rai_qt::wallet::update_connected () void rai_qt::wallet::empty_password () { - rai::raw_key empty; - empty.data.clear (); - wallet_m->store.password.value_set (empty); + this->node.alarm.add (std::chrono::system_clock::now () + std::chrono::seconds (3), [this] () + { + wallet_m->enter_password (std::string ("")); + }); } void rai_qt::wallet::change_rendering_ratio (rai::uint128_t const & rendering_ratio_a)