mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-05 18:52:29 +02:00
Merge #15803: [0.18] Backport 15749: importmulti only imports origin info for PKH outputs
235550d019Take non-importing keys into account for spendability warning in descriptor import (Pieter Wuille)802dcd37d1Import all origin info in importmulti; even for non-importing pubkeys (Pieter Wuille)7fcbe7dc11Keep full pubkeys in FlatSigningProvider::origins (Pieter Wuille) Pull request description: Clean backport of #15749 by sipa to 0.18 ACKs for commit 235550: fanquake: utACK235550dMarcoFalke: ACK235550d019(Checked that they are clean cherry-picks) Tree-SHA512: 1ccc19f51137ac4ef971c0bcca4c87ab2383610aa51c5d02680c485b9ce6abd698dddd7f4a45946d56b1aa741cc3fd94b4180ff15901824d20eeba89b4f12853
This commit is contained in:
@@ -896,7 +896,7 @@ struct ImportData
|
||||
// Output data
|
||||
std::set<CScript> import_scripts;
|
||||
std::map<CKeyID, bool> used_keys; //!< Import these private keys if available (the value indicates whether if the key is required for solvability)
|
||||
std::map<CKeyID, KeyOriginInfo> key_origins;
|
||||
std::map<CKeyID, std::pair<CPubKey, KeyOriginInfo>> key_origins;
|
||||
};
|
||||
|
||||
enum class ScriptContext
|
||||
@@ -1193,6 +1193,9 @@ static UniValue ProcessImportDescriptor(ImportData& import_data, std::map<CKeyID
|
||||
bool spendable = std::all_of(pubkey_map.begin(), pubkey_map.end(),
|
||||
[&](const std::pair<CKeyID, CPubKey>& used_key) {
|
||||
return privkey_map.count(used_key.first) > 0;
|
||||
}) && std::all_of(import_data.key_origins.begin(), import_data.key_origins.end(),
|
||||
[&](const std::pair<CKeyID, std::pair<CPubKey, KeyOriginInfo>>& entry) {
|
||||
return privkey_map.count(entry.first) > 0;
|
||||
});
|
||||
if (!watch_only && !spendable) {
|
||||
warnings.push_back("Some private keys are missing, outputs will be considered watchonly. If this is intentional, specify the watchonly flag.");
|
||||
@@ -1270,7 +1273,10 @@ static UniValue ProcessImport(CWallet * const pwallet, const UniValue& data, con
|
||||
throw JSONRPCError(RPC_WALLET_ERROR, "Error adding key to wallet");
|
||||
}
|
||||
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) {
|
||||
auto entry = pubkey_map.find(id);
|
||||
if (entry == pubkey_map.end()) {
|
||||
@@ -1281,10 +1287,6 @@ static UniValue ProcessImport(CWallet * const pwallet, const UniValue& data, con
|
||||
if (!pwallet->GetPubKey(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;
|
||||
|
||||
// Add to keypool only works with pubkeys
|
||||
|
||||
Reference in New Issue
Block a user