Auto merge of #2052 - str4d:2032-z_importkey-partial-rescan, r=bitcartel

Usability improvements for z_importkey

- Add height parameter to z_importkey to reduce rescan range
- Change semantics of rescan parameter, so users can explicitly force a rescan
  for existing keys.

Closes #2032
This commit is contained in:
zkbot
2017-03-24 03:47:11 +00:00
4 changed files with 79 additions and 18 deletions

View File

@@ -510,9 +510,17 @@ BOOST_AUTO_TEST_CASE(rpc_wallet_z_importexport)
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_importkey way too many args"), runtime_error);
BOOST_CHECK_THROW(CallRPC("z_exportkey toomany args"), runtime_error);
// error if invalid args
auto sk = libzcash::SpendingKey::random();
std::string prefix = std::string("z_importkey ") + CZCSpendingKey(sk).ToString() + " yes ";
BOOST_CHECK_THROW(CallRPC(prefix + "-1"), runtime_error);
BOOST_CHECK_THROW(CallRPC(prefix + "2147483647"), runtime_error); // allowed, but > height of active chain tip
BOOST_CHECK_THROW(CallRPC(prefix + "2147483648"), runtime_error); // not allowed, > int32 used for nHeight
BOOST_CHECK_THROW(CallRPC(prefix + "100badchars"), runtime_error);
// wallet should currently be empty
std::set<libzcash::PaymentAddress> addrs;
pwalletMain->GetPaymentAddresses(addrs);