mirror of
https://github.com/bitcoin/bitcoin.git
synced 2024-11-20 10:38:42 +01:00
Add option to importmulti add an imported pubkey to the keypool
Adds a new option to importmulti where the pubkeys specified in the import object can be added to the keypool. This only works if the wallet has private keys disabled.
This commit is contained in:
parent
9b81fd19ac
commit
513719c5f8
@ -1207,6 +1207,12 @@ static UniValue ProcessImport(CWallet * const pwallet, const UniValue& data, con
|
|||||||
throw JSONRPCError(RPC_INVALID_PARAMETER, "Internal addresses should not have a label");
|
throw JSONRPCError(RPC_INVALID_PARAMETER, "Internal addresses should not have a label");
|
||||||
}
|
}
|
||||||
const std::string& label = data.exists("label") ? data["label"].get_str() : "";
|
const std::string& label = data.exists("label") ? data["label"].get_str() : "";
|
||||||
|
const bool add_keypool = data.exists("keypool") ? data["keypool"].get_bool() : false;
|
||||||
|
|
||||||
|
// Add to keypool only works with privkeys disabled
|
||||||
|
if (add_keypool && !pwallet->IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS)) {
|
||||||
|
throw JSONRPCError(RPC_INVALID_PARAMETER, "Keys can only be imported to the keypool when private keys are disabled");
|
||||||
|
}
|
||||||
|
|
||||||
ImportData import_data;
|
ImportData import_data;
|
||||||
std::map<CKeyID, CPubKey> pubkey_map;
|
std::map<CKeyID, CPubKey> pubkey_map;
|
||||||
@ -1267,6 +1273,11 @@ static UniValue ProcessImport(CWallet * const pwallet, const UniValue& data, con
|
|||||||
pwallet->AddKeyOrigin(pubkey, key_orig_it->second);
|
pwallet->AddKeyOrigin(pubkey, key_orig_it->second);
|
||||||
}
|
}
|
||||||
pwallet->mapKeyMetadata[id].nCreateTime = timestamp;
|
pwallet->mapKeyMetadata[id].nCreateTime = timestamp;
|
||||||
|
|
||||||
|
// Add to keypool only works with pubkeys
|
||||||
|
if (add_keypool) {
|
||||||
|
pwallet->AddKeypoolPubkey(pubkey, internal);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const CScript& script : script_pub_keys) {
|
for (const CScript& script : script_pub_keys) {
|
||||||
|
Loading…
Reference in New Issue
Block a user