Skip to content

Commit

Permalink
Fix crash in validateaddress with -disablewallet
Browse files Browse the repository at this point in the history
Closes #696
  • Loading branch information
crowning- authored and schinzelh committed Feb 15, 2016
1 parent cfc8cc2 commit 1f70fb3
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions src/rpcmisc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,10 @@ class DescribeAddressVisitor : public boost::static_visitor<Object>
CPubKey vchPubKey;
obj.push_back(Pair("isscript", false));
if (mine == ISMINE_SPENDABLE) {
pwalletMain->GetPubKey(keyID, vchPubKey);
obj.push_back(Pair("pubkey", HexStr(vchPubKey)));
obj.push_back(Pair("iscompressed", vchPubKey.IsCompressed()));
if (pwalletMain && pwalletMain->GetPubKey(keyID, vchPubKey)) {
obj.push_back(Pair("pubkey", HexStr(vchPubKey)));
obj.push_back(Pair("iscompressed", vchPubKey.IsCompressed()));
}
}
return obj;
}
Expand All @@ -179,19 +180,20 @@ class DescribeAddressVisitor : public boost::static_visitor<Object>
obj.push_back(Pair("isscript", true));
if (mine != ISMINE_NO) {
CScript subscript;
pwalletMain->GetCScript(scriptID, subscript);
std::vector<CTxDestination> addresses;
txnouttype whichType;
int nRequired;
ExtractDestinations(subscript, whichType, addresses, nRequired);
obj.push_back(Pair("script", GetTxnOutputType(whichType)));
obj.push_back(Pair("hex", HexStr(subscript.begin(), subscript.end())));
Array a;
BOOST_FOREACH(const CTxDestination& addr, addresses)
a.push_back(CBitcoinAddress(addr).ToString());
obj.push_back(Pair("addresses", a));
if (whichType == TX_MULTISIG)
obj.push_back(Pair("sigsrequired", nRequired));
if (pwalletMain && pwalletMain->GetCScript(scriptID, subscript)){
std::vector<CTxDestination> addresses;
txnouttype whichType;
int nRequired;
ExtractDestinations(subscript, whichType, addresses, nRequired);
obj.push_back(Pair("script", GetTxnOutputType(whichType)));
obj.push_back(Pair("hex", HexStr(subscript.begin(), subscript.end())));
Array a;
BOOST_FOREACH(const CTxDestination& addr, addresses)
a.push_back(CBitcoinAddress(addr).ToString());
obj.push_back(Pair("addresses", a));
if (whichType == TX_MULTISIG)
obj.push_back(Pair("sigsrequired", nRequired));
}
}
return obj;
}
Expand Down

0 comments on commit 1f70fb3

Please sign in to comment.