aboutsummaryrefslogtreecommitdiff
path: root/src/rpc
diff options
context:
space:
mode:
authorRussell Yanofsky <russ@yanofsky.org>2016-11-08 16:55:02 -0500
committerRussell Yanofsky <russ@yanofsky.org>2017-02-10 16:11:19 -0500
commita80f98b1c7a49432dc53d18d0fb51ac334de96be (patch)
treeee85a02c68e6157baabd8d7c06b0af3e96b04ec9 /src/rpc
parenta58370e6a2d4dce50eefbcab5bde9f14facef8fc (diff)
Use importmulti timestamp when importing watch only keys
When importing a watch-only address over importmulti with a specific timestamp, the wallet's nTimeFirstKey is currently set to 1. After this change, the provided timestamp will be used and stored as metadata associated with watch-only key. This can improve wallet performance because it can avoid the need to scan the entire blockchain for watch only addresses when timestamps are provided. Also adds timestamp to validateaddress return value (needed for tests). Fixes #9034.
Diffstat (limited to 'src/rpc')
-rw-r--r--src/rpc/misc.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp
index 25fad3c2e3..6fd50127bd 100644
--- a/src/rpc/misc.cpp
+++ b/src/rpc/misc.cpp
@@ -208,6 +208,9 @@ UniValue validateaddress(const JSONRPCRequest& request)
if (pwalletMain) {
const auto& meta = pwalletMain->mapKeyMetadata;
auto it = address.GetKeyID(keyID) ? meta.find(keyID) : meta.end();
+ if (it == meta.end()) {
+ it = meta.find(CScriptID(scriptPubKey));
+ }
if (it != meta.end()) {
ret.push_back(Pair("timestamp", it->second.nCreateTime));
if (!it->second.hdKeypath.empty()) {