@@ -56,13 +56,13 @@ static std::string DecodeDumpString(const std::string &str) {
56
56
return ret.str ();
57
57
}
58
58
59
- static bool GetWalletAddressesForKey (LegacyScriptPubKeyMan* spk_man, const CWallet* const pwallet , const CKeyID& keyid, std::string& strAddr, std::string& strLabel) EXCLUSIVE_LOCKS_REQUIRED(pwallet-> cs_wallet)
59
+ static bool GetWalletAddressesForKey (LegacyScriptPubKeyMan* spk_man, const CWallet& wallet , const CKeyID& keyid, std::string& strAddr, std::string& strLabel) EXCLUSIVE_LOCKS_REQUIRED(wallet. cs_wallet)
60
60
{
61
61
bool fLabelFound = false ;
62
62
CKey key;
63
63
spk_man->GetKey (keyid, key);
64
64
for (const auto & dest : GetAllDestinationsForKey (key.GetPubKey ())) {
65
- const auto * address_book_entry = pwallet-> FindAddressBookEntry (dest);
65
+ const auto * address_book_entry = wallet. FindAddressBookEntry (dest);
66
66
if (address_book_entry) {
67
67
if (!strAddr.empty ()) {
68
68
strAddr += " ," ;
@@ -73,7 +73,7 @@ static bool GetWalletAddressesForKey(LegacyScriptPubKeyMan* spk_man, const CWall
73
73
}
74
74
}
75
75
if (!fLabelFound ) {
76
- strAddr = EncodeDestination (GetDestinationForKey (key.GetPubKey (), pwallet-> m_default_address_type ));
76
+ strAddr = EncodeDestination (GetDestinationForKey (key.GetPubKey (), wallet. m_default_address_type ));
77
77
}
78
78
return fLabelFound ;
79
79
}
@@ -132,7 +132,7 @@ RPCHelpMan importprivkey()
132
132
{
133
133
LOCK (pwallet->cs_wallet );
134
134
135
- EnsureWalletIsUnlocked (pwallet. get () );
135
+ EnsureWalletIsUnlocked (* pwallet);
136
136
137
137
std::string strSecret = request.params [0 ].get_str ();
138
138
std::string strLabel = " " ;
@@ -543,7 +543,7 @@ RPCHelpMan importwallet()
543
543
{
544
544
LOCK (pwallet->cs_wallet );
545
545
546
- EnsureWalletIsUnlocked (pwallet. get () );
546
+ EnsureWalletIsUnlocked (* pwallet);
547
547
548
548
fsbridge::ifstream file;
549
549
file.open (request.params [0 ].get_str (), std::ios::in | std::ios::ate);
@@ -684,7 +684,7 @@ RPCHelpMan dumpprivkey()
684
684
685
685
LOCK2 (pwallet->cs_wallet , spk_man.cs_KeyStore );
686
686
687
- EnsureWalletIsUnlocked (pwallet. get () );
687
+ EnsureWalletIsUnlocked (* pwallet);
688
688
689
689
std::string strAddress = request.params [0 ].get_str ();
690
690
CTxDestination dest = DecodeDestination (strAddress);
@@ -739,7 +739,7 @@ RPCHelpMan dumpwallet()
739
739
740
740
LOCK2 (wallet.cs_wallet , spk_man.cs_KeyStore );
741
741
742
- EnsureWalletIsUnlocked (& wallet);
742
+ EnsureWalletIsUnlocked (wallet);
743
743
744
744
fs::path filepath = request.params [0 ].get_str ();
745
745
filepath = fs::absolute (filepath);
@@ -801,7 +801,7 @@ RPCHelpMan dumpwallet()
801
801
CKey key;
802
802
if (spk_man.GetKey (keyid, key)) {
803
803
file << strprintf (" %s %s " , EncodeSecret (key), strTime);
804
- if (GetWalletAddressesForKey (&spk_man, & wallet, keyid, strAddr, strLabel)) {
804
+ if (GetWalletAddressesForKey (&spk_man, wallet, keyid, strAddr, strLabel)) {
805
805
file << strprintf (" label=%s" , strLabel);
806
806
} else if (keyid == seed_id) {
807
807
file << " hdseed=1" ;
@@ -1161,7 +1161,7 @@ static UniValue ProcessImportDescriptor(ImportData& import_data, std::map<CKeyID
1161
1161
return warnings;
1162
1162
}
1163
1163
1164
- static UniValue ProcessImport (CWallet * const pwallet , const UniValue& data, const int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(pwallet-> cs_wallet)
1164
+ static UniValue ProcessImport (CWallet& wallet , const UniValue& data, const int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(wallet. cs_wallet)
1165
1165
{
1166
1166
UniValue warnings (UniValue::VARR);
1167
1167
UniValue result (UniValue::VOBJ);
@@ -1176,7 +1176,7 @@ static UniValue ProcessImport(CWallet * const pwallet, const UniValue& data, con
1176
1176
const bool add_keypool = data.exists (" keypool" ) ? data[" keypool" ].get_bool () : false ;
1177
1177
1178
1178
// Add to keypool only works with privkeys disabled
1179
- if (add_keypool && !pwallet-> IsWalletFlagSet (WALLET_FLAG_DISABLE_PRIVATE_KEYS)) {
1179
+ if (add_keypool && !wallet. IsWalletFlagSet (WALLET_FLAG_DISABLE_PRIVATE_KEYS)) {
1180
1180
throw JSONRPCError (RPC_INVALID_PARAMETER, " Keys can only be imported to the keypool when private keys are disabled" );
1181
1181
}
1182
1182
@@ -1198,29 +1198,29 @@ static UniValue ProcessImport(CWallet * const pwallet, const UniValue& data, con
1198
1198
}
1199
1199
1200
1200
// If private keys are disabled, abort if private keys are being imported
1201
- if (pwallet-> IsWalletFlagSet (WALLET_FLAG_DISABLE_PRIVATE_KEYS) && !privkey_map.empty ()) {
1201
+ if (wallet. IsWalletFlagSet (WALLET_FLAG_DISABLE_PRIVATE_KEYS) && !privkey_map.empty ()) {
1202
1202
throw JSONRPCError (RPC_WALLET_ERROR, " Cannot import private keys to a wallet with private keys disabled" );
1203
1203
}
1204
1204
1205
1205
// Check whether we have any work to do
1206
1206
for (const CScript& script : script_pub_keys) {
1207
- if (pwallet-> IsMine (script) & ISMINE_SPENDABLE) {
1207
+ if (wallet. IsMine (script) & ISMINE_SPENDABLE) {
1208
1208
throw JSONRPCError (RPC_WALLET_ERROR, " The wallet already contains the private key for this address or script (\" " + HexStr (script) + " \" )" );
1209
1209
}
1210
1210
}
1211
1211
1212
1212
// All good, time to import
1213
- pwallet-> MarkDirty ();
1214
- if (!pwallet-> ImportScripts (import_data.import_scripts , timestamp)) {
1213
+ wallet. MarkDirty ();
1214
+ if (!wallet. ImportScripts (import_data.import_scripts , timestamp)) {
1215
1215
throw JSONRPCError (RPC_WALLET_ERROR, " Error adding script to wallet" );
1216
1216
}
1217
- if (!pwallet-> ImportPrivKeys (privkey_map, timestamp)) {
1217
+ if (!wallet. ImportPrivKeys (privkey_map, timestamp)) {
1218
1218
throw JSONRPCError (RPC_WALLET_ERROR, " Error adding key to wallet" );
1219
1219
}
1220
- if (!pwallet-> ImportPubKeys (ordered_pubkeys, pubkey_map, import_data.key_origins , add_keypool, internal, timestamp)) {
1220
+ if (!wallet. ImportPubKeys (ordered_pubkeys, pubkey_map, import_data.key_origins , add_keypool, internal, timestamp)) {
1221
1221
throw JSONRPCError (RPC_WALLET_ERROR, " Error adding address to wallet" );
1222
1222
}
1223
- if (!pwallet-> ImportScriptPubKeys (label, script_pub_keys, have_solving_data, !internal, timestamp)) {
1223
+ if (!wallet. ImportScriptPubKeys (label, script_pub_keys, have_solving_data, !internal, timestamp)) {
1224
1224
throw JSONRPCError (RPC_WALLET_ERROR, " Error adding address to wallet" );
1225
1225
}
1226
1226
@@ -1359,7 +1359,7 @@ RPCHelpMan importmulti()
1359
1359
UniValue response (UniValue::VARR);
1360
1360
{
1361
1361
LOCK (pwallet->cs_wallet );
1362
- EnsureWalletIsUnlocked (pwallet. get () );
1362
+ EnsureWalletIsUnlocked (* pwallet);
1363
1363
1364
1364
// Verify all timestamps are present before importing any keys.
1365
1365
CHECK_NONFATAL (pwallet->chain ().findBlock (pwallet->GetLastBlockHash (), FoundBlock ().time (nLowestTimestamp).mtpTime (now)));
@@ -1371,7 +1371,7 @@ RPCHelpMan importmulti()
1371
1371
1372
1372
for (const UniValue& data : requests.getValues ()) {
1373
1373
const int64_t timestamp = std::max (GetImportTimestamp (data, now), minimumTimestamp);
1374
- const UniValue result = ProcessImport (pwallet. get () , data, timestamp);
1374
+ const UniValue result = ProcessImport (* pwallet, data, timestamp);
1375
1375
response.push_back (result);
1376
1376
1377
1377
if (!fRescan ) {
@@ -1438,7 +1438,7 @@ RPCHelpMan importmulti()
1438
1438
};
1439
1439
}
1440
1440
1441
- static UniValue ProcessDescriptorImport (CWallet * const pwallet , const UniValue& data, const int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(pwallet-> cs_wallet)
1441
+ static UniValue ProcessDescriptorImport (CWallet& wallet , const UniValue& data, const int64_t timestamp) EXCLUSIVE_LOCKS_REQUIRED(wallet. cs_wallet)
1442
1442
{
1443
1443
UniValue warnings (UniValue::VARR);
1444
1444
UniValue result (UniValue::VOBJ);
@@ -1507,7 +1507,7 @@ static UniValue ProcessDescriptorImport(CWallet * const pwallet, const UniValue&
1507
1507
}
1508
1508
1509
1509
// If the wallet disabled private keys, abort if private keys exist
1510
- if (pwallet-> IsWalletFlagSet (WALLET_FLAG_DISABLE_PRIVATE_KEYS) && !keys.keys .empty ()) {
1510
+ if (wallet. IsWalletFlagSet (WALLET_FLAG_DISABLE_PRIVATE_KEYS) && !keys.keys .empty ()) {
1511
1511
throw JSONRPCError (RPC_WALLET_ERROR, " Cannot import private keys to a wallet with private keys disabled" );
1512
1512
}
1513
1513
@@ -1531,7 +1531,7 @@ static UniValue ProcessDescriptorImport(CWallet * const pwallet, const UniValue&
1531
1531
}
1532
1532
1533
1533
// If private keys are enabled, check some things.
1534
- if (!pwallet-> IsWalletFlagSet (WALLET_FLAG_DISABLE_PRIVATE_KEYS)) {
1534
+ if (!wallet. IsWalletFlagSet (WALLET_FLAG_DISABLE_PRIVATE_KEYS)) {
1535
1535
if (keys.keys .empty ()) {
1536
1536
throw JSONRPCError (RPC_WALLET_ERROR, " Cannot import descriptor without private keys to a wallet with private keys enabled" );
1537
1537
}
@@ -1543,7 +1543,7 @@ static UniValue ProcessDescriptorImport(CWallet * const pwallet, const UniValue&
1543
1543
WalletDescriptor w_desc (std::move (parsed_desc), timestamp, range_start, range_end, next_index);
1544
1544
1545
1545
// Check if the wallet already contains the descriptor
1546
- auto existing_spk_manager = pwallet-> GetDescriptorScriptPubKeyMan (w_desc);
1546
+ auto existing_spk_manager = wallet. GetDescriptorScriptPubKeyMan (w_desc);
1547
1547
if (existing_spk_manager) {
1548
1548
LOCK (existing_spk_manager->cs_desc_man );
1549
1549
if (range_start > existing_spk_manager->GetWalletDescriptor ().range_start ) {
@@ -1552,7 +1552,7 @@ static UniValue ProcessDescriptorImport(CWallet * const pwallet, const UniValue&
1552
1552
}
1553
1553
1554
1554
// Add descriptor to the wallet
1555
- auto spk_manager = pwallet-> AddWalletDescriptor (w_desc, keys, label, internal);
1555
+ auto spk_manager = wallet. AddWalletDescriptor (w_desc, keys, label, internal);
1556
1556
if (spk_manager == nullptr ) {
1557
1557
throw JSONRPCError (RPC_WALLET_ERROR, strprintf (" Could not add descriptor '%s'" , descriptor));
1558
1558
}
@@ -1562,7 +1562,7 @@ static UniValue ProcessDescriptorImport(CWallet * const pwallet, const UniValue&
1562
1562
if (!w_desc.descriptor ->GetOutputType ()) {
1563
1563
warnings.push_back (" Unknown output type, cannot set descriptor to active." );
1564
1564
} else {
1565
- pwallet-> AddActiveScriptPubKeyMan (spk_manager->GetID (), *w_desc.descriptor ->GetOutputType (), internal);
1565
+ wallet. AddActiveScriptPubKeyMan (spk_manager->GetID (), *w_desc.descriptor ->GetOutputType (), internal);
1566
1566
}
1567
1567
}
1568
1568
@@ -1655,15 +1655,15 @@ RPCHelpMan importdescriptors()
1655
1655
UniValue response (UniValue::VARR);
1656
1656
{
1657
1657
LOCK (pwallet->cs_wallet );
1658
- EnsureWalletIsUnlocked (pwallet. get () );
1658
+ EnsureWalletIsUnlocked (* pwallet);
1659
1659
1660
1660
CHECK_NONFATAL (pwallet->chain ().findBlock (pwallet->GetLastBlockHash (), FoundBlock ().time (lowest_timestamp).mtpTime (now)));
1661
1661
1662
1662
// Get all timestamps and extract the lowest timestamp
1663
1663
for (const UniValue& request : requests.getValues ()) {
1664
1664
// This throws an error if "timestamp" doesn't exist
1665
1665
const int64_t timestamp = std::max (GetImportTimestamp (request, now), minimum_timestamp);
1666
- const UniValue result = ProcessDescriptorImport (pwallet. get () , request, timestamp);
1666
+ const UniValue result = ProcessDescriptorImport (* pwallet, request, timestamp);
1667
1667
response.push_back (result);
1668
1668
1669
1669
if (lowest_timestamp > timestamp ) {
@@ -1765,7 +1765,7 @@ RPCHelpMan listdescriptors()
1765
1765
throw JSONRPCError (RPC_WALLET_ERROR, " listdescriptors is not available for non-descriptor wallets" );
1766
1766
}
1767
1767
1768
- EnsureWalletIsUnlocked (wallet. get () );
1768
+ EnsureWalletIsUnlocked (* wallet);
1769
1769
1770
1770
LOCK (wallet->cs_wallet );
1771
1771
0 commit comments