Bugfixes walletclass
Some problems found by ius: * compiler complains with no return after critical section block * CKeyStore::GetPrivKey(key) was undefined for unknown key * missing return statement in GetChange()
This commit is contained in:
parent
04e442070d
commit
98705aa51c
@ -14,11 +14,15 @@ public:
|
|||||||
{
|
{
|
||||||
return (mapKeys.count(vchPubKey) > 0);
|
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);
|
std::map<std::vector<unsigned char>, CPrivKey>::const_iterator mi = mapKeys.find(vchPubKey);
|
||||||
if (mi != mapKeys.end())
|
if (mi != mapKeys.end())
|
||||||
return (*mi).second;
|
{
|
||||||
|
keyOut = (*mi).second;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
std::vector<unsigned char> GenerateNewKey();
|
std::vector<unsigned char> GenerateNewKey();
|
||||||
};
|
};
|
||||||
|
@ -1038,12 +1038,13 @@ bool Solver(const CKeyStore& keystore, const CScript& scriptPubKey, uint256 hash
|
|||||||
{
|
{
|
||||||
// Sign
|
// Sign
|
||||||
const valtype& vchPubKey = item.second;
|
const valtype& vchPubKey = item.second;
|
||||||
if (!keystore.HaveKey(vchPubKey))
|
CPrivKey privkey;
|
||||||
|
if (!keystore.GetPrivKey(vchPubKey, privkey))
|
||||||
return false;
|
return false;
|
||||||
if (hash != 0)
|
if (hash != 0)
|
||||||
{
|
{
|
||||||
vector<unsigned char> vchSig;
|
vector<unsigned char> vchSig;
|
||||||
if (!CKey::Sign(keystore.GetPrivKey(vchPubKey), hash, vchSig))
|
if (!CKey::Sign(privkey, hash, vchSig))
|
||||||
return false;
|
return false;
|
||||||
vchSig.push_back((unsigned char)nHashType);
|
vchSig.push_back((unsigned char)nHashType);
|
||||||
scriptSigRet << vchSig;
|
scriptSigRet << vchSig;
|
||||||
@ -1056,12 +1057,13 @@ bool Solver(const CKeyStore& keystore, const CScript& scriptPubKey, uint256 hash
|
|||||||
if (mi == mapPubKeys.end())
|
if (mi == mapPubKeys.end())
|
||||||
return false;
|
return false;
|
||||||
const vector<unsigned char>& vchPubKey = (*mi).second;
|
const vector<unsigned char>& vchPubKey = (*mi).second;
|
||||||
if (!keystore.HaveKey(vchPubKey))
|
CPrivKey privkey;
|
||||||
|
if (!keystore.GetPrivKey(vchPubKey, privkey))
|
||||||
return false;
|
return false;
|
||||||
if (hash != 0)
|
if (hash != 0)
|
||||||
{
|
{
|
||||||
vector<unsigned char> vchSig;
|
vector<unsigned char> vchSig;
|
||||||
if (!CKey::Sign(keystore.GetPrivKey(vchPubKey), hash, vchSig))
|
if (!CKey::Sign(privkey, hash, vchSig))
|
||||||
return false;
|
return false;
|
||||||
vchSig.push_back((unsigned char)nHashType);
|
vchSig.push_back((unsigned char)nHashType);
|
||||||
scriptSigRet << vchSig << vchPubKey;
|
scriptSigRet << vchSig << vchPubKey;
|
||||||
|
@ -1006,8 +1006,8 @@ bool CWallet::GetTransaction(const uint256 &hashTx, CWalletTx& wtx)
|
|||||||
wtx = (*mi).second;
|
wtx = (*mi).second;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GetWalletFile(CWallet* pwallet, string &strWalletFileOut)
|
bool GetWalletFile(CWallet* pwallet, string &strWalletFileOut)
|
||||||
|
@ -96,7 +96,7 @@ public:
|
|||||||
{
|
{
|
||||||
if (!MoneyRange(txout.nValue))
|
if (!MoneyRange(txout.nValue))
|
||||||
throw std::runtime_error("CWallet::GetChange() : value out of range");
|
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
|
bool IsMine(const CTransaction& tx) const
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user