From 02d6586d7a0f1a0886010e733760ce59cf0935c3 Mon Sep 17 00:00:00 2001 From: Andrew Chow Date: Tue, 6 Nov 2018 09:23:48 -0500 Subject: [PATCH] Import KeyOriginData when importing descriptors --- src/wallet/rpcdump.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/wallet/rpcdump.cpp b/src/wallet/rpcdump.cpp index 8ed912ed1ed..5ceba397041 100644 --- a/src/wallet/rpcdump.cpp +++ b/src/wallet/rpcdump.cpp @@ -888,6 +888,7 @@ struct ImportData // Output data std::set import_scripts; std::map used_keys; //!< Import these private keys if available (the value indicates whether if the key is required for solvability) + std::map key_origins; }; enum class ScriptContext @@ -1158,7 +1159,7 @@ static UniValue ProcessImportDescriptor(ImportData& import_data, std::mapGetPubKey(id, temp) && !pwallet->AddWatchOnly(GetScriptForRawPubKey(pubkey), timestamp)) { throw JSONRPCError(RPC_WALLET_ERROR, "Error adding address to wallet"); } + const auto& key_orig_it = import_data.key_origins.find(id); + if (key_orig_it != import_data.key_origins.end()) { + pwallet->AddKeyOrigin(pubkey, key_orig_it->second); + } + pwallet->mapKeyMetadata[id].nCreateTime = timestamp; } for (const CScript& script : script_pub_keys) {