aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/rpc
diff options
context:
space:
mode:
authorAurèle Oulès <aurele@oules.com>2022-09-17 21:38:35 +0200
committerAurèle Oulès <aurele@oules.com>2022-09-17 21:38:55 +0200
commit1fcf9e6e81ea8299fad958b32777c36b696090ac (patch)
treea639c93ff949476df65e48c049c6b94dbccfc534 /src/wallet/rpc
parenta688ff9046a9df58a373086445ab5796cccf9dd3 (diff)
downloadbitcoin-1fcf9e6e81ea8299fad958b32777c36b696090ac.tar.xz
rpc: Allow importmulti watchonly imports with locked wallet
Diffstat (limited to 'src/wallet/rpc')
-rw-r--r--src/wallet/rpc/backup.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/wallet/rpc/backup.cpp b/src/wallet/rpc/backup.cpp
index 35df151e84..09c74ea2da 100644
--- a/src/wallet/rpc/backup.cpp
+++ b/src/wallet/rpc/backup.cpp
@@ -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)));