Skip to content

Commit 1fcf9e6

Browse files
committed
rpc: Allow importmulti watchonly imports with locked wallet
1 parent a688ff9 commit 1fcf9e6

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/wallet/rpc/backup.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1363,7 +1363,18 @@ RPCHelpMan importmulti()
13631363
UniValue response(UniValue::VARR);
13641364
{
13651365
LOCK(pwallet->cs_wallet);
1366-
EnsureWalletIsUnlocked(*pwallet);
1366+
1367+
// Check all requests are watchonly
1368+
bool is_watchonly{true};
1369+
for (size_t i = 0; i < requests.size(); ++i) {
1370+
const UniValue& request = requests[i];
1371+
if (!request.exists("watchonly") || !request["watchonly"].get_bool()) {
1372+
is_watchonly = false;
1373+
break;
1374+
}
1375+
}
1376+
// Wallet does not need to be unlocked if all requests are watchonly
1377+
if (!is_watchonly) EnsureWalletIsUnlocked(wallet);
13671378

13681379
// Verify all timestamps are present before importing any keys.
13691380
CHECK_NONFATAL(pwallet->chain().findBlock(pwallet->GetLastBlockHash(), FoundBlock().time(nLowestTimestamp).mtpTime(now)));

0 commit comments

Comments
 (0)