Skip to content

Commit 513719c

Browse files
committed
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.
1 parent 9b81fd1 commit 513719c

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/wallet/rpcdump.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1207,6 +1207,12 @@ static UniValue ProcessImport(CWallet * const pwallet, const UniValue& data, con
12071207
throw JSONRPCError(RPC_INVALID_PARAMETER, "Internal addresses should not have a label");
12081208
}
12091209
const std::string& label = data.exists("label") ? data["label"].get_str() : "";
1210+
const bool add_keypool = data.exists("keypool") ? data["keypool"].get_bool() : false;
1211+
1212+
// Add to keypool only works with privkeys disabled
1213+
if (add_keypool && !pwallet->IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS)) {
1214+
throw JSONRPCError(RPC_INVALID_PARAMETER, "Keys can only be imported to the keypool when private keys are disabled");
1215+
}
12101216

12111217
ImportData import_data;
12121218
std::map<CKeyID, CPubKey> pubkey_map;
@@ -1267,6 +1273,11 @@ static UniValue ProcessImport(CWallet * const pwallet, const UniValue& data, con
12671273
pwallet->AddKeyOrigin(pubkey, key_orig_it->second);
12681274
}
12691275
pwallet->mapKeyMetadata[id].nCreateTime = timestamp;
1276+
1277+
// Add to keypool only works with pubkeys
1278+
if (add_keypool) {
1279+
pwallet->AddKeypoolPubkey(pubkey, internal);
1280+
}
12701281
}
12711282

12721283
for (const CScript& script : script_pub_keys) {

0 commit comments

Comments
 (0)