Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optional deterministic index in RPC account_create #1547

Merged

Conversation

Projects
6 participants
@guilhermelawless
Copy link
Contributor

commented Jan 3, 2019

Adds optional index parameter to RPC account_create. Wiki will need to be changed.

Additionally extends account_create unit tests.

@zhyatt zhyatt added this to the V18.0 milestone Jan 3, 2019

@argakiig
Copy link
Collaborator

left a comment

diff --git a/nano/core_test/rpc.cpp b/nano/core_test/rpc.cpp
index 9fb6fc9..ab550b4 100644
--- a/nano/core_test/rpc.cpp
+++ b/nano/core_test/rpc.cpp
@@ -147,7 +147,7 @@ TEST (rpc, account_create)
 	nano::uint256_union account1;
 	ASSERT_FALSE (account1.decode_account (account_text1));
 	ASSERT_TRUE (system.wallet (0)->exists (account1));
-	request.put ("index", max_index+1);
+	request.put ("index", max_index + 1);
 	test_response response2 (request, rpc, system.io_ctx);
 	system.deadline_set (5s);
 	while (response2.status == 0)
diff --git a/nano/node/rpc.cpp b/nano/node/rpc.cpp
index 098a1cd..8f5412a 100644
--- a/nano/node/rpc.cpp
+++ b/nano/node/rpc.cpp
@@ -429,16 +429,16 @@ void nano::rpc_handler::account_create ()
 		const bool generate_work = request.get<bool> ("work", true);
 		nano::account new_key;
 		auto index_text (request.get_optional<std::string> ("index"));
-		if (index_text.is_initialized())
+		if (index_text.is_initialized ())
 		{
 			uint64_t index;
-			if (decode_unsigned (index_text.get(), index) || index > (uint64_t) std::numeric_limits<uint32_t>::max ())
+			if (decode_unsigned (index_text.get (), index) || index > (uint64_t)std::numeric_limits<uint32_t>::max ())
 			{
 				ec = nano::error_common::invalid_index;
 			}
 			else
 			{
-				new_key = wallet->deterministic_insert ((uint32_t) index, generate_work);
+				new_key = wallet->deterministic_insert ((uint32_t)index, generate_work);
 			}
 		}
 		else
Code formatting differs from expected - please run ci/clang-format-all.sh

test failing due to formatting, run it through ci/clang-format-all.sh should fix it for ya

@argakiig argakiig added this to CP 1 (2018-01-09) in V18 Jan 3, 2019

Show resolved Hide resolved nano/node/rpc.cpp Outdated

guilhermelawless added some commits Jan 3, 2019

Show resolved Hide resolved nano/node/rpc.hpp Outdated
Show resolved Hide resolved nano/node/wallet.cpp Outdated

@rkeene rkeene added the enhancement label Jan 7, 2019

@rkeene rkeene merged commit 28115fa into nanocurrency:master Jan 7, 2019

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@guilhermelawless guilhermelawless deleted the guilhermelawless:account_create_index_rpc branch Jan 7, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.