Skip to content

Commit 540bf8a

Browse files
committed
Merge #12559: Avoid locking cs_main in some wallet RPC
00f58f8 rpc: Avoid locking cs_main in some wallet RPC (João Barbosa) Pull request description: Avoid locking `cs_main` in the folllowing wallet RPC: - `decoderawtransaction` - `getnewaddress` - `getrawchangeaddress` - `setlabel` Tree-SHA512: 54089766b2a969a17479af6c60e8ce151fac1f8cec268d43c61e679d5d17e76d17e414240c9ca2bfd280165f3a04e24a51310eb283591cd601a7eebc8b2423ea
2 parents 5b52aa6 + 00f58f8 commit 540bf8a

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

src/rpc/rawtransaction.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -562,7 +562,6 @@ static UniValue decoderawtransaction(const JSONRPCRequest& request)
562562
+ HelpExampleRpc("decoderawtransaction", "\"hexstring\"")
563563
);
564564

565-
LOCK(cs_main);
566565
RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VBOOL});
567566

568567
CMutableTransaction mtx;

src/wallet/rpcwallet.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ static UniValue getnewaddress(const JSONRPCRequest& request)
165165
throw JSONRPCError(RPC_WALLET_ERROR, "Error: Private keys are disabled for this wallet");
166166
}
167167

168-
LOCK2(cs_main, pwallet->cs_wallet);
168+
LOCK(pwallet->cs_wallet);
169169

170170
// Parse the label first so we don't generate a key if there's an error
171171
std::string label;
@@ -276,7 +276,7 @@ static UniValue getrawchangeaddress(const JSONRPCRequest& request)
276276
throw JSONRPCError(RPC_WALLET_ERROR, "Error: Private keys are disabled for this wallet");
277277
}
278278

279-
LOCK2(cs_main, pwallet->cs_wallet);
279+
LOCK(pwallet->cs_wallet);
280280

281281
if (!pwallet->IsLocked()) {
282282
pwallet->TopUpKeyPool();
@@ -331,7 +331,7 @@ static UniValue setlabel(const JSONRPCRequest& request)
331331
+ HelpExampleRpc("setlabel", "\"1D1ZrZNe3JUo7ZycKEYQQiQAWd9y54F4XX\", \"tabby\"")
332332
);
333333

334-
LOCK2(cs_main, pwallet->cs_wallet);
334+
LOCK(pwallet->cs_wallet);
335335

336336
CTxDestination dest = DecodeDestination(request.params[0].get_str());
337337
if (!IsValidDestination(dest)) {

0 commit comments

Comments
 (0)