Skip to content

Commit baa9fc9

Browse files
author
MarcoFalke
committed
Merge bitcoin/bitcoin#22787: refactor: actual immutable pointing
54011e7 refactor: use CWallet const shared pointers when possible (Karl-Johan Alm) 9646198 refactor: const shared_ptrs (Karl-Johan Alm) Pull request description: ```C++ const std::shared_ptr<CWallet> wallet = x; ``` means we can not do `wallet = y`, but we can totally do `wallet->DestructiveOperation()`, contrary to what that line looks like. This PR * introduces a new convention: always use const shared pointers to `CWallet`s (even when we mutate the pointed-to thing) * uses `const shared_ptr<const CWallet>` everywhere where wallets are not modified In the future, this should preferably apply to all shared pointers, not limited to just `CWallet`s. Both of these serve the same purpose: to dispell the misconception that `const shared_ptr<X>` immutates `X`. It doesn't, and it's dangerous to leave this misconception as is, for obvious reasons. ACKs for top commit: theStack: re-ACK 54011e7 Tree-SHA512: 3bf4062fc821751be30770c6b4ead10a016847970f155a0a5156f304347d221b9830840030c2fbfba8cd1e282f4eda45f5b4107fe6df8138afdcb6c2e95a2836
2 parents ab25ef8 + 54011e7 commit baa9fc9

File tree

7 files changed

+40
-40
lines changed

7 files changed

+40
-40
lines changed

