Skip to content

Commit 01f3534

Browse files
committed
refactor: remove unused locks for ResubmitWalletTransactions
ReacceptWalletTransactions is replaced by ResubmitWalletTransactions which already handles acquiring the necessary locks internally.
1 parent c6e8e11 commit 01f3534

File tree

2 files changed

+5
-19
lines changed

2 files changed

+5
-19
lines changed

src/wallet/rpc/backup.cpp

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -293,10 +293,7 @@ RPCHelpMan importaddress()
293293
if (fRescan)
294294
{
295295
RescanWallet(*pwallet, reserver);
296-
{
297-
LOCK(pwallet->cs_wallet);
298-
pwallet->ResubmitWalletTransactions(/*relay=*/false, /*force=*/true);
299-
}
296+
pwallet->ResubmitWalletTransactions(/*relay=*/false, /*force=*/true);
300297
}
301298

302299
return UniValue::VNULL;
@@ -474,10 +471,7 @@ RPCHelpMan importpubkey()
474471
if (fRescan)
475472
{
476473
RescanWallet(*pwallet, reserver);
477-
{
478-
LOCK(pwallet->cs_wallet);
479-
pwallet->ResubmitWalletTransactions(/*relay=*/false, /*force=*/true);
480-
}
474+
pwallet->ResubmitWalletTransactions(/*relay=*/false, /*force=*/true);
481475
}
482476

483477
return UniValue::VNULL;
@@ -1406,10 +1400,7 @@ RPCHelpMan importmulti()
14061400
}
14071401
if (fRescan && fRunScan && requests.size()) {
14081402
int64_t scannedTime = pwallet->RescanFromTime(nLowestTimestamp, reserver, true /* update */);
1409-
{
1410-
LOCK(pwallet->cs_wallet);
1411-
pwallet->ResubmitWalletTransactions(/*relay=*/false, /*force=*/true);
1412-
}
1403+
pwallet->ResubmitWalletTransactions(/*relay=*/false, /*force=*/true);
14131404

14141405
if (pwallet->IsAbortingRescan()) {
14151406
throw JSONRPCError(RPC_MISC_ERROR, "Rescan aborted by user.");
@@ -1700,10 +1691,7 @@ RPCHelpMan importdescriptors()
17001691
// Rescan the blockchain using the lowest timestamp
17011692
if (rescan) {
17021693
int64_t scanned_time = pwallet->RescanFromTime(lowest_timestamp, reserver, true /* update */);
1703-
{
1704-
LOCK(pwallet->cs_wallet);
1705-
pwallet->ResubmitWalletTransactions(/*relay=*/false, /*force=*/true);
1706-
}
1694+
pwallet->ResubmitWalletTransactions(/*relay=*/false, /*force=*/true);
17071695

17081696
if (pwallet->IsAbortingRescan()) {
17091697
throw JSONRPCError(RPC_MISC_ERROR, "Rescan aborted by user.");

src/wallet/wallet.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3196,14 +3196,12 @@ bool CWallet::UpgradeWallet(int version, bilingual_str& error)
31963196

31973197
void CWallet::postInitProcess()
31983198
{
3199-
LOCK(cs_wallet);
3200-
32013199
// Add wallet transactions that aren't already in a block to mempool
32023200
// Do this here as mempool requires genesis block to be loaded
32033201
ResubmitWalletTransactions(/*relay=*/false, /*force=*/true);
32043202

32053203
// Update wallet transactions with current mempool transactions.
3206-
chain().requestMempoolTransactions(*this);
3204+
WITH_LOCK(cs_wallet, chain().requestMempoolTransactions(*this));
32073205
}
32083206

32093207
bool CWallet::BackupWallet(const std::string& strDest) const

0 commit comments

Comments
 (0)