Skip to content

Commit

Permalink
Merge pull request Beldex-Coin#126 from MogamboPuri/prepare-registrat…
Browse files Browse the repository at this point in the history
…ion-update

Prepare registration update
  • Loading branch information
sanada08 authored Nov 14, 2023
2 parents 5c3acd6 + f97e2ce commit ec797f5
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions src/daemon/rpc_command_executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,16 @@ namespace {
return input_line_result::yes;
}

input_line_result input_line_cancel_get_input(char const *msg, std::string &input)
{
std::string prompt = msg;
prompt += " (C/Cancel): ";
input = input_line(prompt);

if (command_line::is_cancel(input)) return input_line_result::cancel;
return input_line_result::yes;
}

const char *get_address_type_name(epee::net_utils::address_type address_type)
{
switch (address_type)
Expand Down Expand Up @@ -2214,30 +2224,27 @@ bool rpc_command_executor::prepare_registration(bool force_registration)
bool valid_address = false;
while (!valid_address && tries < 3)
{
last_input_result = input_line_back_cancel_get_input("Enter the Beldex address for the operator", address_str);
last_input_result = input_line_cancel_get_input("Enter the Beldex address for the operator", address_str);
if (cryptonote::is_valid_address(address_str, nettype))
{
valid_address = true;
}
else if (last_input_result == input_line_result::cancel)
{
step = register_step::cancelled_by_user;
break;
}
else
{
std::cout << "\033[1;31mInvalid address: " << address_str << " Please try again.\033[0m\n"<< std::endl;
std::cout << "\033[1;31mInvalid address: \033[0m" << address_str << std::endl;
tries++;
}
}
if (!valid_address)
{
std::cout << "Max tries exceeded. Aborting the process." << std::endl;
std::cout << "Aborting the process." << std::endl;
return false;
}
if (last_input_result == input_line_result::back)
continue;

if (last_input_result == input_line_result::cancel)
{
step = register_step::cancelled_by_user;
continue;
}
state.addresses.push_back(address_str);
state.prev_step = step;
step = register_step::ask_is_solo_stake;
Expand Down

0 comments on commit ec797f5

Please sign in to comment.