Fix crash in validateaddress with -disablewallet

Closes #696
This commit is contained in:
crowning- 2016-02-14 13:35:31 +01:00 committed by Holger Schinzel
parent cfc8cc2fe5
commit 1f70fb3c04

View File

@ -167,9 +167,10 @@ public:
CPubKey vchPubKey; CPubKey vchPubKey;
obj.push_back(Pair("isscript", false)); obj.push_back(Pair("isscript", false));
if (mine == ISMINE_SPENDABLE) { if (mine == ISMINE_SPENDABLE) {
pwalletMain->GetPubKey(keyID, vchPubKey); if (pwalletMain && pwalletMain->GetPubKey(keyID, vchPubKey)) {
obj.push_back(Pair("pubkey", HexStr(vchPubKey))); obj.push_back(Pair("pubkey", HexStr(vchPubKey)));
obj.push_back(Pair("iscompressed", vchPubKey.IsCompressed())); obj.push_back(Pair("iscompressed", vchPubKey.IsCompressed()));
}
} }
return obj; return obj;
} }
@ -179,19 +180,20 @@ public:
obj.push_back(Pair("isscript", true)); obj.push_back(Pair("isscript", true));
if (mine != ISMINE_NO) { if (mine != ISMINE_NO) {
CScript subscript; CScript subscript;
pwalletMain->GetCScript(scriptID, subscript); if (pwalletMain && pwalletMain->GetCScript(scriptID, subscript)){
std::vector<CTxDestination> addresses; std::vector<CTxDestination> addresses;
txnouttype whichType; txnouttype whichType;
int nRequired; int nRequired;
ExtractDestinations(subscript, whichType, addresses, nRequired); ExtractDestinations(subscript, whichType, addresses, nRequired);
obj.push_back(Pair("script", GetTxnOutputType(whichType))); obj.push_back(Pair("script", GetTxnOutputType(whichType)));
obj.push_back(Pair("hex", HexStr(subscript.begin(), subscript.end()))); obj.push_back(Pair("hex", HexStr(subscript.begin(), subscript.end())));
Array a; Array a;
BOOST_FOREACH(const CTxDestination& addr, addresses) BOOST_FOREACH(const CTxDestination& addr, addresses)
a.push_back(CBitcoinAddress(addr).ToString()); a.push_back(CBitcoinAddress(addr).ToString());
obj.push_back(Pair("addresses", a)); obj.push_back(Pair("addresses", a));
if (whichType == TX_MULTISIG) if (whichType == TX_MULTISIG)
obj.push_back(Pair("sigsrequired", nRequired)); obj.push_back(Pair("sigsrequired", nRequired));
}
} }
return obj; return obj;
} }