src/qt/test/addressbooktests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ void TestAddAddressesToSendBook(interfaces::Node& node)
6363
auto wallet_client = interfaces::MakeWalletClient(*test.m_node.chain, *Assert(test.m_node.args));
6464
test.m_node.wallet_client = wallet_client.get();
6565
node.setContext(&test.m_node);
66-
std::shared_ptr<CWallet> wallet = std::make_shared<CWallet>(node.context()->chain.get(), "", CreateMockWalletDatabase());
66+
const std::shared_ptr<CWallet> wallet = std::make_shared<CWallet>(node.context()->chain.get(), "", CreateMockWalletDatabase());
6767
wallet->LoadWallet();
6868
wallet->SetWalletFlag(WALLET_FLAG_DESCRIPTORS);
6969
{

src/qt/test/wallettests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ void TestGUI(interfaces::Node& node)
141141
auto wallet_client = interfaces::MakeWalletClient(*test.m_node.chain, *Assert(test.m_node.args));
142142
test.m_node.wallet_client = wallet_client.get();
143143
node.setContext(&test.m_node);
144-
std::shared_ptr<CWallet> wallet = std::make_shared<CWallet>(node.context()->chain.get(), "", CreateMockWalletDatabase());
144+
const std::shared_ptr<CWallet> wallet = std::make_shared<CWallet>(node.context()->chain.get(), "", CreateMockWalletDatabase());
145145
wallet->LoadWallet();
146146
wallet->SetWalletFlag(WALLET_FLAG_DESCRIPTORS);
147147
{

src/wallet/rpcdump.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1788,7 +1788,7 @@ RPCHelpMan listdescriptors()
17881788
},
17891789
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
17901790
{
1791-
std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request);
1791+
const std::shared_ptr<const CWallet> wallet = GetWalletForJSONRPCRequest(request);
17921792
if (!wallet) return NullUniValue;
17931793

17941794
if (!wallet->IsWalletFlagSet(WALLET_FLAG_DESCRIPTORS)) {

src/wallet/rpcwallet.cpp

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ std::shared_ptr<CWallet> GetWalletForJSONRPCRequest(const JSONRPCRequest& reques
103103

104104
std::string wallet_name;
105105
if (GetWalletNameFromJSONRPCRequest(request, wallet_name)) {
106-
std::shared_ptr<CWallet> pwallet = GetWallet(context, wallet_name);
106+
const std::shared_ptr<CWallet> pwallet = GetWallet(context, wallet_name);
107107
if (!pwallet) throw JSONRPCError(RPC_WALLET_NOT_FOUND, "Requested wallet does not exist or is not loaded");
108108
return pwallet;
109109
}
@@ -570,7 +570,7 @@ static RPCHelpMan listaddressgroupings()
570570
},
571571
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
572572
{
573-
std::shared_ptr<CWallet> const pwallet = GetWalletForJSONRPCRequest(request);
573+
const std::shared_ptr<const CWallet> pwallet = GetWalletForJSONRPCRequest(request);
574574
if (!pwallet) return NullUniValue;
575575

576576
// Make sure the results are valid at least up to the most recent block
@@ -627,7 +627,7 @@ static RPCHelpMan signmessage()
627627
},
628628
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
629629
{
630-
std::shared_ptr<CWallet> const pwallet = GetWalletForJSONRPCRequest(request);
630+
const std::shared_ptr<const CWallet> pwallet = GetWalletForJSONRPCRequest(request);
631631
if (!pwallet) return NullUniValue;
632632

633633
LOCK(pwallet->cs_wallet);
@@ -729,7 +729,7 @@ static RPCHelpMan getreceivedbyaddress()
729729
},
730730
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
731731
{
732-
std::shared_ptr<CWallet> const pwallet = GetWalletForJSONRPCRequest(request);
732+
const std::shared_ptr<const CWallet> pwallet = GetWalletForJSONRPCRequest(request);
733733
if (!pwallet) return NullUniValue;
734734

735735
// Make sure the results are valid at least up to the most recent block
@@ -767,7 +767,7 @@ static RPCHelpMan getreceivedbylabel()
767767
},
768768
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
769769
{
770-
std::shared_ptr<CWallet> const pwallet = GetWalletForJSONRPCRequest(request);
770+
const std::shared_ptr<const CWallet> pwallet = GetWalletForJSONRPCRequest(request);
771771
if (!pwallet) return NullUniValue;
772772

773773
// Make sure the results are valid at least up to the most recent block
@@ -807,7 +807,7 @@ static RPCHelpMan getbalance()
807807
},
808808
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
809809
{
810-
std::shared_ptr<CWallet> const pwallet = GetWalletForJSONRPCRequest(request);
810+
const std::shared_ptr<const CWallet> pwallet = GetWalletForJSONRPCRequest(request);
811811
if (!pwallet) return NullUniValue;
812812

813813
// Make sure the results are valid at least up to the most recent block
@@ -846,7 +846,7 @@ static RPCHelpMan getunconfirmedbalance()
846846
RPCExamples{""},
847847
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
848848
{
849-
std::shared_ptr<CWallet> const pwallet = GetWalletForJSONRPCRequest(request);
849+
const std::shared_ptr<const CWallet> pwallet = GetWalletForJSONRPCRequest(request);
850850
if (!pwallet) return NullUniValue;
851851

852852
// Make sure the results are valid at least up to the most recent block
@@ -1234,7 +1234,7 @@ static RPCHelpMan listreceivedbyaddress()
12341234
},
12351235
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
12361236
{
1237-
std::shared_ptr<CWallet> const pwallet = GetWalletForJSONRPCRequest(request);
1237+
const std::shared_ptr<const CWallet> pwallet = GetWalletForJSONRPCRequest(request);
12381238
if (!pwallet) return NullUniValue;
12391239

12401240
// Make sure the results are valid at least up to the most recent block
@@ -1276,7 +1276,7 @@ static RPCHelpMan listreceivedbylabel()
12761276
},
12771277
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
12781278
{
1279-
std::shared_ptr<CWallet> const pwallet = GetWalletForJSONRPCRequest(request);
1279+
const std::shared_ptr<const CWallet> pwallet = GetWalletForJSONRPCRequest(request);
12801280
if (!pwallet) return NullUniValue;
12811281

12821282
// Make sure the results are valid at least up to the most recent block
@@ -1461,7 +1461,7 @@ static RPCHelpMan listtransactions()
14611461
},
14621462
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
14631463
{
1464-
std::shared_ptr<CWallet> const pwallet = GetWalletForJSONRPCRequest(request);
1464+
const std::shared_ptr<const CWallet> pwallet = GetWalletForJSONRPCRequest(request);
14651465
if (!pwallet) return NullUniValue;
14661466

14671467
// Make sure the results are valid at least up to the most recent block
@@ -1577,7 +1577,7 @@ static RPCHelpMan listsinceblock()
15771577
},
15781578
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
15791579
{
1580-
std::shared_ptr<CWallet> const pwallet = GetWalletForJSONRPCRequest(request);
1580+
const std::shared_ptr<const CWallet> pwallet = GetWalletForJSONRPCRequest(request);
15811581
if (!pwallet) return NullUniValue;
15821582

15831583
const CWallet& wallet = *pwallet;
@@ -1718,7 +1718,7 @@ static RPCHelpMan gettransaction()
17181718
},
17191719
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
17201720
{
1721-
std::shared_ptr<CWallet> const pwallet = GetWalletForJSONRPCRequest(request);
1721+
const std::shared_ptr<const CWallet> pwallet = GetWalletForJSONRPCRequest(request);
17221722
if (!pwallet) return NullUniValue;
17231723

17241724
// Make sure the results are valid at least up to the most recent block
@@ -1829,7 +1829,7 @@ static RPCHelpMan backupwallet()
18291829
},
18301830
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
18311831
{
1832-
std::shared_ptr<CWallet> const pwallet = GetWalletForJSONRPCRequest(request);
1832+
const std::shared_ptr<const CWallet> pwallet = GetWalletForJSONRPCRequest(request);
18331833
if (!pwallet) return NullUniValue;
18341834

18351835
// Make sure the results are valid at least up to the most recent block
@@ -2331,7 +2331,7 @@ static RPCHelpMan listlockunspent()
23312331
},
23322332
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
23332333
{
2334-
std::shared_ptr<CWallet> const pwallet = GetWalletForJSONRPCRequest(request);
2334+
const std::shared_ptr<const CWallet> pwallet = GetWalletForJSONRPCRequest(request);
23352335
if (!pwallet) return NullUniValue;
23362336

23372337
LOCK(pwallet->cs_wallet);
@@ -2424,9 +2424,9 @@ static RPCHelpMan getbalances()
24242424
HelpExampleRpc("getbalances", "")},
24252425
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
24262426
{
2427-
std::shared_ptr<CWallet> const rpc_wallet = GetWalletForJSONRPCRequest(request);
2427+
const std::shared_ptr<const CWallet> rpc_wallet = GetWalletForJSONRPCRequest(request);
24282428
if (!rpc_wallet) return NullUniValue;
2429-
CWallet& wallet = *rpc_wallet;
2429+
const CWallet& wallet = *rpc_wallet;
24302430

24312431
// Make sure the results are valid at least up to the most recent block
24322432
// the user could have gotten from another RPC command prior to now
@@ -2500,7 +2500,7 @@ static RPCHelpMan getwalletinfo()
25002500
},
25012501
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
25022502
{
2503-
std::shared_ptr<CWallet> const pwallet = GetWalletForJSONRPCRequest(request);
2503+
const std::shared_ptr<const CWallet> pwallet = GetWalletForJSONRPCRequest(request);
25042504
if (!pwallet) return NullUniValue;
25052505

25062506
// Make sure the results are valid at least up to the most recent block
@@ -2840,7 +2840,7 @@ static RPCHelpMan createwallet()
28402840
options.create_passphrase = passphrase;
28412841
bilingual_str error;
28422842
std::optional<bool> load_on_start = request.params[6].isNull() ? std::nullopt : std::optional<bool>(request.params[6].get_bool());
2843-
std::shared_ptr<CWallet> wallet = CreateWallet(context, request.params[0].get_str(), load_on_start, options, status, error, warnings);
2843+
const std::shared_ptr<CWallet> wallet = CreateWallet(context, request.params[0].get_str(), load_on_start, options, status, error, warnings);
28442844
if (!wallet) {
28452845
RPCErrorCode code = status == DatabaseStatus::FAILED_ENCRYPT ? RPC_WALLET_ENCRYPTION_FAILED : RPC_WALLET_ERROR;
28462846
throw JSONRPCError(code, error.original);
@@ -3030,7 +3030,7 @@ static RPCHelpMan listunspent()
30303030
},
30313031
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
30323032
{
3033-
std::shared_ptr<CWallet> const pwallet = GetWalletForJSONRPCRequest(request);
3033+
const std::shared_ptr<const CWallet> pwallet = GetWalletForJSONRPCRequest(request);
30343034
if (!pwallet) return NullUniValue;
30353035

30363036
int nMinDepth = 1;
@@ -3593,7 +3593,7 @@ RPCHelpMan signrawtransactionwithwallet()
35933593
},
35943594
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
35953595
{
3596-
std::shared_ptr<CWallet> const pwallet = GetWalletForJSONRPCRequest(request);
3596+
const std::shared_ptr<const CWallet> pwallet = GetWalletForJSONRPCRequest(request);
35973597
if (!pwallet) return NullUniValue;
35983598

35993599
RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VARR, UniValue::VSTR}, true);
@@ -4058,7 +4058,7 @@ RPCHelpMan getaddressinfo()
40584058
},
40594059
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
40604060
{
4061-
std::shared_ptr<CWallet> const pwallet = GetWalletForJSONRPCRequest(request);
4061+
const std::shared_ptr<const CWallet> pwallet = GetWalletForJSONRPCRequest(request);
40624062
if (!pwallet) return NullUniValue;
40634063

40644064
LOCK(pwallet->cs_wallet);
@@ -4165,7 +4165,7 @@ static RPCHelpMan getaddressesbylabel()
41654165
},
41664166
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
41674167
{
4168-
std::shared_ptr<CWallet> const pwallet = GetWalletForJSONRPCRequest(request);
4168+
const std::shared_ptr<const CWallet> pwallet = GetWalletForJSONRPCRequest(request);
41694169
if (!pwallet) return NullUniValue;
41704170

41714171
LOCK(pwallet->cs_wallet);
@@ -4226,7 +4226,7 @@ static RPCHelpMan listlabels()
42264226
},
42274227
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
42284228
{
4229-
std::shared_ptr<CWallet> const pwallet = GetWalletForJSONRPCRequest(request);
4229+
const std::shared_ptr<const CWallet> pwallet = GetWalletForJSONRPCRequest(request);
42304230
if (!pwallet) return NullUniValue;
42314231

42324232
LOCK(pwallet->cs_wallet);
@@ -4555,7 +4555,7 @@ static RPCHelpMan walletprocesspsbt()
45554555
},
45564556
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
45574557
{
4558-
std::shared_ptr<CWallet> const pwallet = GetWalletForJSONRPCRequest(request);
4558+
const std::shared_ptr<const CWallet> pwallet = GetWalletForJSONRPCRequest(request);
45594559
if (!pwallet) return NullUniValue;
45604560

45614561
const CWallet& wallet{*pwallet};

src/wallet/test/wallet_tests.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ static_assert(WALLET_INCREMENTAL_RELAY_FEE >= DEFAULT_INCREMENTAL_RELAY_FEE, "wa
4141

4242
BOOST_FIXTURE_TEST_SUITE(wallet_tests, WalletTestingSetup)
4343

44-
static std::shared_ptr<CWallet> TestLoadWallet(WalletContext& context)
44+
static const std::shared_ptr<CWallet> TestLoadWallet(WalletContext& context)
4545
{
4646
DatabaseOptions options;
4747
options.create_flags = WALLET_FLAG_DESCRIPTORS;
@@ -208,7 +208,7 @@ BOOST_FIXTURE_TEST_CASE(importmulti_rescan, TestChain100Setup)
208208
// before the missing block, and success for a key whose creation time is
209209
// after.
210210
{
211-
std::shared_ptr<CWallet> wallet = std::make_shared<CWallet>(m_node.chain.get(), "", CreateDummyWalletDatabase());
211+
const std::shared_ptr<CWallet> wallet = std::make_shared<CWallet>(m_node.chain.get(), "", CreateDummyWalletDatabase());
212212
wallet->SetupLegacyScriptPubKeyMan();
213213
WITH_LOCK(wallet->cs_wallet, wallet->SetLastBlockProcessed(newTip->nHeight, newTip->GetBlockHash()));
214214
WalletContext context;
@@ -274,7 +274,7 @@ BOOST_FIXTURE_TEST_CASE(importwallet_rescan, TestChain100Setup)
274274
{
275275
WalletContext context;
276276
context.args = &gArgs;
277-
std::shared_ptr<CWallet> wallet = std::make_shared<CWallet>(m_node.chain.get(), "", CreateDummyWalletDatabase());
277+
const std::shared_ptr<CWallet> wallet = std::make_shared<CWallet>(m_node.chain.get(), "", CreateDummyWalletDatabase());
278278
{
279279
auto spk_man = wallet->GetOrCreateLegacyScriptPubKeyMan();
280280
LOCK2(wallet->cs_wallet, spk_man->cs_KeyStore);
@@ -296,7 +296,7 @@ BOOST_FIXTURE_TEST_CASE(importwallet_rescan, TestChain100Setup)
296296
// Call importwallet RPC and verify all blocks with timestamps >= BLOCK_TIME
297297
// were scanned, and no prior blocks were scanned.
298298
{
299-
std::shared_ptr<CWallet> wallet = std::make_shared<CWallet>(m_node.chain.get(), "", CreateDummyWalletDatabase());
299+
const std::shared_ptr<CWallet> wallet = std::make_shared<CWallet>(m_node.chain.get(), "", CreateDummyWalletDatabase());
300300
LOCK(wallet->cs_wallet);
301301
wallet->SetupLegacyScriptPubKeyMan();
302302

@@ -606,7 +606,7 @@ BOOST_FIXTURE_TEST_CASE(ListCoinsTest, ListCoinsTestingSetup)
606606
BOOST_FIXTURE_TEST_CASE(wallet_disableprivkeys, TestChain100Setup)
607607
{
608608
{
609-
std::shared_ptr<CWallet> wallet = std::make_shared<CWallet>(m_node.chain.get(), "", CreateDummyWalletDatabase());
609+
const std::shared_ptr<CWallet> wallet = std::make_shared<CWallet>(m_node.chain.get(), "", CreateDummyWalletDatabase());
610610
wallet->SetupLegacyScriptPubKeyMan();
611611
wallet->SetMinVersion(FEATURE_LATEST);
612612
wallet->SetWalletFlag(WALLET_FLAG_DISABLE_PRIVATE_KEYS);
@@ -616,7 +616,7 @@ BOOST_FIXTURE_TEST_CASE(wallet_disableprivkeys, TestChain100Setup)
616616
BOOST_CHECK(!wallet->GetNewDestination(OutputType::BECH32, "", dest, error));
617617
}
618618
{
619-
std::shared_ptr<CWallet> wallet = std::make_shared<CWallet>(m_node.chain.get(), "", CreateDummyWalletDatabase());
619+
const std::shared_ptr<CWallet> wallet = std::make_shared<CWallet>(m_node.chain.get(), "", CreateDummyWalletDatabase());
620620
LOCK(wallet->cs_wallet);
621621
wallet->SetWalletFlag(WALLET_FLAG_DESCRIPTORS);
622622
wallet->SetMinVersion(FEATURE_LATEST);

src/wallet/wallet.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ std::shared_ptr<CWallet> LoadWalletInternal(WalletContext& context, const std::s
221221
}
222222

223223
context.chain->initMessage(_("Loading wallet…").translated);
224-
std::shared_ptr<CWallet> wallet = CWallet::Create(context, name, std::move(database), options.create_flags, error, warnings);
224+
const std::shared_ptr<CWallet> wallet = CWallet::Create(context, name, std::move(database), options.create_flags, error, warnings);
225225
if (!wallet) {
226226
error = Untranslated("Wallet loading failed.") + Untranslated(" ") + error;
227227
status = DatabaseStatus::FAILED_LOAD;
@@ -301,7 +301,7 @@ std::shared_ptr<CWallet> CreateWallet(WalletContext& context, const std::string&
301301

302302
// Make the wallet
303303
context.chain->initMessage(_("Loading wallet…").translated);
304-
std::shared_ptr<CWallet> wallet = CWallet::Create(context, name, std::move(database), wallet_creation_flags, error, warnings);
304+
const std::shared_ptr<CWallet> wallet = CWallet::Create(context, name, std::move(database), wallet_creation_flags, error, warnings);
305305
if (!wallet) {
306306
error = Untranslated("Wallet creation failed.") + Untranslated(" ") + error;
307307
status = DatabaseStatus::FAILED_CREATE;
@@ -2540,7 +2540,7 @@ std::shared_ptr<CWallet> CWallet::Create(WalletContext& context, const std::stri
25402540
int64_t nStart = GetTimeMillis();
25412541
// TODO: Can't use std::make_shared because we need a custom deleter but
25422542
// should be possible to use std::allocate_shared.
2543-
std::shared_ptr<CWallet> walletInstance(new CWallet(chain, name, std::move(database)), ReleaseWallet);
2543+
const std::shared_ptr<CWallet> walletInstance(new CWallet(chain, name, std::move(database)), ReleaseWallet);
25442544
bool rescan_required = false;
25452545
DBErrors nLoadWalletRet = walletInstance->LoadWallet();
25462546
if (nLoadWalletRet != DBErrors::LOAD_OK) {

src/wallet/wallettool.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ static void WalletCreate(CWallet* wallet_instance, uint64_t wallet_creation_flag
4040
wallet_instance->TopUpKeyPool();
4141
}
4242

43-
static std::shared_ptr<CWallet> MakeWallet(const std::string& name, const fs::path& path, DatabaseOptions options)
43+
static const std::shared_ptr<CWallet> MakeWallet(const std::string& name, const fs::path& path, DatabaseOptions options)
4444
{
4545
DatabaseStatus status;
4646
bilingual_str error;
@@ -151,15 +151,15 @@ bool ExecuteWalletToolFunc(const ArgsManager& args, const std::string& command)
151151
options.require_format = DatabaseFormat::SQLITE;
152152
}
153153

154-
std::shared_ptr<CWallet> wallet_instance = MakeWallet(name, path, options);
154+
const std::shared_ptr<CWallet> wallet_instance = MakeWallet(name, path, options);
155155
if (wallet_instance) {
156156
WalletShowInfo(wallet_instance.get());
157157
wallet_instance->Close();
158158
}
159159
} else if (command == "info") {
160160
DatabaseOptions options;
161161
options.require_existing = true;
162-
std::shared_ptr<CWallet> wallet_instance = MakeWallet(name, path, options);
162+
const std::shared_ptr<CWallet> wallet_instance = MakeWallet(name, path, options);
163163
if (!wallet_instance) return false;
164164
WalletShowInfo(wallet_instance.get());
165165
wallet_instance->Close();
@@ -184,7 +184,7 @@ bool ExecuteWalletToolFunc(const ArgsManager& args, const std::string& command)
184184
} else if (command == "dump") {
185185
DatabaseOptions options;
186186
options.require_existing = true;
187-
std::shared_ptr<CWallet> wallet_instance = MakeWallet(name, path, options);
187+
const std::shared_ptr<CWallet> wallet_instance = MakeWallet(name, path, options);
188188
if (!wallet_instance) return false;
189189
bilingual_str error;
190190
bool ret = DumpWallet(*wallet_instance, error);

0 commit comments

Comments
 (0)