This isn’t loading anything so the name is a bit odd. Perhaps instead of splitting:
0diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
1index 6a40cfe97e..a633d7966e 100644
2--- a/src/wallet/wallet.cpp
3+++ b/src/wallet/wallet.cpp
4@@ -2617,19 +2617,13 @@ util::Result<void> CWallet::DisplayAddress(const CTxDestination& dest)
5 return util::Error{_("There is no ScriptPubKeyManager for this address")};
6 }
7
8-void CWallet::LoadLockedCoin(const COutPoint& coin, bool persistent)
9+bool CWallet::LockCoin(const COutPoint& coin, bool persistent, bool persist_now)
10 {
11 AssertLockHeld(cs_wallet);
12 m_locked_coins.emplace(coin, persistent);
13-}
14-
15-bool CWallet::LockCoin(const COutPoint& output, bool persist)
16-{
17- AssertLockHeld(cs_wallet);
18- LoadLockedCoin(output, persist);
19- if (persist) {
20+ if (persistent && persist_now) {
21 WalletBatch batch(GetDatabase());
22- return batch.WriteLockedUTXO(output);
23+ return batch.WriteLockedUTXO(coin);
24 }
25 return true;
26 }
27diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h
28index 7fe557f71d..7629de2f9a 100644
29--- a/src/wallet/wallet.h
30+++ b/src/wallet/wallet.h
31@@ -548,8 +548,7 @@ public:
32 util::Result<void> DisplayAddress(const CTxDestination& dest) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
33
34 bool IsLockedCoin(const COutPoint& output) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
35- void LoadLockedCoin(const COutPoint& coin, bool persistent) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
36- bool LockCoin(const COutPoint& output, bool persist) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
37+ bool LockCoin(const COutPoint& output, bool persistent, bool persist_now = true) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
38 bool UnlockCoin(const COutPoint& output) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
39 bool UnlockAllCoins() EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
40 void ListLockedCoins(std::vector<COutPoint>& vOutpts) const EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
41diff --git a/src/wallet/walletdb.cpp b/src/wallet/walletdb.cpp
42index 0f0e228fc8..58f7409b58 100644
43--- a/src/wallet/walletdb.cpp
44+++ b/src/wallet/walletdb.cpp
45@@ -1065,14 +1065,14 @@ static DBErrors LoadTxRecords(CWallet* pwallet, DatabaseBatch& batch, std::vecto
46 });
47 result = std::max(result, tx_res.m_result);
48
49- // Load locked utxo record
50+ // Load utxo record and lock
51 LoadResult locked_utxo_res = LoadRecords(pwallet, batch, DBKeys::LOCKED_UTXO,
52 [] (CWallet* pwallet, DataStream& key, DataStream& value, std::string& err) EXCLUSIVE_LOCKS_REQUIRED(pwallet->cs_wallet) {
53 Txid hash;
54 uint32_t n;
55 key >> hash;
56 key >> n;
57- pwallet->LoadLockedCoin(COutPoint(hash, n), /*persistent=*/true);
58+ pwallet->LockCoin(COutPoint(hash, n), /*persistent=*/true, /*persist_now=*/false);
59 return DBErrors::LOAD_OK;
60 });
61 result = std::max(result, locked_utxo_res.m_result);