Import all origin info in importmulti; even for non-importing pubkeys

This commit is contained in:
Pieter Wuille 2019-04-04 12:48:42 -07:00
parent 9a93c91c88
commit 6e597001a4

View file

@ -1274,7 +1274,10 @@ static UniValue ProcessImport(CWallet * const pwallet, const UniValue& data, con
throw JSONRPCError(RPC_WALLET_ERROR, "Error adding key to wallet"); throw JSONRPCError(RPC_WALLET_ERROR, "Error adding key to wallet");
} }
pwallet->UpdateTimeFirstKey(timestamp); pwallet->UpdateTimeFirstKey(timestamp);
} }
for (const auto& entry : import_data.key_origins) {
pwallet->AddKeyOrigin(entry.second.first, entry.second.second);
}
for (const CKeyID& id : ordered_pubkeys) { for (const CKeyID& id : ordered_pubkeys) {
auto entry = pubkey_map.find(id); auto entry = pubkey_map.find(id);
if (entry == pubkey_map.end()) { if (entry == pubkey_map.end()) {
@ -1285,10 +1288,6 @@ static UniValue ProcessImport(CWallet * const pwallet, const UniValue& data, con
if (!pwallet->GetPubKey(id, temp) && !pwallet->AddWatchOnly(GetScriptForRawPubKey(pubkey), timestamp)) { if (!pwallet->GetPubKey(id, temp) && !pwallet->AddWatchOnly(GetScriptForRawPubKey(pubkey), timestamp)) {
throw JSONRPCError(RPC_WALLET_ERROR, "Error adding address to wallet"); 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.second);
}
pwallet->mapKeyMetadata[id].nCreateTime = timestamp; pwallet->mapKeyMetadata[id].nCreateTime = timestamp;
// Add to keypool only works with pubkeys // Add to keypool only works with pubkeys