@@ -118,22 +118,21 @@ RPCHelpMan importprivkey()
118118 },
119119 [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
120120{
121- std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest (request);
122- if (!wallet) return NullUniValue;
123- CWallet* const pwallet = wallet.get ();
121+ std::shared_ptr<CWallet> const pwallet = GetWalletForJSONRPCRequest (request);
122+ if (!pwallet) return NullUniValue;
124123
125124 if (pwallet->IsWalletFlagSet (WALLET_FLAG_DISABLE_PRIVATE_KEYS)) {
126125 throw JSONRPCError (RPC_WALLET_ERROR, " Cannot import private keys to a wallet with private keys disabled" );
127126 }
128127
129- EnsureLegacyScriptPubKeyMan (*wallet , true );
128+ EnsureLegacyScriptPubKeyMan (*pwallet , true );
130129
131130 WalletRescanReserver reserver (*pwallet);
132131 bool fRescan = true ;
133132 {
134133 LOCK (pwallet->cs_wallet );
135134
136- EnsureWalletIsUnlocked (pwallet);
135+ EnsureWalletIsUnlocked (pwallet. get () );
137136
138137 std::string strSecret = request.params [0 ].get_str ();
139138 std::string strLabel = " " ;
@@ -210,9 +209,8 @@ RPCHelpMan abortrescan()
210209 },
211210 [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
212211{
213- std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest (request);
214- if (!wallet) return NullUniValue;
215- CWallet* const pwallet = wallet.get ();
212+ std::shared_ptr<CWallet> const pwallet = GetWalletForJSONRPCRequest (request);
213+ if (!pwallet) return NullUniValue;
216214
217215 if (!pwallet->IsScanning () || pwallet->IsAbortingRescan ()) return false ;
218216 pwallet->AbortRescan ();
@@ -249,9 +247,8 @@ RPCHelpMan importaddress()
249247 },
250248 [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
251249{
252- std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest (request);
253- if (!wallet) return NullUniValue;
254- CWallet* const pwallet = wallet.get ();
250+ std::shared_ptr<CWallet> const pwallet = GetWalletForJSONRPCRequest (request);
251+ if (!pwallet) return NullUniValue;
255252
256253 EnsureLegacyScriptPubKeyMan (*pwallet, true );
257254
@@ -335,9 +332,8 @@ RPCHelpMan importprunedfunds()
335332 RPCExamples{" " },
336333 [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
337334{
338- std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest (request);
339- if (!wallet) return NullUniValue;
340- CWallet* const pwallet = wallet.get ();
335+ std::shared_ptr<CWallet> const pwallet = GetWalletForJSONRPCRequest (request);
336+ if (!pwallet) return NullUniValue;
341337
342338 CMutableTransaction tx;
343339 if (!DecodeHexTx (tx, request.params [0 ].get_str ())) {
@@ -397,9 +393,8 @@ RPCHelpMan removeprunedfunds()
397393 },
398394 [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
399395{
400- std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest (request);
401- if (!wallet) return NullUniValue;
402- CWallet* const pwallet = wallet.get ();
396+ std::shared_ptr<CWallet> const pwallet = GetWalletForJSONRPCRequest (request);
397+ if (!pwallet) return NullUniValue;
403398
404399 LOCK (pwallet->cs_wallet );
405400
@@ -445,11 +440,10 @@ RPCHelpMan importpubkey()
445440 },
446441 [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
447442{
448- std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest (request);
449- if (!wallet) return NullUniValue;
450- CWallet* const pwallet = wallet.get ();
443+ std::shared_ptr<CWallet> const pwallet = GetWalletForJSONRPCRequest (request);
444+ if (!pwallet) return NullUniValue;
451445
452- EnsureLegacyScriptPubKeyMan (*wallet , true );
446+ EnsureLegacyScriptPubKeyMan (*pwallet , true );
453447
454448 std::string strLabel;
455449 if (!request.params [1 ].isNull ())
@@ -527,11 +521,10 @@ RPCHelpMan importwallet()
527521 },
528522 [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
529523{
530- std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest (request);
531- if (!wallet) return NullUniValue;
532- CWallet* const pwallet = wallet.get ();
524+ std::shared_ptr<CWallet> const pwallet = GetWalletForJSONRPCRequest (request);
525+ if (!pwallet) return NullUniValue;
533526
534- EnsureLegacyScriptPubKeyMan (*wallet , true );
527+ EnsureLegacyScriptPubKeyMan (*pwallet , true );
535528
536529 if (pwallet->chain ().havePruned ()) {
537530 // Exit early and print an error.
@@ -550,7 +543,7 @@ RPCHelpMan importwallet()
550543 {
551544 LOCK (pwallet->cs_wallet );
552545
553- EnsureWalletIsUnlocked (pwallet);
546+ EnsureWalletIsUnlocked (pwallet. get () );
554547
555548 fsbridge::ifstream file;
556549 file.open (request.params [0 ].get_str (), std::ios::in | std::ios::ate);
@@ -684,15 +677,14 @@ RPCHelpMan dumpprivkey()
684677 },
685678 [&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
686679{
687- std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest (request);
688- if (!wallet) return NullUniValue;
689- const CWallet* const pwallet = wallet.get ();
680+ std::shared_ptr<CWallet> const pwallet = GetWalletForJSONRPCRequest (request);
681+ if (!pwallet) return NullUniValue;
690682
691- LegacyScriptPubKeyMan& spk_man = EnsureLegacyScriptPubKeyMan (*wallet );
683+ LegacyScriptPubKeyMan& spk_man = EnsureLegacyScriptPubKeyMan (*pwallet );
692684
693685 LOCK2 (pwallet->cs_wallet , spk_man.cs_KeyStore );
694686
695- EnsureWalletIsUnlocked (pwallet);
687+ EnsureWalletIsUnlocked (pwallet. get () );
696688
697689 std::string strAddress = request.params [0 ].get_str ();
698690 CTxDestination dest = DecodeDestination (strAddress);
@@ -1336,13 +1328,12 @@ RPCHelpMan importmulti()
13361328 },
13371329 [&](const RPCHelpMan& self, const JSONRPCRequest& mainRequest) -> UniValue
13381330{
1339- std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest (mainRequest);
1340- if (!wallet) return NullUniValue;
1341- CWallet* const pwallet = wallet.get ();
1331+ std::shared_ptr<CWallet> const pwallet = GetWalletForJSONRPCRequest (mainRequest);
1332+ if (!pwallet) return NullUniValue;
13421333
13431334 RPCTypeCheck (mainRequest.params , {UniValue::VARR, UniValue::VOBJ});
13441335
1345- EnsureLegacyScriptPubKeyMan (*wallet , true );
1336+ EnsureLegacyScriptPubKeyMan (*pwallet , true );
13461337
13471338 const UniValue& requests = mainRequest.params [0 ];
13481339
@@ -1368,7 +1359,7 @@ RPCHelpMan importmulti()
13681359 UniValue response (UniValue::VARR);
13691360 {
13701361 LOCK (pwallet->cs_wallet );
1371- EnsureWalletIsUnlocked (pwallet);
1362+ EnsureWalletIsUnlocked (pwallet. get () );
13721363
13731364 // Verify all timestamps are present before importing any keys.
13741365 CHECK_NONFATAL (pwallet->chain ().findBlock (pwallet->GetLastBlockHash (), FoundBlock ().time (nLowestTimestamp).mtpTime (now)));
@@ -1380,7 +1371,7 @@ RPCHelpMan importmulti()
13801371
13811372 for (const UniValue& data : requests.getValues ()) {
13821373 const int64_t timestamp = std::max (GetImportTimestamp (data, now), minimumTimestamp);
1383- const UniValue result = ProcessImport (pwallet, data, timestamp);
1374+ const UniValue result = ProcessImport (pwallet. get () , data, timestamp);
13841375 response.push_back (result);
13851376
13861377 if (!fRescan ) {
@@ -1641,9 +1632,8 @@ RPCHelpMan importdescriptors()
16411632 },
16421633 [&](const RPCHelpMan& self, const JSONRPCRequest& main_request) -> UniValue
16431634{
1644- std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest (main_request);
1645- if (!wallet) return NullUniValue;
1646- CWallet* const pwallet = wallet.get ();
1635+ std::shared_ptr<CWallet> const pwallet = GetWalletForJSONRPCRequest (main_request);
1636+ if (!pwallet) return NullUniValue;
16471637
16481638 // Make sure wallet is a descriptor wallet
16491639 if (!pwallet->IsWalletFlagSet (WALLET_FLAG_DESCRIPTORS)) {
@@ -1665,15 +1655,15 @@ RPCHelpMan importdescriptors()
16651655 UniValue response (UniValue::VARR);
16661656 {
16671657 LOCK (pwallet->cs_wallet );
1668- EnsureWalletIsUnlocked (pwallet);
1658+ EnsureWalletIsUnlocked (pwallet. get () );
16691659
16701660 CHECK_NONFATAL (pwallet->chain ().findBlock (pwallet->GetLastBlockHash (), FoundBlock ().time (lowest_timestamp).mtpTime (now)));
16711661
16721662 // Get all timestamps and extract the lowest timestamp
16731663 for (const UniValue& request : requests.getValues ()) {
16741664 // This throws an error if "timestamp" doesn't exist
16751665 const int64_t timestamp = std::max (GetImportTimestamp (request, now), minimum_timestamp);
1676- const UniValue result = ProcessDescriptorImport (pwallet, request, timestamp);
1666+ const UniValue result = ProcessDescriptorImport (pwallet. get () , request, timestamp);
16771667 response.push_back (result);
16781668
16791669 if (lowest_timestamp > timestamp ) {
0 commit comments