aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/rpc
diff options
context:
space:
mode:
authorAndrew Chow <github@achow101.com>2022-09-20 11:54:17 -0400
committerAndrew Chow <github@achow101.com>2022-09-20 12:00:02 -0400
commitfc4017552c980ec9e95de677ea8166702351b79d (patch)
treef0d6b39ff3312ebb45ba42cc2928bf47578bd2f0 /src/wallet/rpc
parent5b6f0f31fa6ce85db3fb7f9823b1bbb06161ae32 (diff)
parent2c03465dfa18ee615f76b6e507a65ef451ce1b7c (diff)
downloadbitcoin-fc4017552c980ec9e95de677ea8166702351b79d.tar.xz
Merge bitcoin/bitcoin#26116: rpc: Allow importmulti watchonly imports with locked wallet
2c03465dfa18ee615f76b6e507a65ef451ce1b7c test: Test watchonly imports with passphrase-locked wallet (Aurèle Oulès) 1fcf9e6e81ea8299fad958b32777c36b696090ac rpc: Allow importmulti watchonly imports with locked wallet (Aurèle Oulès) Pull request description: Allows watch-only imports on locked wallets with `importmulti`. Also adds a test. Fixes #17867. ACKs for top commit: achow101: ACK 2c03465dfa18ee615f76b6e507a65ef451ce1b7c kristapsk: re-ACK 2c03465dfa18ee615f76b6e507a65ef451ce1b7c theStack: re-ACK 2c03465dfa18ee615f76b6e507a65ef451ce1b7c Tree-SHA512: 9978d6e59a230c0d160efd312c671cf59458797387d6622b6bf5c9e0681c1fcfebedb3d834fa9314dc5a1eda97e3295696352eacbeab9b43a46b942990087035
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)));