diff options
author | Andrew Chow <achow101-github@achow101.com> | 2018-11-06 09:47:49 -0500 |
---|---|---|
committer | Andrew Chow <achow101-github@achow101.com> | 2019-02-14 18:14:42 -0500 |
commit | 513719c5f860a5758411331d5ced0bb50c5c5054 (patch) | |
tree | e7d8784a77a4d60e296f8df11b6424946175d17d | |
parent | 9b81fd19ac7ff9f34cc32cc221f057d9c3cd7218 (diff) |
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.
-rw-r--r-- | src/wallet/rpcdump.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/wallet/rpcdump.cpp b/src/wallet/rpcdump.cpp index 5ceba39704..30555886f7 100644 --- a/src/wallet/rpcdump.cpp +++ b/src/wallet/rpcdump.cpp @@ -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"); } 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; 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->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) { |