@@ -888,6 +888,7 @@ struct ImportData
888
888
// Output data
889
889
std::set<CScript> import_scripts;
890
890
std::map<CKeyID, bool > used_keys; // !< Import these private keys if available (the value indicates whether if the key is required for solvability)
891
+ std::map<CKeyID, KeyOriginInfo> key_origins;
891
892
};
892
893
893
894
enum class ScriptContext
@@ -1158,7 +1159,7 @@ static UniValue ProcessImportDescriptor(ImportData& import_data, std::map<CKeyID
1158
1159
}
1159
1160
1160
1161
std::copy (out_keys.pubkeys .begin (), out_keys.pubkeys .end (), std::inserter (pubkey_map, pubkey_map.end ()));
1161
-
1162
+ import_data. key_origins . insert (out_keys. origins . begin (), out_keys. origins . end ());
1162
1163
for (size_t i = 0 ; i < priv_keys.size (); ++i) {
1163
1164
const auto & str = priv_keys[i].get_str ();
1164
1165
CKey key = DecodeSecret (str);
@@ -1261,6 +1262,11 @@ static UniValue ProcessImport(CWallet * const pwallet, const UniValue& data, con
1261
1262
if (!pwallet->GetPubKey (id, temp) && !pwallet->AddWatchOnly (GetScriptForRawPubKey (pubkey), timestamp)) {
1262
1263
throw JSONRPCError (RPC_WALLET_ERROR, " Error adding address to wallet" );
1263
1264
}
1265
+ const auto & key_orig_it = import_data.key_origins .find (id);
1266
+ if (key_orig_it != import_data.key_origins .end ()) {
1267
+ pwallet->AddKeyOrigin (pubkey, key_orig_it->second );
1268
+ }
1269
+ pwallet->mapKeyMetadata [id].nCreateTime = timestamp;
1264
1270
}
1265
1271
1266
1272
for (const CScript& script : script_pub_keys) {
0 commit comments