aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGregory Maxwell <greg@xiph.org>2015-09-07 01:28:32 +0000
committerGregory Maxwell <greg@xiph.org>2015-09-07 01:28:32 +0000
commit77c60724733a98af5248fb95625046a5a3f82dc3 (patch)
tree23f819c8ac6eab24266e72edc4767c2af836630f /src
parent536207f3167daad1fa3d60a1de7d9cb55db28ac9 (diff)
Enable wallet key imports without rescan in pruned mode.
Complete rescan is incompatible with pruning, but rescan is optional on our wallet key import RPCs. Import on use is very useful in some common situations in conjunction with pruning, e.g. merchant payment tracking. This reenables importprivkey/importaddress/importpubkey when rescan is not used. In the future we should consider changing the rescan argument to allow depth or date to allow limited rescanning when compatible with the retained block depth.
Diffstat (limited to 'src')
-rw-r--r--src/wallet/rpcdump.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/wallet/rpcdump.cpp b/src/wallet/rpcdump.cpp
index 8d557979c0..7e22faac37 100644
--- a/src/wallet/rpcdump.cpp
+++ b/src/wallet/rpcdump.cpp
@@ -97,8 +97,6 @@ UniValue importprivkey(const UniValue& params, bool fHelp)
+ HelpExampleRpc("importprivkey", "\"mykey\", \"testing\", false")
);
- if (fPruneMode)
- throw JSONRPCError(RPC_WALLET_ERROR, "Importing keys is disabled in pruned mode");
LOCK2(cs_main, pwalletMain->cs_wallet);
@@ -114,6 +112,9 @@ UniValue importprivkey(const UniValue& params, bool fHelp)
if (params.size() > 2)
fRescan = params[2].get_bool();
+ if (fRescan && fPruneMode)
+ throw JSONRPCError(RPC_WALLET_ERROR, "Rescan is disabled in pruned mode");
+
CBitcoinSecret vchSecret;
bool fGood = vchSecret.SetString(strSecret);
@@ -201,8 +202,6 @@ UniValue importaddress(const UniValue& params, bool fHelp)
+ HelpExampleRpc("importaddress", "\"myscript\", \"testing\", false")
);
- if (fPruneMode)
- throw JSONRPCError(RPC_WALLET_ERROR, "Importing addresses is disabled in pruned mode");
string strLabel = "";
if (params.size() > 1)
@@ -213,6 +212,9 @@ UniValue importaddress(const UniValue& params, bool fHelp)
if (params.size() > 2)
fRescan = params[2].get_bool();
+ if (fRescan && fPruneMode)
+ throw JSONRPCError(RPC_WALLET_ERROR, "Rescan is disabled in pruned mode");
+
// Whether to import a p2sh version, too
bool fP2SH = false;
if (params.size() > 3)
@@ -264,8 +266,6 @@ UniValue importpubkey(const UniValue& params, bool fHelp)
+ HelpExampleRpc("importpubkey", "\"mypubkey\", \"testing\", false")
);
- if (fPruneMode)
- throw JSONRPCError(RPC_WALLET_ERROR, "Importing public keys is disabled in pruned mode");
string strLabel = "";
if (params.size() > 1)
@@ -276,6 +276,9 @@ UniValue importpubkey(const UniValue& params, bool fHelp)
if (params.size() > 2)
fRescan = params[2].get_bool();
+ if (fRescan && fPruneMode)
+ throw JSONRPCError(RPC_WALLET_ERROR, "Rescan is disabled in pruned mode");
+
if (!IsHex(params[0].get_str()))
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Pubkey must be a hex string");
std::vector<unsigned char> data(ParseHex(params[0].get_str()));