@@ -118,22 +118,21 @@ RPCHelpMan importprivkey()
118
118
},
119
119
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
120
120
{
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;
124
123
125
124
if (pwallet->IsWalletFlagSet (WALLET_FLAG_DISABLE_PRIVATE_KEYS)) {
126
125
throw JSONRPCError (RPC_WALLET_ERROR, " Cannot import private keys to a wallet with private keys disabled" );
127
126
}
128
127
129
- EnsureLegacyScriptPubKeyMan (*wallet , true );
128
+ EnsureLegacyScriptPubKeyMan (*pwallet , true );
130
129
131
130
WalletRescanReserver reserver (*pwallet);
132
131
bool fRescan = true ;
133
132
{
134
133
LOCK (pwallet->cs_wallet );
135
134
136
- EnsureWalletIsUnlocked (pwallet);
135
+ EnsureWalletIsUnlocked (pwallet. get () );
137
136
138
137
std::string strSecret = request.params [0 ].get_str ();
139
138
std::string strLabel = " " ;
@@ -210,9 +209,8 @@ RPCHelpMan abortrescan()
210
209
},
211
210
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
212
211
{
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;
216
214
217
215
if (!pwallet->IsScanning () || pwallet->IsAbortingRescan ()) return false ;
218
216
pwallet->AbortRescan ();
@@ -249,9 +247,8 @@ RPCHelpMan importaddress()
249
247
},
250
248
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
251
249
{
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;
255
252
256
253
EnsureLegacyScriptPubKeyMan (*pwallet, true );
257
254
@@ -335,9 +332,8 @@ RPCHelpMan importprunedfunds()
335
332
RPCExamples{" " },
336
333
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
337
334
{
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;
341
337
342
338
CMutableTransaction tx;
343
339
if (!DecodeHexTx (tx, request.params [0 ].get_str ())) {
@@ -397,9 +393,8 @@ RPCHelpMan removeprunedfunds()
397
393
},
398
394
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
399
395
{
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;
403
398
404
399
LOCK (pwallet->cs_wallet );
405
400
@@ -445,11 +440,10 @@ RPCHelpMan importpubkey()
445
440
},
446
441
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
447
442
{
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;
451
445
452
- EnsureLegacyScriptPubKeyMan (*wallet , true );
446
+ EnsureLegacyScriptPubKeyMan (*pwallet , true );
453
447
454
448
std::string strLabel;
455
449
if (!request.params [1 ].isNull ())
@@ -527,11 +521,10 @@ RPCHelpMan importwallet()
527
521
},
528
522
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
529
523
{
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;
533
526
534
- EnsureLegacyScriptPubKeyMan (*wallet , true );
527
+ EnsureLegacyScriptPubKeyMan (*pwallet , true );
535
528
536
529
if (pwallet->chain ().havePruned ()) {
537
530
// Exit early and print an error.
@@ -550,7 +543,7 @@ RPCHelpMan importwallet()
550
543
{
551
544
LOCK (pwallet->cs_wallet );
552
545
553
- EnsureWalletIsUnlocked (pwallet);
546
+ EnsureWalletIsUnlocked (pwallet. get () );
554
547
555
548
fsbridge::ifstream file;
556
549
file.open (request.params [0 ].get_str (), std::ios::in | std::ios::ate);
@@ -684,15 +677,14 @@ RPCHelpMan dumpprivkey()
684
677
},
685
678
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
686
679
{
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;
690
682
691
- LegacyScriptPubKeyMan& spk_man = EnsureLegacyScriptPubKeyMan (*wallet );
683
+ LegacyScriptPubKeyMan& spk_man = EnsureLegacyScriptPubKeyMan (*pwallet );
692
684
693
685
LOCK2 (pwallet->cs_wallet , spk_man.cs_KeyStore );
694
686
695
- EnsureWalletIsUnlocked (pwallet);
687
+ EnsureWalletIsUnlocked (pwallet. get () );
696
688
697
689
std::string strAddress = request.params [0 ].get_str ();
698
690
CTxDestination dest = DecodeDestination (strAddress);
@@ -1336,13 +1328,12 @@ RPCHelpMan importmulti()
1336
1328
},
1337
1329
[&](const RPCHelpMan& self, const JSONRPCRequest& mainRequest) -> UniValue
1338
1330
{
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;
1342
1333
1343
1334
RPCTypeCheck (mainRequest.params , {UniValue::VARR, UniValue::VOBJ});
1344
1335
1345
- EnsureLegacyScriptPubKeyMan (*wallet , true );
1336
+ EnsureLegacyScriptPubKeyMan (*pwallet , true );
1346
1337
1347
1338
const UniValue& requests = mainRequest.params [0 ];
1348
1339
@@ -1368,7 +1359,7 @@ RPCHelpMan importmulti()
1368
1359
UniValue response (UniValue::VARR);
1369
1360
{
1370
1361
LOCK (pwallet->cs_wallet );
1371
- EnsureWalletIsUnlocked (pwallet);
1362
+ EnsureWalletIsUnlocked (pwallet. get () );
1372
1363
1373
1364
// Verify all timestamps are present before importing any keys.
1374
1365
CHECK_NONFATAL (pwallet->chain ().findBlock (pwallet->GetLastBlockHash (), FoundBlock ().time (nLowestTimestamp).mtpTime (now)));
@@ -1380,7 +1371,7 @@ RPCHelpMan importmulti()
1380
1371
1381
1372
for (const UniValue& data : requests.getValues ()) {
1382
1373
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);
1384
1375
response.push_back (result);
1385
1376
1386
1377
if (!fRescan ) {
@@ -1641,9 +1632,8 @@ RPCHelpMan importdescriptors()
1641
1632
},
1642
1633
[&](const RPCHelpMan& self, const JSONRPCRequest& main_request) -> UniValue
1643
1634
{
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;
1647
1637
1648
1638
// Make sure wallet is a descriptor wallet
1649
1639
if (!pwallet->IsWalletFlagSet (WALLET_FLAG_DESCRIPTORS)) {
@@ -1665,15 +1655,15 @@ RPCHelpMan importdescriptors()
1665
1655
UniValue response (UniValue::VARR);
1666
1656
{
1667
1657
LOCK (pwallet->cs_wallet );
1668
- EnsureWalletIsUnlocked (pwallet);
1658
+ EnsureWalletIsUnlocked (pwallet. get () );
1669
1659
1670
1660
CHECK_NONFATAL (pwallet->chain ().findBlock (pwallet->GetLastBlockHash (), FoundBlock ().time (lowest_timestamp).mtpTime (now)));
1671
1661
1672
1662
// Get all timestamps and extract the lowest timestamp
1673
1663
for (const UniValue& request : requests.getValues ()) {
1674
1664
// This throws an error if "timestamp" doesn't exist
1675
1665
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);
1677
1667
response.push_back (result);
1678
1668
1679
1669
if (lowest_timestamp > timestamp ) {
0 commit comments