@@ -34,6 +34,9 @@ static CKey ParsePrivKey(const std::string &strKeyOrAddress, bool allowAddresses
3434 CBitcoinAddress address;
3535 if (allowAddresses && address.SetString (strKeyOrAddress) && address.IsValid ()) {
3636#ifdef ENABLE_WALLET
37+ if (!pwalletMain) {
38+ throw std::runtime_error (" addresses not supported when wallet is disabled" );
39+ }
3740 CKeyID keyId;
3841 CKey key;
3942 if (!address.GetKeyID (keyId) || !pwalletMain->GetKey (keyId, key))
@@ -643,6 +646,10 @@ void protx_list_help()
643646}
644647
645648static bool CheckWalletOwnsScript (const CScript& script) {
649+ if (!pwalletMain) {
650+ return false ;
651+ }
652+
646653 CTxDestination dest;
647654 if (ExtractDestination (script, dest)) {
648655 if ((boost::get<CKeyID>(&dest) && pwalletMain->HaveKey (*boost::get<CKeyID>(&dest))) || (boost::get<CScriptID>(&dest) && pwalletMain->HaveCScript (*boost::get<CScriptID>(&dest)))) {
@@ -665,9 +672,9 @@ UniValue BuildDMNListEntry(const CDeterministicMNCPtr& dmn, bool detailed)
665672 int confirmations = GetUTXOConfirmations (dmn->collateralOutpoint );
666673 o.push_back (Pair (" confirmations" , confirmations));
667674
668- bool hasOwnerKey = pwalletMain->HaveKey (dmn->pdmnState ->keyIDOwner );
669- bool hasOperatorKey = false ; // pwalletMain->HaveKey(dmn->pdmnState->keyIDOperator);
670- bool hasVotingKey = pwalletMain->HaveKey (dmn->pdmnState ->keyIDVoting );
675+ bool hasOwnerKey = pwalletMain && pwalletMain ->HaveKey (dmn->pdmnState ->keyIDOwner );
676+ bool hasOperatorKey = false ; // pwalletMain && pwalletMain ->HaveKey(dmn->pdmnState->keyIDOperator);
677+ bool hasVotingKey = pwalletMain && pwalletMain ->HaveKey (dmn->pdmnState ->keyIDVoting );
671678
672679 bool ownsCollateral = false ;
673680 CTransactionRef collateralTx;
@@ -701,9 +708,14 @@ UniValue protx_list(const JSONRPCRequest& request)
701708
702709 UniValue ret (UniValue::VARR);
703710
704- LOCK2 (cs_main, pwalletMain-> cs_wallet );
711+ LOCK (cs_main);
705712
706713 if (type == " wallet" ) {
714+ if (!pwalletMain) {
715+ throw std::runtime_error (" \" protx list wallet\" not supported when wallet is disabled" );
716+ }
717+ LOCK (pwalletMain->cs_wallet );
718+
707719 if (request.params .size () > 3 ) {
708720 protx_list_help ();
709721 }
0 commit comments