@@ -70,7 +70,9 @@ UniValue getinfo(const JSONRPCRequest& request)
7070 );
7171
7272#ifdef ENABLE_WALLET
73- LOCK2 (cs_main, pwalletMain ? &pwalletMain->cs_wallet : NULL );
73+ CWallet * const pwallet = GetWalletForJSONRPCRequest (request);
74+
75+ LOCK2 (cs_main, pwallet ? &pwallet->cs_wallet : NULL );
7476#else
7577 LOCK (cs_main);
7678#endif
@@ -82,9 +84,9 @@ UniValue getinfo(const JSONRPCRequest& request)
8284 obj.push_back (Pair (" version" , CLIENT_VERSION));
8385 obj.push_back (Pair (" protocolversion" , PROTOCOL_VERSION));
8486#ifdef ENABLE_WALLET
85- if (pwalletMain ) {
86- obj.push_back (Pair (" walletversion" , pwalletMain ->GetVersion ()));
87- obj.push_back (Pair (" balance" , ValueFromAmount (pwalletMain ->GetBalance ())));
87+ if (pwallet ) {
88+ obj.push_back (Pair (" walletversion" , pwallet ->GetVersion ()));
89+ obj.push_back (Pair (" balance" , ValueFromAmount (pwallet ->GetBalance ())));
8890 }
8991#endif
9092 obj.push_back (Pair (" blocks" , (int )chainActive.Height ()));
@@ -95,11 +97,11 @@ UniValue getinfo(const JSONRPCRequest& request)
9597 obj.push_back (Pair (" difficulty" , (double )GetDifficulty ()));
9698 obj.push_back (Pair (" testnet" , Params ().NetworkIDString () == CBaseChainParams::TESTNET));
9799#ifdef ENABLE_WALLET
98- if (pwalletMain ) {
99- obj.push_back (Pair (" keypoololdest" , pwalletMain ->GetOldestKeyPoolTime ()));
100- obj.push_back (Pair (" keypoolsize" , (int )pwalletMain ->GetKeyPoolSize ()));
100+ if (pwallet ) {
101+ obj.push_back (Pair (" keypoololdest" , pwallet ->GetOldestKeyPoolTime ()));
102+ obj.push_back (Pair (" keypoolsize" , (int )pwallet ->GetKeyPoolSize ()));
101103 }
102- if (pwalletMain && pwalletMain ->IsCrypted ())
104+ if (pwallet && pwallet ->IsCrypted ())
103105 obj.push_back (Pair (" unlocked_until" , nWalletUnlockTime));
104106 obj.push_back (Pair (" paytxfee" , ValueFromAmount (payTxFee.GetFeePerK ())));
105107#endif
@@ -181,7 +183,9 @@ UniValue validateaddress(const JSONRPCRequest& request)
181183 );
182184
183185#ifdef ENABLE_WALLET
184- LOCK2 (cs_main, pwalletMain ? &pwalletMain->cs_wallet : NULL );
186+ CWallet * const pwallet = GetWalletForJSONRPCRequest (request);
187+
188+ LOCK2 (cs_main, pwallet ? &pwallet->cs_wallet : NULL );
185189#else
186190 LOCK (cs_main);
187191#endif
@@ -201,16 +205,16 @@ UniValue validateaddress(const JSONRPCRequest& request)
201205 ret.push_back (Pair (" scriptPubKey" , HexStr (scriptPubKey.begin (), scriptPubKey.end ())));
202206
203207#ifdef ENABLE_WALLET
204- isminetype mine = pwalletMain ? IsMine (*pwalletMain , dest) : ISMINE_NO;
208+ isminetype mine = pwallet ? IsMine (*pwallet , dest) : ISMINE_NO;
205209 ret.push_back (Pair (" ismine" , (mine & ISMINE_SPENDABLE) ? true : false ));
206210 ret.push_back (Pair (" iswatchonly" , (mine & ISMINE_WATCH_ONLY) ? true : false ));
207- UniValue detail = boost::apply_visitor (DescribeAddressVisitor (pwalletMain ), dest);
211+ UniValue detail = boost::apply_visitor (DescribeAddressVisitor (pwallet ), dest);
208212 ret.pushKVs (detail);
209- if (pwalletMain && pwalletMain ->mapAddressBook .count (dest))
210- ret.push_back (Pair (" account" , pwalletMain ->mapAddressBook [dest].name ));
213+ if (pwallet && pwallet ->mapAddressBook .count (dest))
214+ ret.push_back (Pair (" account" , pwallet ->mapAddressBook [dest].name ));
211215 CKeyID keyID;
212- if (pwalletMain ) {
213- const auto & meta = pwalletMain ->mapKeyMetadata ;
216+ if (pwallet ) {
217+ const auto & meta = pwallet ->mapKeyMetadata ;
214218 auto it = address.GetKeyID (keyID) ? meta.find (keyID) : meta.end ();
215219 if (it == meta.end ()) {
216220 it = meta.find (CScriptID (scriptPubKey));
@@ -294,6 +298,12 @@ CScript _createmultisig_redeemScript(CWallet * const pwallet, const UniValue& pa
294298
295299UniValue createmultisig (const JSONRPCRequest& request)
296300{
301+ #ifdef ENABLE_WALLET
302+ CWallet * const pwallet = GetWalletForJSONRPCRequest (request);
303+ #else
304+ CWallet * const pwallet = NULL ;
305+ #endif
306+
297307 if (request.fHelp || request.params .size () < 2 || request.params .size () > 2 )
298308 {
299309 string msg = " createmultisig nrequired [\" key\" ,...]\n "
@@ -324,7 +334,7 @@ UniValue createmultisig(const JSONRPCRequest& request)
324334 }
325335
326336 // Construct using pay-to-script-hash:
327- CScript inner = _createmultisig_redeemScript (pwalletMain , request.params );
337+ CScript inner = _createmultisig_redeemScript (pwallet , request.params );
328338 CScriptID innerID (inner);
329339 CBitcoinAddress address (innerID);
330340
0 commit comments