{
return (mapKeys.count(vchPubKey) > 0);
}
- CPrivKey GetPrivKey(const std::vector<unsigned char> &vchPubKey) const
+ bool GetPrivKey(const std::vector<unsigned char> &vchPubKey, CPrivKey& keyOut) const
{
std::map<std::vector<unsigned char>, CPrivKey>::const_iterator mi = mapKeys.find(vchPubKey);
if (mi != mapKeys.end())
- return (*mi).second;
+ {
+ keyOut = (*mi).second;
+ return true;
+ }
+ return false;
}
std::vector<unsigned char> GenerateNewKey();
};
{
// Sign
const valtype& vchPubKey = item.second;
- if (!keystore.HaveKey(vchPubKey))
+ CPrivKey privkey;
+ if (!keystore.GetPrivKey(vchPubKey, privkey))
return false;
if (hash != 0)
{
vector<unsigned char> vchSig;
- if (!CKey::Sign(keystore.GetPrivKey(vchPubKey), hash, vchSig))
+ if (!CKey::Sign(privkey, hash, vchSig))
return false;
vchSig.push_back((unsigned char)nHashType);
scriptSigRet << vchSig;
if (mi == mapPubKeys.end())
return false;
const vector<unsigned char>& vchPubKey = (*mi).second;
- if (!keystore.HaveKey(vchPubKey))
+ CPrivKey privkey;
+ if (!keystore.GetPrivKey(vchPubKey, privkey))
return false;
if (hash != 0)
{
vector<unsigned char> vchSig;
- if (!CKey::Sign(keystore.GetPrivKey(vchPubKey), hash, vchSig))
+ if (!CKey::Sign(privkey, hash, vchSig))
return false;
vchSig.push_back((unsigned char)nHashType);
scriptSigRet << vchSig << vchPubKey;
{
if (!MoneyRange(txout.nValue))
throw std::runtime_error("CWallet::GetChange() : value out of range");
- if (IsChange(txout) ? txout.nValue : 0);
+ return (IsChange(txout) ? txout.nValue : 0);
}
bool IsMine(const CTransaction& tx) const
{