0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-02-08 10:31:50 -05:00

rpc: Allow importmulti watchonly imports with locked wallet

This commit is contained in:
Aurèle Oulès 2022-09-17 21:38:35 +02:00
parent a688ff9046
commit 1fcf9e6e81
No known key found for this signature in database
GPG key ID: 55F3976F7001D998

View file

@ -1363,7 +1363,18 @@ RPCHelpMan importmulti()
UniValue response(UniValue::VARR);
{
LOCK(pwallet->cs_wallet);
EnsureWalletIsUnlocked(*pwallet);
// Check all requests are watchonly
bool is_watchonly{true};
for (size_t i = 0; i < requests.size(); ++i) {
const UniValue& request = requests[i];
if (!request.exists("watchonly") || !request["watchonly"].get_bool()) {
is_watchonly = false;
break;
}
}
// Wallet does not need to be unlocked if all requests are watchonly
if (!is_watchonly) EnsureWalletIsUnlocked(wallet);
// Verify all timestamps are present before importing any keys.
CHECK_NONFATAL(pwallet->chain().findBlock(pwallet->GetLastBlockHash(), FoundBlock().time(nLowestTimestamp).mtpTime(now)));