diff --git a/src/test/rpc_wallet_tests.cpp b/src/test/rpc_wallet_tests.cpp index 8395d982e..1da7c4781 100644 --- a/src/test/rpc_wallet_tests.cpp +++ b/src/test/rpc_wallet_tests.cpp @@ -312,7 +312,9 @@ BOOST_AUTO_TEST_CASE(rpc_wallet_z_exportwallet) BOOST_CHECK(addrs.size()==1); BOOST_CHECK_THROW(CallRPC("z_exportwallet"), runtime_error); - + + BOOST_CHECK_THROW(CallRPC("z_exportwallet toomany args"), runtime_error); + boost::filesystem::path temp = boost::filesystem::temp_directory_path() / boost::filesystem::unique_path(); @@ -362,6 +364,9 @@ BOOST_AUTO_TEST_CASE(rpc_wallet_z_importwallet) // error if no args BOOST_CHECK_THROW(CallRPC("z_importwallet"), runtime_error); + // error if too many args + BOOST_CHECK_THROW(CallRPC("z_importwallet toomany args"), runtime_error); + // create a random key locally auto testSpendingKey = libzcash::SpendingKey::random(); auto testPaymentAddress = testSpendingKey.address(); @@ -430,6 +435,10 @@ BOOST_AUTO_TEST_CASE(rpc_wallet_z_importexport) BOOST_CHECK_THROW(CallRPC("z_importkey"), runtime_error); BOOST_CHECK_THROW(CallRPC("z_exportkey"), runtime_error); + // error if too many args + BOOST_CHECK_THROW(CallRPC("z_importkey too many args"), runtime_error); + BOOST_CHECK_THROW(CallRPC("z_exportkey toomany args"), runtime_error); + // wallet should currently be empty std::set addrs; pwalletMain->GetPaymentAddresses(addrs); @@ -490,6 +499,9 @@ BOOST_AUTO_TEST_CASE(rpc_wallet_z_importexport) CZCPaymentAddress pa(newaddress); auto newAddr = pa.Get(); BOOST_CHECK(pwalletMain->HaveSpendingKey(newAddr)); + + // Check if too many args + BOOST_CHECK_THROW(CallRPC("z_getnewaddress toomanyargs"), runtime_error); } @@ -709,6 +721,9 @@ BOOST_AUTO_TEST_CASE(rpc_z_getoperations) std::this_thread::sleep_for(std::chrono::milliseconds(1000)); BOOST_CHECK(q->getOperationCount() == 0); + // Check if too many args + BOOST_CHECK_THROW(CallRPC("z_listoperationids toomany args"), runtime_error); + Value retValue; BOOST_CHECK_NO_THROW(retValue = CallRPC("z_listoperationids")); BOOST_CHECK(retValue.get_array().size() == 2); diff --git a/src/wallet/rpcdump.cpp b/src/wallet/rpcdump.cpp index 61aa4da50..9db1a2fab 100644 --- a/src/wallet/rpcdump.cpp +++ b/src/wallet/rpcdump.cpp @@ -532,9 +532,9 @@ Value z_importkey(const Array& params, bool fHelp) if (!EnsureWalletIsAvailable(fHelp)) return Value::null; - if (fHelp || params.size() < 1 || params.size() > 3) + if (fHelp || params.size() < 1 || params.size() > 2) throw runtime_error( - "z_importkey \"zkey\" ( \"label\" rescan )\n" + "z_importkey \"zkey\" ( rescan )\n" "\nAdds a zkey (as returned by z_exportkey) to your wallet.\n" "\nArguments:\n" "1. \"zkey\" (string, required) The zkey (see z_exportkey)\n" @@ -545,10 +545,8 @@ Value z_importkey(const Array& params, bool fHelp) + HelpExampleCli("z_exportkey", "\"myaddress\"") + "\nImport the zkey with rescan\n" + HelpExampleCli("z_importkey", "\"mykey\"") + - "\nImport using a label and without rescan\n" - + HelpExampleCli("z_importkey", "\"mykey\" \"testing\" false") + "\nAs a JSON-RPC call\n" - + HelpExampleRpc("z_importkey", "\"mykey\", \"testing\", false") + + HelpExampleRpc("z_importkey", "\"mykey\", false") ); LOCK2(cs_main, pwalletMain->cs_wallet); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 33a62e98d..747682136 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -2792,7 +2792,7 @@ Value z_getnewaddress(const Array& params, bool fHelp) if (!EnsureWalletIsAvailable(fHelp)) return Value::null; - if (fHelp || params.size() > 1) + if (fHelp || params.size() > 0) throw runtime_error( "z_getnewaddress\n" "\nReturns a new zaddr for receiving payments.\n"